Changeset 4447 for TI12-security/trunk/python/ndg.security.test/ndg/security/test/sessionmanager/test_sessionmanager.py
- Timestamp:
- 19/11/08 13:10:48 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.