Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-cas
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-cas
Commits
37632248
Commit
37632248
authored
Nov 30, 2010
by
Ed Crewe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check up to date
parent
7fa47f44
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
11 deletions
+30
-11
django_cas/tests/cas_tests.py
+30
-11
No files found.
django_cas/tests/cas_tests.py
View file @
37632248
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
# This does script does it for you against the deployed servers
# This does script does it for you against the deployed servers
# Run via python 2.4 or above ...
# Run via python 2.4 or above ...
# python
proxy_test.py username password
# python
cas_tests.py [username]
# You will need to edit the constants below to match your setup ...
# You will need to edit the constants below to match your setup ...
import
unittest
import
unittest
...
@@ -57,12 +57,17 @@ class TestCAS(unittest.TestCase):
...
@@ -57,12 +57,17 @@ class TestCAS(unittest.TestCase):
self
.
get_restricted
()
self
.
get_restricted
()
print
'Test proxy CAS login'
print
'Test proxy CAS login'
print
'--------------------'
print
'--------------------'
iou
=
self
.
get_proxy
()
iou
=
self
.
get_proxy
_iou
()
if
iou
:
if
iou
:
print
'Got IOU:
%
s'
%
iou
print
'Got IOU:
%
s'
%
iou
else
:
else
:
print
'Proxy CAS login failed, no IOU'
print
'Proxy CAS login failed, no IOU'
pgt
=
self
.
get_proxy
(
iou
)
if
pgt
:
print
'Got PGT:
%
s'
%
pgt
else
:
print
'Proxy CAS login failed, no PGT'
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 """
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
...
@@ -141,18 +146,32 @@ class TestCAS(unittest.TestCase):
...
@@ -141,18 +146,32 @@ class TestCAS(unittest.TestCase):
print
'FAILED to log in to restricted app at
%
s'
%
url
print
'FAILED to log in to restricted app at
%
s'
%
url
return
return
def
get_proxy
(
self
):
def
get_proxy
_iou
(
self
):
""" Use login ticket to get proxy """
""" Use login ticket to get proxy
iou
"""
url_args
=
(
CAS_
SERVER_
URL
,
self
.
ticket
,
APP_URL
,
PROXY_URL
)
url_args
=
(
CAS_URL
,
self
.
ticket
,
APP_URL
,
PROXY_URL
)
iou_
url
=
'
%
s/serviceValidate?ticket=
%
s&service=
%
s&pgtUrl=
%
s'
%
url_args
url
=
'
%
s/serviceValidate?ticket=
%
s&service=
%
s&pgtUrl=
%
s'
%
url_args
iou
=
self
.
opener
.
open
(
iou_
url
)
iou
=
self
.
opener
.
open
(
url
)
page
=
iou
.
read
()
page
=
iou
.
read
()
if
page
.
find
(
'cas:authenticationSuccess'
)
>
-
1
:
if
page
.
find
(
'cas:authenticationSuccess'
)
>
-
1
:
iou_ticket
=
self
.
find_in_dom
(
page
,[
'cas:serviceResponse'
,
iou_ticket
=
self
.
find_in_dom
(
page
,[
'cas:serviceResponse'
,
'cas:authenticationSuccess'
,
'cas:authenticationSuccess'
,
'cas:proxyGrantingTicket'
])
'cas:proxyGrantingTicket'
])
return
iou_ticket
return
iou_ticket
print
page
return
None
def
get_proxy
(
self
,
iou
):
""" Use login ticket to get proxy """
url_args
=
(
PROXY_URL
,
iou
)
url
=
'
%
s/pgtCallback?pgtIou=
%
s'
%
url_args
return
url
pgt
=
self
.
opener
.
open
(
url
)
page
=
pgt
.
read
()
return
page
if
page
.
find
(
'cas:authenticationSuccess'
)
>
-
1
:
pgt_ticket
=
self
.
find_in_dom
(
page
,[
'cas:serviceResponse'
,
'cas:authenticationSuccess'
,
'cas:proxyGrantingTicket'
])
return
pgt_ticket
return
None
return
None
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment