update devDependencies, clean up lint issues
[squeep-authentication-module] / test / lib / template / login-html.js
1 'use strict';
2
3 const assert = require('node:assert');
4 const { LoginHTML } = require('../../../lib/template');
5 const lintHtml = require('../../lint-html');
6
7 describe('Template LoginHTML', function () {
8 let ctx, options;
9 beforeEach(function () {
10 ctx = {
11 clientProtocol: 'https',
12 };
13 options = {
14 authenticator: {
15 authnEnabled: ['indieAuth'],
16 secureAuthOnly: true,
17 },
18 manager: {
19 pageTitle: 'page',
20 },
21 dingus: {
22 selfBaseUrl: 'https://example.com/',
23 },
24 };
25 });
26
27 it('covers', async function () {
28 const result = LoginHTML(ctx, options);
29 await lintHtml(result);
30 assert(result);
31 });
32
33 it('covers local user', async function () {
34 options.authenticator.authnEnabled = ['argon2'];
35 const result = LoginHTML(ctx, options);
36 await lintHtml(result);
37 assert(result);
38 });
39
40 it('renders errors and additional content', async function () {
41 ctx.errors = ['an error', 'another error'];
42 options.manager.logoUrl = 'https://example.com/logo.png';
43 options.authenticator.loginBlurb = ['<p>This is a login page.</p>'];
44 options.authenticator.indieAuthBlurb = ['<p>Describe what IndieAuth allows one to do.</p>'];
45 options.authenticator.userBlurb = ['<p>Describe user login.</p>'];
46 const result = LoginHTML(ctx, options);
47 await lintHtml(result);
48 assert(result);
49 });
50
51 it('covers no indieAuth', async function () {
52 options.authenticator.authnEnabled = [];
53 const result = LoginHTML(ctx, options);
54 await lintHtml(result);
55 assert(result);
56 });
57
58 it('covers insecure not allowed', async function () {
59 ctx.clientProtocol = undefined;
60 const result = LoginHTML(ctx, options);
61 await lintHtml(result);
62 assert(result);
63 });
64
65 it('covers insecure allowed', async function () {
66 ctx.clientProtocol = 'http';
67 options.authenticator.secureAuthOnly = false;
68 const result = LoginHTML(ctx, options);
69 await lintHtml(result);
70 assert(result);
71 });
72
73 });