3 const assert
= require('assert');
4 const template
= require('../../../src/template/authorization-request-html');
5 const Config
= require('../../../config');
6 const StubLogger
= require('../../stub-logger');
7 const { makeHtmlLint
} = require('@squeep/html-template-helper');
8 const { HtmlValidate
} = require('html-validate');
10 const stubLogger
= new StubLogger();
11 const htmlValidate
= new HtmlValidate({
13 'html-validate:recommended',
16 'valid-id': ['error', { relaxed: true }], // allow profile uri to be component of id
19 const lintHtml
= makeHtmlLint(stubLogger
, htmlValidate
);
21 describe('Authorization Request HTML Template', function () {
23 beforeEach(function () {
25 config
= new Config('test');
27 it('renders', async
function () {
28 const result
= template(ctx
, config
);
29 await
lintHtml(result
);
32 it('covers options', async
function () {
34 scope: ['profile', 'email'],
37 description: 'Profile',
43 description: 'Create',
44 profiles: ['https://exmaple.com/profile'],
47 me: new URL('https://example.com/profile'),
48 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
52 url: 'https://client.example.com/app/',
53 summary: 'This is an app',
54 logo: 'https://client.example.com/app/logo.png',
55 name: 'Some Fancy Application',
59 clientId: 'https://client.example.com/app/',
60 persist: 'encodedData',
61 redirectUri: 'https://client.example.com/app/_return',
63 const result
= template(ctx
, config
);
64 await
lintHtml(result
);
67 it('covers alternate scopes and client logo', async
function () {
69 scope: ['profile', 'email'],
72 description: 'Profile',
78 description: 'Create',
79 profiles: ['https://example.com/profile'],
82 description: 'Another Scope',
83 profiles: ['https://example.com/profile'],
86 me: new URL('https://example.com/profile'),
87 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
91 url: 'https://client.example.com/app/',
92 summary: 'This is an app',
94 value: 'https://client.example.com/app/logo.png',
97 name: 'Some Fancy Application',
101 clientId: 'https://client.example.com/app/',
102 persist: 'encodedData',
103 redirectUri: 'https://client.example.com/app/_return',
105 const result
= template(ctx
, config
);
106 await
lintHtml(result
);
109 it('covers partial data', async
function () {
111 scope: ['profile', 'email', 'create'],
112 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
116 url: 'https://client.example.com/app/',
117 summary: 'This is an app',
118 logo: 'https://client.example.com/app/logo.png',
119 name: 'Some Fancy Application',
123 clientId: 'https://client.example.com/app/',
124 persist: 'encodedData',
125 redirectUri: 'https://client.example.com/app/_return',
127 const result
= template(ctx
, config
);
128 await
lintHtml(result
);
131 it('covers partial data', async
function () {
133 scope: ['profile', 'email', 'create'],
139 clientId: 'https://client.example.com/app/',
140 persist: 'encodedData',
141 redirectUri: 'https://client.example.com/app/_return',
143 const result
= template(ctx
, config
);
144 await
lintHtml(result
);
147 }); // Authorization Request HTML Template