~roadmr/canonical-identity-provider/webauthn-register-endpoint-part-2-the-registration

« back to all changes in this revision

Viewing changes to src/webui/tests/test_templates.py

Merged webauthn-register-endpoint into webauthn-register-endpoint-part-2-the-registration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
from pyquery import PyQuery
7
7
 
8
8
from identityprovider.models.openidmodels import OpenIDRPConfig
9
 
from identityprovider.readonly import ReadOnlyManager
10
9
from identityprovider.tests.utils import (
11
10
    AuthenticatedTestCase,
12
11
    SSOBaseTestCase,
 
12
    readonly_enabled,
13
13
)
14
14
 
15
15
 
44
44
 
45
45
    def render_login_with_rpconfig(self, rpconfig):
46
46
        return render_to_string(
47
 
            'registration/login.html', dict(rpconfig=rpconfig))
 
47
            'registration/login.html', {'rpconfig': rpconfig})
48
48
 
49
49
    def get_title_style_and_text(self, dom):
50
 
        titles = dom.find('p[class~=login-title]')
 
50
        titles = dom.find('[class~=login-title]')
51
51
        self.assertEqual(1, titles.length)
52
52
        text = " ".join(titles[0].text_content().split())
53
 
        style = dom.find('style[data-qa-id="test_login_rp"]')
 
53
        style = dom.find('[data-qa-id="test_login_rp"]')
54
54
        if len(style) == 1:
55
55
            style = " ".join(style.text().split())
56
56
        else:
99
99
        self.assertContains(response, "data-qa-id=\"create_account_form\"")
100
100
 
101
101
    def test_login_without_create_account_form(self):
102
 
        rm = ReadOnlyManager()
103
 
        rm.set_readonly()
104
 
        self.addCleanup(rm.clear_readonly)
105
 
 
106
 
        response = self.client.get('/+login')
 
102
        with readonly_enabled():
 
103
            response = self.client.get('/+login')
107
104
        self.assertNotContains(response, "data-qa-id=\"create_account_form\"")
108
105
 
109
106
 
155
152
        with self.settings(GOOGLE_TAG_MANAGER_ID='foobar'):
156
153
            response = self.client.get('/')
157
154
 
158
 
        self.assertTemplateUsed(response, 'base.html')
 
155
        self.assertTemplateUsed(response, 'vanilla/base.html')
159
156
        self.assertContains(response, 'gtm.start')
160
157
 
161
158
    def test_base_template_not_includes_analytics(self):
164
161
        with self.settings(GOOGLE_TAG_MANAGER_ID=None):
165
162
            response = self.client.get('/')
166
163
 
167
 
        self.assertTemplateUsed(response, 'base.html')
 
164
        self.assertTemplateUsed(response, 'vanilla/base.html')
168
165
        self.assertNotContains(response, 'gtm.start')
169
166
 
170
167
    def test_login_header_without_token(self):
171
 
        html = render_to_string('base.html', {})
 
168
        html = render_to_string('vanilla/base.html', {})
172
169
        dom = PyQuery(html)
173
170
        link = dom.find('a#login-link')
174
171
        self.assertEqual(link.attr['href'], reverse('login'))
175
172
 
176
173
    def test_login_header_with_token(self):
177
174
        ctx = {'token': 'a' * 16}
178
 
        html = render_to_string('base.html', ctx.copy())
 
175
        html = render_to_string('vanilla/base.html', ctx.copy())
179
176
        dom = PyQuery(html)
180
177
        link = dom.find('a#login-link')
181
178
        self.assertEqual(link.attr['href'], reverse('login', kwargs=ctx))