X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Flib%2Ftemplate%2Flogin-html.js;h=40ecc4b1de0499ea782086324c6c0bb9c0dbe329;hb=04c85a23b032c46ac0e5a1d85db34b9a7560c216;hp=4d239119a49ef97e11d6c9f8afb392276ad7d6d4;hpb=dd173e6b450cbba8100883514610c9fde83d050a;p=squeep-authentication-module diff --git a/test/lib/template/login-html.js b/test/lib/template/login-html.js index 4d23911..40ecc4b 100644 --- a/test/lib/template/login-html.js +++ b/test/lib/template/login-html.js @@ -1,16 +1,8 @@ -/* eslint-env mocha */ 'use strict'; -const assert = require('assert'); +const assert = require('node:assert'); const { LoginHTML } = require('../../../lib/template'); -const stubLogger = require('../../stub-logger'); -const lint = require('html-minifier-lint').lint; // eslint-disable-line node/no-unpublished-require - -function lintHtml(html) { - const result = lint(html); - stubLogger.debug('validHtml', '', { result, html }); - assert(!result); -} +const lintHtml = require('../../lint-html'); describe('Template LoginHTML', function () { let ctx, options; @@ -20,7 +12,7 @@ describe('Template LoginHTML', function () { }; options = { authenticator: { - authnEnabled: ['indieAuth', 'DEBUG_ANY'], + authnEnabled: ['indieAuth'], secureAuthOnly: true, }, manager: { @@ -32,42 +24,49 @@ describe('Template LoginHTML', function () { }; }); - it('covers', function () { + it('covers', async function () { + const result = LoginHTML(ctx, options); + await lintHtml(result); + assert(result); + }); + + it('covers local user', async function () { + options.authenticator.authnEnabled = ['argon2']; const result = LoginHTML(ctx, options); - lintHtml(result); + await lintHtml(result); assert(result); }); - it('renders errors and additional content', function () { + it('renders errors and additional content', async function () { ctx.errors = ['an error', 'another error']; options.manager.logoUrl = 'https://example.com/logo.png'; options.authenticator.loginBlurb = ['

This is a login page.

']; options.authenticator.indieAuthBlurb = ['

Describe what IndieAuth allows one to do.

']; options.authenticator.userBlurb = ['

Describe user login.

']; const result = LoginHTML(ctx, options); - lintHtml(result); + await lintHtml(result); assert(result); }); - it('covers no indieAuth', function () { + it('covers no indieAuth', async function () { options.authenticator.authnEnabled = []; const result = LoginHTML(ctx, options); - lintHtml(result); + await lintHtml(result); assert(result); }); - it('covers insecure not allowed', function () { + it('covers insecure not allowed', async function () { ctx.clientProtocol = undefined; const result = LoginHTML(ctx, options); - lintHtml(result); + await lintHtml(result); assert(result); }); - it('covers insecure allowed', function () { + it('covers insecure allowed', async function () { ctx.clientProtocol = 'http'; options.authenticator.secureAuthOnly = false; const result = LoginHTML(ctx, options); - lintHtml(result); + await lintHtml(result); assert(result); });