Commit a9ee4d36 by Ed Crewe

add redirect to proxy if PT check

parent fffebc82
...@@ -75,11 +75,12 @@ class TestCAS(unittest.TestCase): ...@@ -75,11 +75,12 @@ class TestCAS(unittest.TestCase):
print '-----------------------' print '-----------------------'
self.ticket = self.login() self.ticket = self.login()
self.get_restricted() self.get_restricted()
self.logout()
print '' print ''
print 'Test proxy CAS login' print 'Test proxy CAS login'
print '--------------------' print '--------------------'
self.ticket = self.login()
iou = self.proxy1_iou() iou = self.proxy1_iou()
if iou.startswith('PGT'): if iou.startswith('PGT'):
print 'PASS: Got IOU - %s for %s' % (iou, self.urls['proxy']) print 'PASS: Got IOU - %s for %s' % (iou, self.urls['proxy'])
...@@ -105,6 +106,9 @@ class TestCAS(unittest.TestCase): ...@@ -105,6 +106,9 @@ class TestCAS(unittest.TestCase):
else: else:
print 'FAIL: The proxy login to %s via %s has failed' % (self.urls['app'], self.urls['proxy']) print 'FAIL: The proxy login to %s via %s has failed' % (self.urls['app'], self.urls['proxy'])
self.logout()
self.proxy5_login(pt)
def get_auth(self): def get_auth(self):
""" Get authentication by passing to this script on the command line """ """ Get authentication by passing to this script on the command line """
...@@ -193,9 +197,19 @@ class TestCAS(unittest.TestCase): ...@@ -193,9 +197,19 @@ class TestCAS(unittest.TestCase):
print 'FAIL: Couldnt login to %s' % url print 'FAIL: Couldnt login to %s' % url
return ticket return ticket
def get_restricted(self): def logout(self):
""" Logout inbetween tests """
url = '%slogout' % self.urls['cas']
app_resp = self.opener.open(url)
app_resp.close()
print 'Logged out'
return
def get_restricted(self, ticket=''):
""" Access a restricted URL and see if its accessible """ """ Access a restricted URL and see if its accessible """
url = self.urls['app'] + APP_RESTRICTED url = '%s%s' % (self.urls['app'], APP_RESTRICTED)
if ticket:
url = '%s&ticket=%s' % (url, ticket)
app_resp = self.opener.open(url) app_resp = self.opener.open(url)
ok = app_resp.code == 200 ok = app_resp.code == 200
app_resp.close() app_resp.close()
...@@ -203,7 +217,6 @@ class TestCAS(unittest.TestCase): ...@@ -203,7 +217,6 @@ class TestCAS(unittest.TestCase):
print 'PASS: logged in to restricted app at %s' % url print 'PASS: logged in to restricted app at %s' % url
else: else:
print 'FAIL: couldnt log in to restricted app at %s' % url print 'FAIL: couldnt log in to restricted app at %s' % url
return
def proxy1_iou(self): def proxy1_iou(self):
""" Use login ticket to get proxy iou """ Use login ticket to get proxy iou
...@@ -273,12 +286,15 @@ class TestCAS(unittest.TestCase): ...@@ -273,12 +286,15 @@ class TestCAS(unittest.TestCase):
except: except:
return 'FAIL: PTURL=%s not found' % url return 'FAIL: PTURL=%s not found' % url
page = login.read() page = login.read()
print url
if page.find('cas:authenticationSuccess') > -1: if page.find('cas:authenticationSuccess') > -1:
proxy = self.find_in_dom(page,['cas:proxies', proxy = self.find_in_dom(page,['cas:proxies',
'cas:proxy']) 'cas:proxy'])
return proxy return proxy
return None return None
def proxy5_login(self, pt):
""" Check if service redirects to proxy login if given a PT-ticket """
return self.get_restricted(pt)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment