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