fix typo in ticket template causing extraneous navLink to be displayed
[squeep-indie-auther] / test / src / template / authorization-request-html.js
1 /* eslint-env mocha */
2 'use strict';
3
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');
10
11 const stubLogger = new StubLogger();
12 const htmlValidate = new HtmlValidate({
13 extends: [
14 'html-validate:recommended',
15 ],
16 rules: {
17 'valid-id': ['error', { relaxed: true }], // allow profile uri to be component of id
18 },
19 });
20 const lintHtml = makeHtmlLint(stubLogger, htmlValidate);
21
22 describe('Authorization Request HTML Template', function () {
23 let ctx, config;
24 beforeEach(function () {
25 ctx = {};
26 config = new Config('test');
27 });
28 it('renders', async function () {
29 const result = template(ctx, config);
30 await lintHtml(result);
31 assert(result);
32 });
33 it('covers options', async function () {
34 ctx.session = {
35 scope: ['profile', 'email'],
36 scopeIndex: {
37 'profile': {
38 description: 'Profile',
39 },
40 'email': {
41 description: 'Email',
42 },
43 'create': {
44 description: 'Create',
45 profiles: ['https://exmaple.com/profile'],
46 },
47 },
48 me: new URL('https://example.com/profile'),
49 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
50 clientIdentifier: {
51 items: [{
52 properties: {
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',
57 },
58 }],
59 },
60 clientId: 'https://client.example.com/app/',
61 persist: 'encodedData',
62 redirectUri: 'https://client.example.com/app/_return',
63 };
64 const result = template(ctx, config);
65 await lintHtml(result);
66 assert(result);
67 });
68 it('covers alternate scopes and client logo', async function () {
69 ctx.session = {
70 scope: ['profile', 'email'],
71 scopeIndex: {
72 'profile': {
73 description: 'Profile',
74 },
75 'email': {
76 description: 'Email',
77 },
78 'create': {
79 description: 'Create',
80 profiles: ['https://example.com/profile'],
81 },
82 'other': {
83 description: 'Another Scope',
84 profiles: ['https://example.com/profile'],
85 },
86 },
87 me: new URL('https://example.com/profile'),
88 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
89 clientIdentifier: {
90 items: [{
91 properties: {
92 url: 'https://client.example.com/app/',
93 summary: 'This is an app',
94 logo: [{
95 value: 'https://client.example.com/app/logo.png',
96 alt: 'alt',
97 }],
98 name: 'Some Fancy Application',
99 },
100 }],
101 },
102 clientId: 'https://client.example.com/app/',
103 persist: 'encodedData',
104 redirectUri: 'https://client.example.com/app/_return',
105 };
106 const result = template(ctx, config);
107 await lintHtml(result);
108 assert(result);
109 });
110 it('covers partial data', async function () {
111 ctx.session = {
112 scope: ['profile', 'email', 'create'],
113 profiles: ['https://another.example.com/profile', 'https://example.com/profile'],
114 clientIdentifier: {
115 items: [{
116 properties: {
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',
121 },
122 }],
123 },
124 clientId: 'https://client.example.com/app/',
125 persist: 'encodedData',
126 redirectUri: 'https://client.example.com/app/_return',
127 };
128 const result = template(ctx, config);
129 await lintHtml(result);
130 assert(result);
131 });
132 it('covers partial data', async function () {
133 ctx.session = {
134 scope: ['profile', 'email', 'create'],
135 profiles: [],
136 clientIdentifier: {
137 items: [{
138 }],
139 },
140 clientId: 'https://client.example.com/app/',
141 persist: 'encodedData',
142 redirectUri: 'https://client.example.com/app/_return',
143 };
144 const result = template(ctx, config);
145 await lintHtml(result);
146 assert(result);
147 });
148 }); // Authorization Request HTML Template