4 const assert
= require('assert');
5 const template
= require('../../../src/template/authorization-request-html');
6 const Config
= require('../../../config');
7 const StubLogger
= require('../../stub-logger');
8 const { makeHtmlLint
} = require('@squeep/html-template-helper');
9 const { HtmlValidate
} = require('html-validate');
11 const stubLogger
= new StubLogger();
12 const htmlValidate
= new HtmlValidate({
14 'html-validate:recommended',
17 'valid-id': ['error', { relaxed: true }], // allow profile uri to be component of id
20 const lintHtml
= makeHtmlLint(stubLogger
, htmlValidate
);
22 describe('Authorization Request HTML Template', function () {
24 beforeEach(function () {
26 config
= new Config('test');
28 it('renders', async
function () {
29 const result
= template(ctx
, config
);
30 await
lintHtml(result
);
33 it('covers options', async
function () {
35 scope: ['profile', 'email'],
38 description: 'Profile',
44 description: 'Create',
45 profiles: ['https://exmaple.com/profile'],
48 me: new URL('https://example.com/profile'),
49 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
53 url: 'https://client.example.com/app/',
54 summary: 'This is an app',
55 logo: 'https://client.example.com/app/logo.png',
56 name: 'Some Fancy Application',
60 clientId: 'https://client.example.com/app/',
61 persist: 'encodedData',
62 redirectUri: 'https://client.example.com/app/_return',
64 const result
= template(ctx
, config
);
65 await
lintHtml(result
);
68 it('covers alternate scopes and client logo', async
function () {
70 scope: ['profile', 'email'],
73 description: 'Profile',
79 description: 'Create',
80 profiles: ['https://example.com/profile'],
83 description: 'Another Scope',
84 profiles: ['https://example.com/profile'],
87 me: new URL('https://example.com/profile'),
88 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
92 url: 'https://client.example.com/app/',
93 summary: 'This is an app',
95 value: 'https://client.example.com/app/logo.png',
98 name: 'Some Fancy Application',
102 clientId: 'https://client.example.com/app/',
103 persist: 'encodedData',
104 redirectUri: 'https://client.example.com/app/_return',
106 const result
= template(ctx
, config
);
107 await
lintHtml(result
);
110 it('covers partial data', async
function () {
112 scope: ['profile', 'email', 'create'],
113 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
117 url: 'https://client.example.com/app/',
118 summary: 'This is an app',
119 logo: 'https://client.example.com/app/logo.png',
120 name: 'Some Fancy Application',
124 clientId: 'https://client.example.com/app/',
125 persist: 'encodedData',
126 redirectUri: 'https://client.example.com/app/_return',
128 const result
= template(ctx
, config
);
129 await
lintHtml(result
);
132 it('covers partial data', async
function () {
134 scope: ['profile', 'email', 'create'],
140 clientId: 'https://client.example.com/app/',
141 persist: 'encodedData',
142 redirectUri: 'https://client.example.com/app/_return',
144 const result
= template(ctx
, config
);
145 await
lintHtml(result
);
148 }); // Authorization Request HTML Template