From 91e3dfb3ed0352ee57697c98c3c2b019d4fddc03 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Tue, 27 Aug 2024 12:45:52 -0500 Subject: [PATCH] fix: fixed navbar icon when logged in, attempt to fix env var for GitHub CI, cleanup apiURL and webURL in tests --- app/views/_nav.pug | 5 +++-- config/index.js | 4 +++- test/api/v1.js | 8 ++++---- test/mx/index.js | 8 +++++--- test/utils.js | 4 ++++ test/web/sitemap.js | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/views/_nav.pug b/app/views/_nav.pug index b18eb797a7..9c357db346 100644 --- a/app/views/_nav.pug +++ b/app/views/_nav.pug @@ -222,13 +222,14 @@ nav.navbar(class=navbarClasses.join(" ")) = t("Signup") .no-js.is-bot.d-inline-block.mr-3 if !isBot(ctx.get('User-Agent')) - button.navbar-toggler.d-lg-none.no-js.text-dark.text-themed( + button.navbar-toggler.d-lg-none.no-js( type="button", data-toggle="collapse", data-target="#navbar-header", aria-controls="navbar-header", aria-expanded="false", - aria-label=t("Toggle navigation") + aria-label=t("Toggle navigation"), + class=isAuthenticated() ? "text-white" : "text-dark text-themed" ) i.fas.fa-bars //- once we have responsive border utilities added to bootstrap diff --git a/config/index.js b/config/index.js index 7a164e6048..07f18135b1 100644 --- a/config/index.js +++ b/config/index.js @@ -18,6 +18,7 @@ const manifestRev = require('manifest-rev'); const ms = require('ms'); const nodemailer = require('nodemailer'); const tlds = require('tlds'); +const splitLines = require('split-lines'); const { Iconv } = require('iconv'); const { boolean } = require('boolean'); @@ -226,7 +227,8 @@ const config = { privateKey: isSANB(env.DKIM_PRIVATE_KEY_PATH) ? fs.readFileSync(env.DKIM_PRIVATE_KEY_PATH, 'utf8') : isSANB(env.DKIM_PRIVATE_KEY_VALUE) - ? env.DKIM_PRIVATE_KEY_VALUE + ? // GitHub CI may convert \n to \\n in env var rendering + splitLines(env.DKIM_PRIVATE_KEY_VALUE.replace(/\\n/g, '\n')).join('\n') : undefined, algorithm: 'rsa-sha256', canonicalization: 'relaxed/relaxed' diff --git a/test/api/v1.js b/test/api/v1.js index cdf877324e..e250ca01e8 100644 --- a/test/api/v1.js +++ b/test/api/v1.js @@ -329,7 +329,7 @@ test('creates alias with global catch-all', async (t) => { t.is(res.headers['x-item-count'], '1'); t.is( res.headers.link, - `<${t.context.apiURL}v1/domains/${domain.name}/aliases?page=1)>; rel="last", <${t.context.apiURL}v1/domains/${domain.name}/aliases?page=1)>; rel="first"` + `<${t.context.apiURL}/v1/domains/${domain.name}/aliases?page=1)>; rel="last", <${t.context.apiURL}/v1/domains/${domain.name}/aliases?page=1)>; rel="first"` ); } }); @@ -1261,7 +1261,7 @@ test('create domain without catchall', async (t) => { t.is(res.headers['x-item-count'], '0'); t.is( res.headers.link, - `<${t.context.apiURL}v1/domains/testdomain1.com/aliases?page=1)>; rel="last", <${t.context.apiURL}v1/domains/testdomain1.com/aliases?page=1)>; rel="first"` + `<${t.context.apiURL}/v1/domains/testdomain1.com/aliases?page=1)>; rel="last", <${t.context.apiURL}/v1/domains/testdomain1.com/aliases?page=1)>; rel="first"` ); } @@ -1328,7 +1328,7 @@ test('create domain without catchall', async (t) => { t.is(res.headers['x-item-count'], '1'); t.is( res.headers.link, - `<${t.context.apiURL}v1/domains?page=1)>; rel="last", <${t.context.apiURL}v1/domains?page=1)>; rel="first"` + `<${t.context.apiURL}/v1/domains?page=1)>; rel="last", <${t.context.apiURL}/v1/domains?page=1)>; rel="first"` ); } @@ -1514,7 +1514,7 @@ test('lists emails', async (t) => { t.is(res.headers['x-item-count'], '1'); t.is( res.headers.link, - `<${t.context.apiURL}v1/emails?page=1)>; rel="last", <${t.context.apiURL}v1/emails?page=1)>; rel="first"` + `<${t.context.apiURL}/v1/emails?page=1)>; rel="last", <${t.context.apiURL}/v1/emails?page=1)>; rel="first"` ); t.is(res.body[0].id, id); diff --git a/test/mx/index.js b/test/mx/index.js index a29faad92a..ee39e42927 100644 --- a/test/mx/index.js +++ b/test/mx/index.js @@ -14,6 +14,7 @@ const mxConnect = require('mx-connect'); const nodemailer = require('nodemailer'); const pify = require('pify'); const test = require('ava'); +const { listen } = require('async-listen'); const utils = require('../utils'); const MX = require('../../mx-server'); @@ -52,14 +53,15 @@ test.beforeEach(async (t) => { Users ); const port = await getPort(); - t.context.apiPort = port; - await api.listen(port); + // remove trailing slash from API URL + t.context.apiURL = await listen(api.server, { host: '127.0.0.1', port }); + t.context.apiURL = t.context.apiURL.toString().slice(0, -1); }); test('connects', async (t) => { const smtp = new MX({ client: t.context.client, - apiEndpoint: `http://localhost:${t.context.apiPort}` + apiEndpoint: t.context.apiURL }); const { resolver } = smtp; const port = await getPort(); diff --git a/test/utils.js b/test/utils.js index fa8b12a428..edbc89cabf 100644 --- a/test/utils.js +++ b/test/utils.js @@ -68,7 +68,9 @@ exports.setupWebServer = async (t) => { t.context._web = web; if (!getPort) await pWaitFor(() => Boolean(getPort), { timeout: ms('15s') }); const port = await getPort(); + // remove trailing slash from web URL t.context.webURL = await listen(web.server, { host: '127.0.0.1', port }); + t.context.webURL = t.context.webURL.toString().slice(0, -1); t.context.web = request.agent(web.server); }; @@ -85,7 +87,9 @@ exports.setupApiServer = async (t) => { ); if (!getPort) await pWaitFor(() => Boolean(getPort), { timeout: ms('15s') }); const port = await getPort(); + // remove trailing slash from API URL t.context.apiURL = await listen(api.server, { host: '127.0.0.1', port }); + t.context.apiURL = t.context.apiURL.toString().slice(0, -1); t.context.api = request.agent(api.server); }; diff --git a/test/web/sitemap.js b/test/web/sitemap.js index 04bea2c7e3..dd0f72cca5 100644 --- a/test/web/sitemap.js +++ b/test/web/sitemap.js @@ -72,7 +72,7 @@ for (const key of keys) { const status = key === '/tti' ? 408 : 200; test(`GET /${route} should return 200`, async (t) => { t.timeout(ms('5m')); // FAQ takes 30s+ to render (the pug view is ~4000 LOC right now) - const res = await undici.fetch(`${t.context.webURL}${route}`, { + const res = await undici.fetch(`${t.context.webURL}/${route}`, { method: 'HEAD' }); t.is(res.status, status);