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
fdc4f9c5
Commit
fdc4f9c5
authored
Dec 13, 2010
by
Ed Crewe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed test to use different openers for the proxied app logins
parent
37fa9dbe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
django_cas/tests/cas_tests.py
+19
-14
No files found.
django_cas/tests/cas_tests.py
View file @
fdc4f9c5
...
...
@@ -74,7 +74,7 @@ class TestCAS(unittest.TestCase):
print
'Test ordinary CAS login'
print
'-----------------------'
self
.
ticket
=
self
.
login
()
self
.
get_restricted
()
self
.
get_restricted
(
opener
=
self
.
opener
)
self
.
logout
()
print
''
...
...
@@ -99,7 +99,9 @@ class TestCAS(unittest.TestCase):
else
:
print
pt
# self.logout()
# NB: Dont logout proxy app, but test proxy auth with new openers
# for the tests to be valid...
print
''
print
'Test SSO server login with proxy ticket'
print
'---------------------------------------'
...
...
@@ -109,11 +111,11 @@ class TestCAS(unittest.TestCase):
else
:
print
'FAIL: The proxy login to
%
s via
%
s has failed'
%
(
self
.
urls
[
'app'
],
self
.
urls
[
'proxy'
])
self
.
logout
()
print
''
print
'Test direct proxy login'
print
'-----------------------'
self
.
proxy5_login
(
pt
)
new_pt
=
self
.
proxy3_pt
(
pgt
)
self
.
proxy5_login
(
new_pt
)
return
...
...
@@ -216,7 +218,7 @@ class TestCAS(unittest.TestCase):
print
'Logged out'
return
def
get_restricted
(
self
,
ticket
=
''
,
print_page
=
False
):
def
get_restricted
(
self
,
ticket
=
''
,
opener
=
None
,
print_page
=
False
):
""" Access a restricted URL and see if its accessible
Use token to check if this page has redirected to SSO login
ie. success for get_token is a fail for get restricted
...
...
@@ -224,10 +226,8 @@ class TestCAS(unittest.TestCase):
url
=
'
%
s
%
s'
%
(
self
.
urls
[
'app'
],
APP_RESTRICTED
)
if
ticket
:
url
=
'
%
s?ticket=
%
s'
%
(
url
,
ticket
)
print
url
return
try
:
app_resp
=
self
.
opener
.
open
(
url
)
app_resp
=
opener
.
open
(
url
)
ok
=
app_resp
.
code
==
200
except
:
print
'FAIL: couldnt log in to restricted app at
%
s'
%
url
...
...
@@ -305,25 +305,30 @@ class TestCAS(unittest.TestCase):
def
proxy4_login
(
self
,
pt
):
""" Check proxy ticket for service """
""" Check proxy ticket for service
Use a new opener so its not got any cookies / auth already
"""
opener
=
urllib2
.
build_opener
(
urllib2
.
HTTPCookieProcessor
(
cookielib
.
CookieJar
()))
url_args
=
(
self
.
urls
[
'cas'
],
self
.
urls
[
'app'
],
pt
)
url
=
'
%
sproxyValidate?service=
%
s&ticket=
%
s'
%
url_args
try
:
login
=
self
.
opener
.
open
(
url
)
login
=
opener
.
open
(
url
)
except
:
return
'FAIL: PTURL=
%
s not found'
%
url
page
=
login
.
read
()
print
page
if
page
.
find
(
'cas:authenticationSuccess'
)
>
-
1
:
proxy
=
self
.
find_in_dom
(
page
,[
'cas:proxies'
,
'cas:proxy'
])
return
proxy
else
:
print
page
return
None
def
proxy5_login
(
self
,
pt
):
""" Use proxy ticket to login directly to app """
return
self
.
get_restricted
(
pt
)
""" Use proxy ticket to login directly to app
Use a new opener so its not got any cookies / auth already
"""
opener
=
urllib2
.
build_opener
(
urllib2
.
HTTPCookieProcessor
(
cookielib
.
CookieJar
()))
return
self
.
get_restricted
(
ticket
=
pt
,
opener
=
opener
)
if
__name__
==
'__main__'
:
unittest
.
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