Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
snapshot session login (tests still break)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Mar 8, 2009
1 parent df02faf commit 79c4734
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/z3c/layer/pagelet/browser/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import zope.i18nmessageid
import zope.interface
import zope.publisher.interfaces.browser
import zope.traversing.browser.interfaces
import zope.viewlet.interfaces
import zope.viewlet.manager
import zope.viewlet.viewlet
Expand Down Expand Up @@ -57,13 +58,13 @@ def get_view_url(context, request, view_name):
"Compute the url of a view."
if view_name.startswith('@@'):
view_name = view_name[2:]
view_truncated = True
view_name_truncated = True
else:
view_truncated = False
view_name_truncated = False
view = zope.component.getMultiAdapter((context, request), name=view_name)
view_url = zope.component.getMultiAdapter(
(view, request), name='absolute_url')()
if view_truncated:
if view_name_truncated:
view_url = view_url.replace(view_name, '@@'+view_name)
return view_url

Expand Down
30 changes: 27 additions & 3 deletions src/z3c/layer/pagelet/login.txt
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,35 @@ Entering wrong password does not authorize either:
</html>


After entering correct username and passord the user gets authorized:
After entering a correct username and password the user gets
authorized:

>>> browser.getControl('User Name').value = 'tester'
>>> browser.getControl('Password').value = 'tpass'
>>> browser.handleErrors = False
>>> browser.getControl('Log in').click()

The user gets redirected to the page where he selected the login
link. After logging in the login link is no longer displayed. As we
already specified that logout is supported, a logout link is
displayed:

>>> browser.url
'http://localhost/++skin++PageletTestSkin/container/@@default.html'
>>> print browser.contents
<!DOCTYPE ...>
<html ...>
<head>
<title>PageletTest</title>
</head>
<body>
<a href="http://localhost/++skin++PageletTestSkin/container/@@logout.html?nextURL=http%3A//localhost/%2B%2Bskin%2B%2BPageletTestSkin/container/%40%40default.html">Logout</a>
</body>
</html>


.. >>> browser.getControl('Log in').click()
Calling the login URL again leads directly to the page referred in
nextURL:

>>> browser.open(login_url)
>>> browser.url
'http://localhost/++skin++PageletTestSkin/container/@@default.html'
1 change: 0 additions & 1 deletion src/z3c/layer/pagelet/tests/ftesting.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<!-- exclude will prevent from include -->
<exclude package="zope.app.authentication" file="ftpplugins.zcml" />
<exclude package="zope.app.authentication" file="groupfolder.zcml" />
<exclude package="zope.app.authentication" file="principalfolder.zcml" />
<exclude package="zope.app.authentication.browser" />
<exclude package="zope.app.authentication.browser" file="configure.zcml" />
<exclude package="zope.app.authentication.browser" file="groupfolder.zcml" />
Expand Down

0 comments on commit 79c4734

Please sign in to comment.