~ubuntuone-pqm-team/canonical-identity-provider/trunk

« back to all changes in this revision

Viewing changes to doctests/stories/openid/per-version/switch-user-twice.txt

  • Committer: Danny Tamez
  • Date: 2010-04-21 15:29:24 UTC
  • Revision ID: danny.tamez@canonical.com-20100421152924-lq1m92tstk2iz75a
Canonical SSO Provider (Open Source) - Initial Commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Copyright 2010 Canonical Ltd.  This software is licensed under the
 
2
GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
= Switching Users Twice =
 
5
 
 
6
If a user is already logged in when authenticating via OpenID, they
 
7
have the option to sign in as someone else.  This logs them out and
 
8
takes them to the login form.
 
9
 
 
10
By using the back button in their browser, it is possible for the user
 
11
to perform this action twice.  The result should be the same: the user
 
12
is taken to the login form.
 
13
 
 
14
To test this, we will first sign the user in.  First we'll set up the
 
15
OpenID consumer:
 
16
 
 
17
    >>> from openid.consumer.consumer import Consumer
 
18
    >>> from openid.fetchers import setDefaultFetcher
 
19
    >>> from openid.store.memstore import MemoryStore
 
20
    >>> from canonical.signon.testing.openidhelpers import (
 
21
    ...     make_identifier_select_endpoint, PublisherFetcher)
 
22
    >>> setDefaultFetcher(PublisherFetcher())
 
23
 
 
24
    >>> openid_store = MemoryStore()
 
25
    >>> consumer = Consumer(session={}, store=openid_store)
 
26
 
 
27
Then log in as Sample Person:
 
28
 
 
29
    >>> request = consumer.beginWithoutDiscovery(
 
30
    ...     make_identifier_select_endpoint(PROTOCOL_URI))
 
31
    >>> browser.open(request.redirectURL(
 
32
    ...     'http://launchpad.dev/', 'http://launchpad.dev/+openid-consumer'))
 
33
 
 
34
    >>> print browser.title
 
35
    Log in
 
36
    >>> browser.getControl(name='email').value = 'test@canonical.com'
 
37
    >>> browser.getControl(name='password').value = 'test'
 
38
    >>> browser.getControl(name='continue').click()
 
39
    >>> browser.getControl(name='yes').click()
 
40
    >>> print browser.url
 
41
    http://launchpad.dev/+openid-consumer?...
 
42
 
 
43
Now lets start a second authentication request, which should take us
 
44
to the authentication page asking if we want to sign in as someone
 
45
else:
 
46
 
 
47
    >>> request = consumer.beginWithoutDiscovery(
 
48
    ...     make_identifier_select_endpoint(PROTOCOL_URI))
 
49
    >>> browser.open(request.redirectURL(
 
50
    ...     'http://launchpad.dev/', 'http://launchpad.dev/+openid-consumer'))
 
51
    >>> print browser.title
 
52
    Authenticate to http://launchpad.dev/
 
53
 
 
54
Now log out, by saying that we are someone else:
 
55
 
 
56
    >>> browser.getLink(id='logout-link').click()
 
57
    >>> print browser.title
 
58
    Log in
 
59
 
 
60
Going back and repeating the action should succeed without error:
 
61
 
 
62
    >>> browser.goBack()
 
63
    >>> print browser.title
 
64
    Log in
 
65
 
 
66
 
 
67
== Cleanup ==
 
68
 
 
69
    >>> setDefaultFetcher(None)