Skip to content

Commit efe33a7

Browse files
committed
CI Integration. TeamCity
1 parent f4857f0 commit efe33a7

11 files changed

Lines changed: 102 additions & 2 deletions

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
],
3939
extras_require={
4040
'test': (
41-
'coverage==3.7.1',
41+
'teamcity-messages==1.17',
42+
'coverage==4.0.3',
4243
'freezegun==0.3.5',
4344
'pylint==1.3.1',
4445
'pep8==1.5.7',

tests/src/OneLogin/saml2_tests/auth_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import json
88
from os.path import dirname, join, exists
99
import unittest
10+
from teamcity import is_running_under_teamcity
11+
from teamcity.unittestpy import TeamcityTestRunner
1012
from urlparse import urlparse, parse_qs
1113

1214
from onelogin.saml2.auth import OneLogin_Saml2_Auth
@@ -858,3 +860,11 @@ def testBuildResponseSignature(self):
858860
auth2.build_response_signature(message, relay_state)
859861
except Exception as e:
860862
self.assertIn("Trying to sign the SAMLResponse but can't load the SP private key", e.message)
863+
864+
865+
if __name__ == '__main__':
866+
if is_running_under_teamcity():
867+
runner = TeamcityTestRunner()
868+
else:
869+
runner = unittest.TextTestRunner()
870+
unittest.main(testRunner=runner)

tests/src/OneLogin/saml2_tests/authn_request_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import json
88
from os.path import dirname, join, exists
99
import unittest
10+
from teamcity import is_running_under_teamcity
11+
from teamcity.unittestpy import TeamcityTestRunner
1012
from urlparse import urlparse, parse_qs
1113
from zlib import decompress
1214

@@ -257,3 +259,11 @@ def testCreateEncSAMLRequest(self):
257259
self.assertRegexpMatches(inflated, '<saml:Issuer>http://stuff.com/endpoints/metadata.php</saml:Issuer>')
258260
self.assertRegexpMatches(inflated, 'Format="urn:oasis:names:tc:SAML:2.0:nameid-format:encrypted"')
259261
self.assertRegexpMatches(inflated, 'ProviderName="SP prueba"')
262+
263+
264+
if __name__ == '__main__':
265+
if is_running_under_teamcity():
266+
runner = TeamcityTestRunner()
267+
else:
268+
runner = unittest.TextTestRunner()
269+
unittest.main(testRunner=runner)

tests/src/OneLogin/saml2_tests/error_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44
# All rights reserved.
55

66
import unittest
7+
from teamcity import is_running_under_teamcity
8+
from teamcity.unittestpy import TeamcityTestRunner
79
from onelogin.saml2.errors import OneLogin_Saml2_Error
810

911

1012
class OneLogin_Saml2_Error_Test(unittest.TestCase):
1113
"""
1214
Tests the OneLogin_Saml2_Error Constructor.
1315
"""
14-
1516
def runTest(self):
1617
exception = OneLogin_Saml2_Error('test')
1718
self.assertEqual(exception.message, 'test')
19+
20+
21+
if __name__ == '__main__':
22+
if is_running_under_teamcity():
23+
runner = TeamcityTestRunner()
24+
else:
25+
runner = unittest.TextTestRunner()
26+
unittest.main(testRunner=runner)

tests/src/OneLogin/saml2_tests/logout_request_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import json
88
from os.path import dirname, join, exists
99
import unittest
10+
from teamcity import is_running_under_teamcity
11+
from teamcity.unittestpy import TeamcityTestRunner
1012
from urlparse import urlparse, parse_qs
1113
from xml.dom.minidom import parseString
1214

@@ -438,3 +440,11 @@ def testIsValidSign(self):
438440
self.assertFalse(valid)
439441
except Exception as e:
440442
self.assertIn('In order to validate the sign on the Logout Request, the x509cert of the IdP is required', e.message)
443+
444+
445+
if __name__ == '__main__':
446+
if is_running_under_teamcity():
447+
runner = TeamcityTestRunner()
448+
else:
449+
runner = unittest.TextTestRunner()
450+
unittest.main(testRunner=runner)

tests/src/OneLogin/saml2_tests/logout_response_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import json
77
from os.path import dirname, join, exists
88
import unittest
9+
from teamcity import is_running_under_teamcity
10+
from teamcity.unittestpy import TeamcityTestRunner
911
from urlparse import urlparse, parse_qs
1012
from xml.dom.minidom import parseString
1113

@@ -381,3 +383,11 @@ def testIsValid(self):
381383

382384
response_3 = OneLogin_Saml2_Logout_Response(settings, message_3)
383385
self.assertTrue(response_3.is_valid(request_data))
386+
387+
388+
if __name__ == '__main__':
389+
if is_running_under_teamcity():
390+
runner = TeamcityTestRunner()
391+
else:
392+
runner = unittest.TextTestRunner()
393+
unittest.main(testRunner=runner)

tests/src/OneLogin/saml2_tests/metadata_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from time import strftime
1010
from datetime import datetime
1111
import unittest
12+
from teamcity import is_running_under_teamcity
13+
from teamcity.unittestpy import TeamcityTestRunner
1214

1315
from onelogin.saml2.metadata import OneLogin_Saml2_Metadata
1416
from onelogin.saml2.settings import OneLogin_Saml2_Settings
@@ -222,3 +224,11 @@ def testAddX509KeyDescriptors(self):
222224
self.assertFalse(True)
223225
except Exception as e:
224226
self.assertIn('Error parsing metadata', e.message)
227+
228+
229+
if __name__ == '__main__':
230+
if is_running_under_teamcity():
231+
runner = TeamcityTestRunner()
232+
else:
233+
runner = unittest.TextTestRunner()
234+
unittest.main(testRunner=runner)

tests/src/OneLogin/saml2_tests/response_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import json
1111
from os.path import dirname, join, exists
1212
import unittest
13+
from teamcity import is_running_under_teamcity
14+
from teamcity.unittestpy import TeamcityTestRunner
1315
from xml.dom.minidom import parseString
1416

1517
from onelogin.saml2.response import OneLogin_Saml2_Response
@@ -1175,3 +1177,11 @@ def testIsValidSignWithEmptyReferenceURI(self):
11751177
xml = self.file_contents(join(self.data_path, 'responses', 'response_without_reference_uri.xml.base64'))
11761178
response = OneLogin_Saml2_Response(settings, xml)
11771179
self.assertTrue(response.is_valid(self.get_request_data()))
1180+
1181+
1182+
if __name__ == '__main__':
1183+
if is_running_under_teamcity():
1184+
runner = TeamcityTestRunner()
1185+
else:
1186+
runner = unittest.TextTestRunner()
1187+
unittest.main(testRunner=runner)

tests/src/OneLogin/saml2_tests/settings_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import json
77
from os.path import dirname, join, exists, sep
88
import unittest
9+
from teamcity import is_running_under_teamcity
10+
from teamcity.unittestpy import TeamcityTestRunner
911

1012
from onelogin.saml2.errors import OneLogin_Saml2_Error
1113
from onelogin.saml2.settings import OneLogin_Saml2_Settings
@@ -669,3 +671,11 @@ def testIsDebugActive(self):
669671
settings_info['debug'] = True
670672
settings_3 = OneLogin_Saml2_Settings(settings_info)
671673
self.assertTrue(settings_3.is_debug_active())
674+
675+
676+
if __name__ == '__main__':
677+
if is_running_under_teamcity():
678+
runner = TeamcityTestRunner()
679+
else:
680+
runner = unittest.TextTestRunner()
681+
unittest.main(testRunner=runner)

tests/src/OneLogin/saml2_tests/signed_response_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import json
88
from os.path import dirname, join, exists
99
import unittest
10+
from teamcity import is_running_under_teamcity
11+
from teamcity.unittestpy import TeamcityTestRunner
1012

1113
from onelogin.saml2.response import OneLogin_Saml2_Response
1214
from onelogin.saml2.settings import OneLogin_Saml2_Settings
@@ -52,3 +54,11 @@ def testResponseAndAssertionSigned(self):
5254
response = OneLogin_Saml2_Response(settings, b64encode(message))
5355

5456
self.assertEquals('someone@example.com', response.get_nameid())
57+
58+
59+
if __name__ == '__main__':
60+
if is_running_under_teamcity():
61+
runner = TeamcityTestRunner()
62+
else:
63+
runner = unittest.TextTestRunner()
64+
unittest.main(testRunner=runner)

0 commit comments

Comments
 (0)