1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test harness for person views unit tests."""
__metaclass__ = type
from textwrap import dedent
from canonical.config import config
from canonical.launchpad.ftests import login_person
from canonical.launchpad.webapp.servers import LaunchpadTestRequest
from canonical.testing.layers import DatabaseFunctionalLayer
from lp.registry.browser.person import PersonView
from lp.testing import TestCaseWithFactory
class PersonView_openid_identity_url_TestCase(TestCaseWithFactory):
"""Tests for the public OpenID identifier shown on the profile page."""
layer = DatabaseFunctionalLayer
def setUp(self):
TestCaseWithFactory.setUp(self)
self.user = self.factory.makePerson(name='eris')
self.request = LaunchpadTestRequest(
SERVER_URL="http://launchpad.dev/")
login_person(self.user, self.request)
self.view = PersonView(self.user, self.request)
# Marker allowing us to reset the config.
config.push(self.id(), '')
self.addCleanup(config.pop, self.id())
def test_should_be_profile_page_when_delegating(self):
"""The profile page is the OpenID identifier in normal situation."""
self.assertEquals(
'http://launchpad.dev/~eris', self.view.openid_identity_url)
def test_should_be_production_profile_page_when_not_delegating(self):
"""When the profile page is not delegated, the OpenID identity URL
should be the one on the main production site."""
config.push('non-delegating', dedent('''
[vhost.mainsite]
openid_delegate_profile: False
[launchpad]
non_restricted_hostname: prod.launchpad.dev
'''))
self.assertEquals(
'http://prod.launchpad.dev/~eris', self.view.openid_identity_url)
|