- Timestamp:
- 16/08/10 13:54:09 (11 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/__init__.py
r7168 r7327 131 131 X500DN.fromString("/O=Site A/CN=Authorisation Service"), 132 132 X500DN.fromString("/O=Site B/CN=Authorisation Service"), 133 X500DN.fromString('/CN=test/O=NDG/OU=BADC') 133 X500DN.fromString('/CN=test/O=NDG/OU=BADC'), 134 X500DN.fromString('/O=NDG/OU=Security/CN=localhost') 134 135 ) 135 136 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/x509/test_x509.py
r6861 r7327 25 25 26 26 from ConfigParser import SafeConfigParser 27 27 28 from ndg.security.test.unit import BaseTestCase 28 29 import warnings 30 _warningMsg = None 31 _origWarn = warnings.warn 32 def _warnWrapper(*arg, **kw): 33 global _warningMsg 34 _warningMsg = arg[0] 35 _origWarn(*arg, **kw) 36 37 warnings.warn = _warnWrapper 38 39 from ndg.security.common.X509 import X509CertRead, X509CertParse, X500DN, \ 40 X509Stack, X509StackEmptyError, SelfSignedCert, X509CertIssuerNotFound 29 from ndg.security.common.X509 import (X509CertRead, X509CertParse, X500DN, 30 X509Stack, X509StackEmptyError, SelfSignedCert, X509CertIssuerNotFound) 31 41 32 42 33 class X509TestCase(BaseTestCase): 43 34 """Unit test X509 module""" 44 35 CA_DIR = os.path.join(BaseTestCase.NDGSEC_TEST_CONFIG_DIR, 'ca') 45 46 def __del__(self):47 warnings.warn = _origWarn48 if getattr(super(X509TestCase, self), "__del__", None):49 super(X509TestCase, self).__del__()50 36 51 37 def setUp(self): … … 189 175 self.test01X509CertRead() 190 176 191 # Set ridiculous bounds for expiry warning to ensure a warning message 192 # is output 193 self.assert_(self.x509Cert.isValidTime(nDaysBeforeExpiryLimit=36500), 194 "Certificate has expired") 195 if not _warningMsg: 196 self.fail("No warning message was set") 197 else: 198 print("PASSED - Got warning message from X509Cert." 199 "isValidTime: %s" % _warningMsg) 200 201 def test10ReadStackFromCADir(self): 202 203 stack = X509Stack.fromCADir(X509TestCase.CA_DIR) 204 self.assert_(stack) 205 self.assert_(len(stack) > 0) 177 warningMsg = None 178 179 # Capture stderr 180 try: 181 warningOutput = StringIO() 182 _stderr = sys.stderr 183 sys.stderr = warningOutput 184 185 # Set ridiculous bounds for expiry warning to ensure a warning 186 # message is output 187 validStatus = self.x509Cert.isValidTime( 188 nDaysBeforeExpiryLimit=36500) 189 self.assert_(validStatus, "Certificate has expired") 190 finally: 191 sys.stderr = _stderr 192 warningMsg = warningOutput.getvalue() 193 194 self.assert_("UserWarning" in str(warningMsg), 195 "No warning message was set") 196 197 print("PASSED - Got warning message from X509Cert.isValidTime: %s" % 198 warningMsg) 199 206 200 207 201 class X500DNTestCase(BaseTestCase): … … 215 209 self.assert_(str(dn)) 216 210 print(dn) 211 212 def test02VerifyCommaSeparatedDnParsing(self): 213 # Test parsing for ',' delimited fields 214 dnStr = 'O=NDG, OU=Security, CN=localhost' 215 dn = X500DN.fromString(dnStr) 216 self.assert_(str(dn)) 217 print(dn) 218 217 219 218 220 if __name__ == "__main__": -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/xacml/pip-mapping.txt
r7314 r7327 19 19 20 20 # Entries are whitespace delimited <attribute id> <attribute authority> 21 urn: ndg:security:attributeshttps://localhost:5443/AttributeAuthority21 urn:siteA:security:authz:1.0:attr https://localhost:5443/AttributeAuthority 22 22 myattributeid https://myattributeauthority.ac.uk/ 23 23 http://someotherattributeid.schema https://another.ac.uk/attributeservice/ -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/xacml/test_saml_pip.py
r7314 r7327 38 38 CONFIG_FILEPATH = path.join(THIS_DIR, CONFIG_FILENAME) 39 39 40 NDGS_ATTR_ID = 'urn:ndg:security:attributes'40 NDGS_ATTR_ID = BaseTestCase.ATTRIBUTE_NAMES[0] 41 41 OPENID_ATTR_ID = 'urn:esg:openid' 42 OPENID = 'https://localhost:7443/pjkershaw'43 42 44 43 CLNT_CERT_FILEPATH = path.join(BaseTestCase.PKI_DIR, 'localhost.crt') … … 83 82 openidAttr.dataType) 84 83 85 openidAttrVal = anyUriAttrValue(self.__class__.OPENID )84 openidAttrVal = anyUriAttrValue(self.__class__.OPENID_URI) 86 85 openidAttr.attributeValues.append(openidAttrVal) 87 86 … … 115 114 ctx = self._createXacmlRequestCtx() 116 115 117 attributes = pip.attributeQuery(ctx, designator) 118 self.assert_(len(attributes) > 0) 116 attributeValues = pip.attributeQuery(ctx, designator) 117 self.assert_(len(attributeValues) > 0) 118 print("PIP retrieved attribute values %r" % attributeValues) 119 119 120 120 def test04InitFromConfigFile(self): … … 122 122 pip = PIP.fromConfig(self.__class__.CONFIG_FILEPATH) 123 123 self.assert_(pip.mappingFilePath) 124 125 for i in dir(PIP): 126 print("%s = %r" % (i, getattr(pip, i))) 124 127 125 128 126 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.