Changeset 4447 for TI12-security/trunk/python
- Timestamp:
- 19/11/08 13:10:48 (12 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 9 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/ndg.security.common/ndg/security/common/credentialwallet.py
r4446 r4447 1070 1070 raise CredentialWalletError("Error requesting attribute: " 1071 1071 "certificate a URI or Attribute " 1072 "Authority configuration file must be " 1073 "specified") 1072 "Authority instance must be specified") 1074 1073 1075 1074 try: … … 1343 1342 self.attributeAuthorityURI = attributeAuthorityURI 1344 1343 1345 if attributeAuthority :1344 if attributeAuthority is not None: 1346 1345 self.attributeAuthority = attributeAuthority 1347 1346 -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/zsi/attributeauthority/__init__.py
r4404 r4447 73 73 # Get certificate corresponding to private key that signed the 74 74 # message - i.e. the user's proxy 75 holder Cert = signatureFilter.signatureHandler.verifyingCert75 holderX509Cert = signatureFilter.signatureHandler.verifyingCert 76 76 else: 77 77 # No signature from client - they must instead provide the 78 78 # designated holder cert via the UserCert input 79 holder Cert = request.UserCert79 holderX509Cert = request.UserCert 80 80 81 81 try: 82 82 attCert = self.aa.getAttCert(userId=request.UserId, 83 holder Cert=holderCert,83 holderX509Cert=holderX509Cert, 84 84 userAttCert=request.UserAttCert) 85 85 response.AttCert = attCert.toString() -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/credentialwallet/siteAAttributeAuthority/__init__.py
r4446 r4447 1 """NDG Security Session Manager unit test package - cadirectory2 for storing CA cert.s used in SSL connections1 """NDG Security Credential Wallet unit test package - directory 2 for test Attribute Authority used in these tests 3 3 4 4 NERC Data Grid Project 5 5 """ 6 6 __author__ = "P J Kershaw" 7 __date__ = "1 2/12/07"8 __copyright__ = "(C) 200 7STFC & NERC"7 __date__ = "19/11/08" 8 __copyright__ = "(C) 2008 STFC & NERC" 9 9 __license__ = \ 10 10 """This software may be distributed under the terms of the Q Public -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/credentialwallet/test_credentialwallet.py
r4446 r4447 53 53 54 54 55 #def test01ReadOnlyClassVariables(self):56 #57 #try:58 #CredentialWallet.accessDenied = 'yes'59 #self.fail("accessDenied class variable should be read-only")60 #except Exception, e:61 #print("PASS - accessDenied class variable is read-only")62 # 63 #try:64 #CredentialWallet.accessGranted = False65 #self.fail("accessGranted class variable should be read-only")66 #except Exception, e:67 #print("PASS - accessGranted class variable is read-only")68 #69 #assert(not CredentialWallet.accessDenied)70 #assert(CredentialWallet.accessGranted)71 #72 #73 #def test02SetAttributes(self):74 #75 #credWallet = CredentialWallet()76 #credWallet.userX509Cert = \77 #'''-----BEGIN CERTIFICATE-----78 #MIICazCCAdSgAwIBAgICAPcwDQYJKoZIhvcNAQEEBQAwLzEMMAoGA1UEChMDTkRH79 #MQ0wCwYDVQQLEwRCQURDMRAwDgYDVQQDEwdUZXN0IENBMB4XDTA4MDEwNDEwMTk080 #N1oXDTA5MDEwMzEwMTk0N1owLDEMMAoGA1UEChMDTkRHMQ0wCwYDVQQLEwRCQURD81 #MQ0wCwYDVQQDEwR0ZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA82 #rpbuNUHWVRwhjHzhTOdym+fcZdmD7HbaeoFdef2V//Wj41xMieMZy9XQft2dFBDY83 #ZIHLElojVhZTHoowMkwXxsmLt7hZF8fL7j3ssU/lflM9E0Uk2dZxaAt97zXEruEH84 #JoNqHTEQlH0qMALfuUrAaZEIXHDdTQDNRJl4oXvjJWaqS8Y5Je8QREThIE5hRd9F85 #oUlgfMNNnwzLyIH7s0KBci2yryeubAG/Qig5LkulbpnhxYLCcLvs3THQ3kO5qYYb86 #B0g11YOBgshZ0SpNwEEyhDzHUt3Ii2XmAh25/II08BR61fhMZvSJ/tVGJY4HfWG787 #B4PZzYwo5vn/tYH1mk7w5QIDAQABoxUwEzARBglghkgBhvhCAQEEBAMCBPAwDQYJ88 #KoZIhvcNAQEEBQADgYEAFKEdr2FwlposAGRDHBMX9d48TKm1gXzOMEvReTYIaq4689 #aMpDDuApsbjpRqohvKIrngGa2e1p81tOTL5kbuusNjcNsagXkNgeO6qcGZCly/Bl90 #9Kxfynaned5jmgWgoxJP7VtOynvlLqJfrS/cEwOWDYpyPjJDRx2cZgEd3P4WfYI=91 #-----END CERTIFICATE-----92 #'''93 #print("userCert=%s" % credWallet.userX509Cert)94 #credWallet.userId = 'ndg-user'95 #print("userId=%s" % credWallet.userId)96 #97 #try:98 #credWallet.blah = 'blah blah'99 #self.fail("Attempting to set attribute not in __slots__ class "100 #"variable should fail")101 #except AttributeError:102 #print("PASS - expected AttributeError when setting attribute "103 #"not in __slots__ class variable")104 #105 #credWallet.caCertFilePathList=None106 #credWallet.attributeAuthorityURI='http://localhost/AttributeAuthority'107 #108 #credWallet.attributeAuthority = None109 #credWallet.credentialRepository = None110 #credWallet.mapFromTrustedHosts = False111 #credWallet.rtnExtAttCertList = True112 #credWallet.attCertRefreshElapse = 7200113 #114 #def test03GetAttCertWithUserId(self):115 #116 #credWallet = CredentialWallet(cfg=self.cfg.get('setUp', 'cfgFilePath'))117 #attCert = credWallet.getAttCert()118 #119 ## No user X.509 cert is set so the resulting Attribute Certificate120 ## user ID should be the same as that set for the wallet121 #assert(attCert.userId == credWallet.userId)122 #print "Attribute Certificate:\n%s" % attCert123 #124 #def test04GetAttCertWithUserX509Cert(self):125 #126 #credWallet = CredentialWallet(cfg=self.cfg.get('setUp', 'cfgFilePath'))127 #128 ## Set a test individual user certificate to override the client129 ## cert. and private key in WS-Security settings in the config file130 #credWallet.userX509Cert = """131 #-----BEGIN CERTIFICATE-----132 #MIICazCCAdSgAwIBAgICAPcwDQYJKoZIhvcNAQEEBQAwLzEMMAoGA1UEChMDTkRH133 #MQ0wCwYDVQQLEwRCQURDMRAwDgYDVQQDEwdUZXN0IENBMB4XDTA4MDEwNDEwMTk0134 #N1oXDTA5MDEwMzEwMTk0N1owLDEMMAoGA1UEChMDTkRHMQ0wCwYDVQQLEwRCQURD135 #MQ0wCwYDVQQDEwR0ZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA136 #rpbuNUHWVRwhjHzhTOdym+fcZdmD7HbaeoFdef2V//Wj41xMieMZy9XQft2dFBDY137 #ZIHLElojVhZTHoowMkwXxsmLt7hZF8fL7j3ssU/lflM9E0Uk2dZxaAt97zXEruEH138 #JoNqHTEQlH0qMALfuUrAaZEIXHDdTQDNRJl4oXvjJWaqS8Y5Je8QREThIE5hRd9F139 #oUlgfMNNnwzLyIH7s0KBci2yryeubAG/Qig5LkulbpnhxYLCcLvs3THQ3kO5qYYb140 #B0g11YOBgshZ0SpNwEEyhDzHUt3Ii2XmAh25/II08BR61fhMZvSJ/tVGJY4HfWG7141 #B4PZzYwo5vn/tYH1mk7w5QIDAQABoxUwEzARBglghkgBhvhCAQEEBAMCBPAwDQYJ142 #KoZIhvcNAQEEBQADgYEAFKEdr2FwlposAGRDHBMX9d48TKm1gXzOMEvReTYIaq46143 #aMpDDuApsbjpRqohvKIrngGa2e1p81tOTL5kbuusNjcNsagXkNgeO6qcGZCly/Bl144 #9Kxfynaned5jmgWgoxJP7VtOynvlLqJfrS/cEwOWDYpyPjJDRx2cZgEd3P4WfYI=145 #-----END CERTIFICATE-----146 #"""147 #credWallet.userPriKey = """148 #-----BEGIN RSA PRIVATE KEY-----149 #MIIEowIBAAKCAQEArpbuNUHWVRwhjHzhTOdym+fcZdmD7HbaeoFdef2V//Wj41xM150 #ieMZy9XQft2dFBDYZIHLElojVhZTHoowMkwXxsmLt7hZF8fL7j3ssU/lflM9E0Uk151 #2dZxaAt97zXEruEHJoNqHTEQlH0qMALfuUrAaZEIXHDdTQDNRJl4oXvjJWaqS8Y5152 #Je8QREThIE5hRd9FoUlgfMNNnwzLyIH7s0KBci2yryeubAG/Qig5LkulbpnhxYLC153 #cLvs3THQ3kO5qYYbB0g11YOBgshZ0SpNwEEyhDzHUt3Ii2XmAh25/II08BR61fhM154 #ZvSJ/tV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iBhONyCWcJDT1BSEMMQjqgqNFOBBDMPRhLs7g3sRL1vYrLuC4iYe382e2p8ZXJe+171 #Kg6/BQKBgDlFDM9m/9A11PIlh/ir0KXUqtPA1q+Hn629BRsbbsH2HW+kj018RLT+172 #SgRwhrqFtF5HCMXEh0ez/RyHHoMiVnan9jpLtGEdE8ojJnISjvkIyLUCCJdq8HYC173 #25UDHqKuoqHBiXWazfZ6MOlcIm6vp1FpVDygu59JHPROMxW+BAg/174 #-----END RSA PRIVATE KEY-----175 #"""176 #attCert = credWallet.getAttCert()177 #178 ## A user X.509 cert. was set so this cert's DN should be set in the179 ## userId field of the resulting Attribute Certificate180 #assert(attCert.userId == str(credWallet.userX509Cert.dn))181 #print "Attribute Certificate:\n%s" % attCert182 #183 # 184 # 185 #def test05GetAttCertRefusedWithUserCert(self):186 #187 ## Keyword mapFromTrustedHosts overrides any setting in the config file188 ## This flag prevents role mapping from a trusted AA and so in this case189 ## forces refusal of the request190 #credWallet = CredentialWallet(cfg=self.cfg.get('setUp', 'cfgFilePath'),191 #mapFromTrustedHosts=False)192 #credWallet.userX509CertFilePath = self.cfg.get('setUp',193 #'userX509CertFilePath')194 #credWallet.userPriKeyFilePath = self.cfg.get('setUp',195 #'userPriKeyFilePath')196 #197 ## Set AA URI AFTER user PKI settings so that these are picked in the198 ## implicit call to create a new AA Client when the URI is set199 #credWallet.attributeAuthorityURI = self.cfg.get('setUp',200 #'attributeAuthorityURI')201 #try:202 #attCert = credWallet.getAttCert()203 #except CredentialWalletAttributeRequestDenied, e:204 #print "SUCCESS - obtained expected result: %s" % e205 #return206 #207 #self.fail("Request allowed from Attribute Authority where user is NOT "208 #"registered!")209 # 210 #def test06GetMappedAttCertWithUserId(self):211 #212 ## Call Site A Attribute Authority where user is registered213 #credWallet = CredentialWallet(cfg=self.cfg.get('setUp', 'cfgFilePath'))214 #attCert = credWallet.getAttCert()215 # 216 ## Use Attribute Certificate cached in wallet to get a mapped217 ## Attribute Certificate from Site B's Attribute Authority218 #siteBURI = self.cfg.get('setUp', 'attributeAuthorityURI')219 #attCert = credWallet.getAttCert(attributeAuthorityURI=siteBURI)220 #221 #print("Mapped Attribute Certificate from Site B Attribute "222 #"Authority:\n%s" % attCert)55 def test01ReadOnlyClassVariables(self): 56 57 try: 58 CredentialWallet.accessDenied = 'yes' 59 self.fail("accessDenied class variable should be read-only") 60 except Exception, e: 61 print("PASS - accessDenied class variable is read-only") 62 63 try: 64 CredentialWallet.accessGranted = False 65 self.fail("accessGranted class variable should be read-only") 66 except Exception, e: 67 print("PASS - accessGranted class variable is read-only") 68 69 assert(not CredentialWallet.accessDenied) 70 assert(CredentialWallet.accessGranted) 71 72 73 def test02SetAttributes(self): 74 75 credWallet = CredentialWallet() 76 credWallet.userX509Cert = \ 77 '''-----BEGIN CERTIFICATE----- 78 MIICazCCAdSgAwIBAgICAPcwDQYJKoZIhvcNAQEEBQAwLzEMMAoGA1UEChMDTkRH 79 MQ0wCwYDVQQLEwRCQURDMRAwDgYDVQQDEwdUZXN0IENBMB4XDTA4MDEwNDEwMTk0 80 N1oXDTA5MDEwMzEwMTk0N1owLDEMMAoGA1UEChMDTkRHMQ0wCwYDVQQLEwRCQURD 81 MQ0wCwYDVQQDEwR0ZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA 82 rpbuNUHWVRwhjHzhTOdym+fcZdmD7HbaeoFdef2V//Wj41xMieMZy9XQft2dFBDY 83 ZIHLElojVhZTHoowMkwXxsmLt7hZF8fL7j3ssU/lflM9E0Uk2dZxaAt97zXEruEH 84 JoNqHTEQlH0qMALfuUrAaZEIXHDdTQDNRJl4oXvjJWaqS8Y5Je8QREThIE5hRd9F 85 oUlgfMNNnwzLyIH7s0KBci2yryeubAG/Qig5LkulbpnhxYLCcLvs3THQ3kO5qYYb 86 B0g11YOBgshZ0SpNwEEyhDzHUt3Ii2XmAh25/II08BR61fhMZvSJ/tVGJY4HfWG7 87 B4PZzYwo5vn/tYH1mk7w5QIDAQABoxUwEzARBglghkgBhvhCAQEEBAMCBPAwDQYJ 88 KoZIhvcNAQEEBQADgYEAFKEdr2FwlposAGRDHBMX9d48TKm1gXzOMEvReTYIaq46 89 aMpDDuApsbjpRqohvKIrngGa2e1p81tOTL5kbuusNjcNsagXkNgeO6qcGZCly/Bl 90 9Kxfynaned5jmgWgoxJP7VtOynvlLqJfrS/cEwOWDYpyPjJDRx2cZgEd3P4WfYI= 91 -----END CERTIFICATE----- 92 ''' 93 print("userCert=%s" % credWallet.userX509Cert) 94 credWallet.userId = 'ndg-user' 95 print("userId=%s" % credWallet.userId) 96 97 try: 98 credWallet.blah = 'blah blah' 99 self.fail("Attempting to set attribute not in __slots__ class " 100 "variable should fail") 101 except AttributeError: 102 print("PASS - expected AttributeError when setting attribute " 103 "not in __slots__ class variable") 104 105 credWallet.caCertFilePathList=None 106 credWallet.attributeAuthorityURI='http://localhost/AttributeAuthority' 107 108 credWallet.attributeAuthority = None 109 credWallet.credentialRepository = None 110 credWallet.mapFromTrustedHosts = False 111 credWallet.rtnExtAttCertList = True 112 credWallet.attCertRefreshElapse = 7200 113 114 def test03GetAttCertWithUserId(self): 115 116 credWallet = CredentialWallet(cfg=self.cfg.get('setUp', 'cfgFilePath')) 117 attCert = credWallet.getAttCert() 118 119 # No user X.509 cert is set so the resulting Attribute Certificate 120 # user ID should be the same as that set for the wallet 121 assert(attCert.userId == credWallet.userId) 122 print "Attribute Certificate:\n%s" % attCert 123 124 def test04GetAttCertWithUserX509Cert(self): 125 126 credWallet = CredentialWallet(cfg=self.cfg.get('setUp', 'cfgFilePath')) 127 128 # Set a test individual user certificate to override the client 129 # cert. and private key in WS-Security settings in the config file 130 credWallet.userX509Cert = """ 131 -----BEGIN CERTIFICATE----- 132 MIICazCCAdSgAwIBAgICAPcwDQYJKoZIhvcNAQEEBQAwLzEMMAoGA1UEChMDTkRH 133 MQ0wCwYDVQQLEwRCQURDMRAwDgYDVQQDEwdUZXN0IENBMB4XDTA4MDEwNDEwMTk0 134 N1oXDTA5MDEwMzEwMTk0N1owLDEMMAoGA1UEChMDTkRHMQ0wCwYDVQQLEwRCQURD 135 MQ0wCwYDVQQDEwR0ZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA 136 rpbuNUHWVRwhjHzhTOdym+fcZdmD7HbaeoFdef2V//Wj41xMieMZy9XQft2dFBDY 137 ZIHLElojVhZTHoowMkwXxsmLt7hZF8fL7j3ssU/lflM9E0Uk2dZxaAt97zXEruEH 138 JoNqHTEQlH0qMALfuUrAaZEIXHDdTQDNRJl4oXvjJWaqS8Y5Je8QREThIE5hRd9F 139 oUlgfMNNnwzLyIH7s0KBci2yryeubAG/Qig5LkulbpnhxYLCcLvs3THQ3kO5qYYb 140 B0g11YOBgshZ0SpNwEEyhDzHUt3Ii2XmAh25/II08BR61fhMZvSJ/tVGJY4HfWG7 141 B4PZzYwo5vn/tYH1mk7w5QIDAQABoxUwEzARBglghkgBhvhCAQEEBAMCBPAwDQYJ 142 KoZIhvcNAQEEBQADgYEAFKEdr2FwlposAGRDHBMX9d48TKm1gXzOMEvReTYIaq46 143 aMpDDuApsbjpRqohvKIrngGa2e1p81tOTL5kbuusNjcNsagXkNgeO6qcGZCly/Bl 144 9Kxfynaned5jmgWgoxJP7VtOynvlLqJfrS/cEwOWDYpyPjJDRx2cZgEd3P4WfYI= 145 -----END CERTIFICATE----- 146 """ 147 credWallet.userPriKey = """ 148 -----BEGIN RSA PRIVATE KEY----- 149 MIIEowIBAAKCAQEArpbuNUHWVRwhjHzhTOdym+fcZdmD7HbaeoFdef2V//Wj41xM 150 ieMZy9XQft2dFBDYZIHLElojVhZTHoowMkwXxsmLt7hZF8fL7j3ssU/lflM9E0Uk 151 2dZxaAt97zXEruEHJoNqHTEQlH0qMALfuUrAaZEIXHDdTQDNRJl4oXvjJWaqS8Y5 152 Je8QREThIE5hRd9FoUlgfMNNnwzLyIH7s0KBci2yryeubAG/Qig5LkulbpnhxYLC 153 cLvs3THQ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 169 gluNKgxoZC2qj812w8l1HHJYUfg8ZQU3pmrDfuRAKm0tCncwaSPUeGh62axC2rGa 170 iBhONyCWcJDT1BSEMMQjqgqNFOBBDMPRhLs7g3sRL1vYrLuC4iYe382e2p8ZXJe+ 171 Kg6/BQKBgDlFDM9m/9A11PIlh/ir0KXUqtPA1q+Hn629BRsbbsH2HW+kj018RLT+ 172 SgRwhrqFtF5HCMXEh0ez/RyHHoMiVnan9jpLtGEdE8ojJnISjvkIyLUCCJdq8HYC 173 25UDHqKuoqHBiXWazfZ6MOlcIm6vp1FpVDygu59JHPROMxW+BAg/ 174 -----END RSA PRIVATE KEY----- 175 """ 176 attCert = credWallet.getAttCert() 177 178 # A user X.509 cert. was set so this cert's DN should be set in the 179 # userId field of the resulting Attribute Certificate 180 assert(attCert.userId == str(credWallet.userX509Cert.dn)) 181 print "Attribute Certificate:\n%s" % attCert 182 183 184 185 def test05GetAttCertRefusedWithUserCert(self): 186 187 # Keyword mapFromTrustedHosts overrides any setting in the config file 188 # This flag prevents role mapping from a trusted AA and so in this case 189 # forces refusal of the request 190 credWallet = CredentialWallet(cfg=self.cfg.get('setUp', 'cfgFilePath'), 191 mapFromTrustedHosts=False) 192 credWallet.userX509CertFilePath = self.cfg.get('setUp', 193 'userX509CertFilePath') 194 credWallet.userPriKeyFilePath = self.cfg.get('setUp', 195 'userPriKeyFilePath') 196 197 # Set AA URI AFTER user PKI settings so that these are picked in the 198 # implicit call to create a new AA Client when the URI is set 199 credWallet.attributeAuthorityURI = self.cfg.get('setUp', 200 'attributeAuthorityURI') 201 try: 202 attCert = credWallet.getAttCert() 203 except CredentialWalletAttributeRequestDenied, e: 204 print "SUCCESS - obtained expected result: %s" % e 205 return 206 207 self.fail("Request allowed from Attribute Authority where user is NOT " 208 "registered!") 209 210 def test06GetMappedAttCertWithUserId(self): 211 212 # Call Site A Attribute Authority where user is registered 213 credWallet = CredentialWallet(cfg=self.cfg.get('setUp', 'cfgFilePath')) 214 attCert = credWallet.getAttCert() 215 216 # Use Attribute Certificate cached in wallet to get a mapped 217 # Attribute Certificate from Site B's Attribute Authority 218 siteBURI = self.cfg.get('setUp', 'attributeAuthorityURI') 219 attCert = credWallet.getAttCert(attributeAuthorityURI=siteBURI) 220 221 print("Mapped Attribute Certificate from Site B Attribute " 222 "Authority:\n%s" % attCert) 223 223 224 224 def test07GetAttCertFromLocalAAInstance(self): -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionmanager/sessionMgrTest.cfg
r4402 r4447 22 22 propFilePath = $NDGSEC_SM_UNITTEST_DIR/sessionMgr.cfg 23 23 24 [test 1Connect]24 [test01Connect2AuthNServiceWithNoUserCertReturned] 25 25 # Alter username according to the MyProxy credentials you wish to test. If 26 26 # passphrase is commented out you will be prompted for it on the command line. … … 29 29 passphrase = testpassword 30 30 31 [test 2Connect2AuthNServiceReturningAUserCert]31 [test02Connect2AuthNServiceReturningAUserCert] 32 32 outputCredsFilePath = user.creds 33 33 34 [test 4ConnectNoCreateServerSess]34 [test04ConnectNoCreateServerSess] 35 35 username = testuser 36 36 passphrase = testpassword 37 37 38 [test 7GetAttCertWithSessID]38 [test07GetAttCertWithSessID] 39 39 aaURI = http://localhost:5000/AttributeAuthority 40 40 acOutputFilePath = $NDGSEC_SM_UNITTEST_DIR/ac-out.xml 41 41 42 [test 8GetAttCertRefusedWithSessID]42 [test08GetAttCertRefusedWithSessID] 43 43 aaURI = http://localhost:5100/AttributeAuthority 44 44 45 [test 9GetMappedAttCertWithSessID]45 [test09GetMappedAttCertWithSessID] 46 46 aaURI = http://localhost:5100/AttributeAuthority 47 47 48 48 [test10GetAttCertWithExtAttCertListWithSessID] 49 49 aaURI = http://localhost:5100/AttributeAuthority 50 # Use output from test 7GetAttCertWithSessID!50 # Use output from test07GetAttCertWithSessID! 51 51 extACFilePath = $NDGSEC_SM_UNITTEST_DIR/ac-out.xml 52 52 53 53 [test11GetAttCertWithUserCert] 54 54 aaURI = http://localhost:5000/AttributeAuthority 55 56 [test12GetAttCertFromLocalAAInstance] 57 aaPropFilePath = $NDGSEC_SM_UNITTEST_DIR/siteAAttributeAuthority/siteA-aa.cfg 58 acOutputFilePath = $NDGSEC_SM_UNITTEST_DIR/test12-ac-out.xml -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionmanager/test_sessionmanager.py
r4406 r4447 23 23 CaseSensitiveConfigParser 24 24 from ndg.security.common.X509 import X509CertParse 25 from ndg.security.server.sessionmanager import * 25 from ndg.security.server.sessionmanager import SessionManager 26 from ndg.security.server.attributeauthority import AttributeAuthority 26 27 27 28 from os.path import expandvars as xpdVars … … 130 131 print("Finished setting up connection") 131 132 132 def test1Connect2AuthNServiceWithNoUserCertReturned(self): 133 134 username = self.cfg.get('test1Connect', 'username') 133 def test01Connect2AuthNServiceWithNoUserCertReturned(self): 134 135 thisSection = 'test01Connect2AuthNServiceWithNoUserCertReturned' 136 username = self.cfg.get(thisSection, 'username') 135 137 if SessionManagerTestCase.passphrase is None and \ 136 self.cfg.has_option( 'test1Connect', 'passphrase'):137 SessionManagerTestCase.passphrase=self.cfg.get( 'test1Connect',138 138 self.cfg.has_option(thisSection, 'passphrase'): 139 SessionManagerTestCase.passphrase=self.cfg.get(thisSection, 140 'passphrase') 139 141 140 142 if not SessionManagerTestCase.passphrase: … … 150 152 assert(issuingCert is None) 151 153 152 print "User '%s' connected to Session Manager:\n%s" % \ 153 (username, sessID) 154 print("User '%s' connected to Session Manager:\n%s"%(username, sessID)) 154 155 155 def test 2Connect2AuthNServiceReturningAUserCert(self):156 157 section = 'test 2Connect2AuthNServiceReturningAUserCert'156 def test02Connect2AuthNServiceReturningAUserCert(self): 157 158 section = 'test02Connect2AuthNServiceReturningAUserCert' 158 159 159 160 # Change to alternative authentication service … … 185 186 186 187 187 def test 3GetSessionStatus(self):188 """test 3GetSessionStatus: check a session is alive"""188 def test03GetSessionStatus(self): 189 """test03GetSessionStatus: check a session is alive""" 189 190 190 191 self._connect() … … 197 198 print "CORRECT: sessID=abc doesn't exist" 198 199 199 def test 4ConnectNoCreateServerSess(self):200 """test 4ConnectNoCreateServerSess: Connect to retrieve credentials200 def test04ConnectNoCreateServerSess(self): 201 """test04ConnectNoCreateServerSess: Connect to retrieve credentials 201 202 only - no session is created. This makes sense only for an AuthN 202 203 Service that returns user credentials""" 203 section = 'test 4ConnectNoCreateServerSess'204 section = 'test04ConnectNoCreateServerSess' 204 205 205 206 # Change to alternative authentication service … … 243 244 244 245 245 def test 5DisconnectWithSessID(self):246 """test 5DisconnectWithSessID: disconnect as if acting as a browser246 def test05DisconnectWithSessID(self): 247 """test05DisconnectWithSessID: disconnect as if acting as a browser 247 248 client 248 249 """ … … 254 255 255 256 256 def test 6DisconnectWithUserCert(self):257 def test06DisconnectWithUserCert(self): 257 258 """test5DisconnectWithUserCert: Disconnect based on a user X.509 258 259 cert. credential from an earlier call to connect … … 266 267 267 268 268 def test 7GetAttCertWithSessID(self):269 """test 7GetAttCertWithSessID: make an attribute request using269 def test07GetAttCertWithSessID(self): 270 """test07GetAttCertWithSessID: make an attribute request using 270 271 a session ID as authentication credential""" 271 272 272 273 self._connect() 273 274 274 section = 'test 7GetAttCertWithSessID'275 section = 'test07GetAttCertWithSessID' 275 276 aaURI = self.cfg.get(section, 'aaURI') 276 277 attCert, errMsg, extAttCertList=self.sm.getAttCert(sessID=self.sessID, … … 282 283 attCert.filePath = xpdVars(self.cfg.get(section, 'acOutputFilePath')) 283 284 attCert.write() 284 285 return self.sm 286 287 288 def test8GetAttCertRefusedWithSessID(self): 289 """test8GetAttCertRefusedWithSessID: make an attribute request using 285 286 287 def test08GetAttCertRefusedWithSessID(self): 288 """test08GetAttCertRefusedWithSessID: make an attribute request using 290 289 a sessID as authentication credential requesting an AC from an 291 290 Attribute Authority where the user is NOT registered""" … … 293 292 self._connect() 294 293 295 aaURI = self.cfg.get('test 8GetAttCertRefusedWithSessID', 'aaURI')294 aaURI = self.cfg.get('test08GetAttCertRefusedWithSessID', 'aaURI') 296 295 297 296 attCert, errMsg, extAttCertList=self.sm.getAttCert(sessID=self.sessID, … … 305 304 306 305 307 def test 9GetMappedAttCertWithSessID(self):308 """test 9GetMappedAttCertWithSessID: make an attribute request using306 def test09GetMappedAttCertWithSessID(self): 307 """test09GetMappedAttCertWithSessID: make an attribute request using 309 308 a session ID as authentication credential""" 310 309 … … 313 312 # Attribute Certificate cached in test 6 can be used to get a mapped 314 313 # AC for this test ... 315 self. sm = self.test7GetAttCertWithSessID()316 317 aaURI = self.cfg.get('test 9GetMappedAttCertWithSessID', 'aaURI')314 self.test07GetAttCertWithSessID() 315 316 aaURI = self.cfg.get('test09GetMappedAttCertWithSessID', 'aaURI') 318 317 319 318 attCert, errMsg, extAttCertList=self.sm.getAttCert(sessID=self.sessID, … … 364 363 365 364 print("Attribute Certificate:\n%s" % attCert) 365 366 367 def test12GetAttCertFromLocalAAInstance(self): 368 """test12GetAttCertFromLocalAAInstance: make an attribute request to a 369 locally instantiated Attribute Authority""" 370 371 self._connect() 372 373 section = 'test12GetAttCertFromLocalAAInstance' 374 aaPropFilePath = self.cfg.get(section, 'aaPropFilePath') 375 attributeAuthority=AttributeAuthority(propFilePath=aaPropFilePath, 376 propPrefix='attributeAuthority') 377 378 attCert, errMsg, extAttCertList=self.sm.getAttCert(sessID=self.sessID, 379 attributeAuthority=attributeAuthority) 380 if errMsg: 381 self.fail(errMsg) 382 383 print("Attribute Certificate:\n%s" % attCert) 384 attCert.filePath = xpdVars(self.cfg.get(section, 'acOutputFilePath')) 385 attCert.write() 366 386 367 387 … … 372 392 smTestCaseMap = map(SessionManagerTestCase, 373 393 ( 374 "test 1Connect2AuthNServiceWithNoUserCertReturned",375 "test 2Connect2AuthNServiceReturningAUserCert",376 "test 3GetSessionStatus",377 "test 4ConnectNoCreateServerSess",378 "test 5DisconnectWithSessID",379 "test 6DisconnectWithUserCert",380 "test 7GetAttCertWithSessID",381 "test 8GetAttCertRefusedWithSessID",382 "test 9GetMappedAttCertWithSessID",394 "test01Connect2AuthNServiceWithNoUserCertReturned", 395 "test02Connect2AuthNServiceReturningAUserCert", 396 "test03GetSessionStatus", 397 "test04ConnectNoCreateServerSess", 398 "test05DisconnectWithSessID", 399 "test06DisconnectWithUserCert", 400 "test07GetAttCertWithSessID", 401 "test08GetAttCertRefusedWithSessID", 402 "test09GetMappedAttCertWithSessID", 383 403 "test10GetAttCertWithExtAttCertListWithSessID", 384 404 "test11GetAttCertWithUserCert", 405 "test12GetAttCertFromLocalAAInstance", 385 406 )) 386 407 unittest.TestSuite.__init__(self, smTestCaseMap)
Note: See TracChangeset
for help on using the changeset viewer.