From 3e09272502f751c1f4561fa66b77e1c6f36d4a76 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Tue, 16 Aug 2022 16:03:24 -0400 Subject: [PATCH 1/2] Allowing login page to be configured without HTML page --- src/context/directory/handlers/pages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/context/directory/handlers/pages.ts b/src/context/directory/handlers/pages.ts index a37688702..a34698058 100644 --- a/src/context/directory/handlers/pages.ts +++ b/src/context/directory/handlers/pages.ts @@ -35,7 +35,7 @@ function parse(context: DirectoryContext): ParsedPages { log.warn(`Skipping pages file ${html} as missing the corresponding '.json' file`); return []; } - if (!html && key === 'error_page') { + if (!html && ['error_page', 'login'].includes(key)) { //Error pages don't require an HTML template, it is valid to redirect errors to URL return { ...loadJSON(meta, context.mappings), From e2e5d7403b832a56e94fc51488a228d6d269c2d0 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Wed, 17 Aug 2022 08:36:31 -0400 Subject: [PATCH 2/2] Renaming value to prevent linting error --- test/context/directory/pages.test.js | 49 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/test/context/directory/pages.test.js b/test/context/directory/pages.test.js index 136817d85..c827ef286 100644 --- a/test/context/directory/pages.test.js +++ b/test/context/directory/pages.test.js @@ -33,36 +33,45 @@ const pagesTarget = [ ]; describe('#directory context pages', () => { - it('should process pages even without error_page HTML file', async () => { - const repoDir = path.join(testDataDir, 'directory', 'pages4'); - const noErrorPageHtml = (() => { - const newPages = { ...pages }; - delete newPages['error_page.html']; - return newPages; - })(); - createDir(repoDir, { [constants.PAGES_DIRECTORY]: noErrorPageHtml }); + it('should process pages', async () => { + const repoDir = path.join(testDataDir, 'directory', 'pages1'); + createDir(repoDir, { [constants.PAGES_DIRECTORY]: pages }); - const config = { AUTH0_INPUT_FILE: repoDir }; + const config = { AUTH0_INPUT_FILE: repoDir, AUTH0_KEYWORD_REPLACE_MAPPINGS: { env: 'test' } }; const context = new Context(config, mockMgmtClient()); await context.load(); - expect(context.assets.pages.find((page) => page.name === 'error_page')).to.deep.equal({ - html: '', - name: 'error_page', - show_log_link: false, - url: 'https://example.com/error', - }); + expect(context.assets.pages).to.deep.equal(pagesTarget); }); - it('should process pages', async () => { - const repoDir = path.join(testDataDir, 'directory', 'pages1'); - createDir(repoDir, { [constants.PAGES_DIRECTORY]: pages }); + it('should process login and error pages without HTML files', async () => { + const repoDir = path.join(testDataDir, 'directory', 'pages4'); - const config = { AUTH0_INPUT_FILE: repoDir, AUTH0_KEYWORD_REPLACE_MAPPINGS: { env: 'test' } }; + const pagesNoHtml = { + 'login.json': '{ "name": "login", "enabled": false }', + 'error_page.json': + '{ "name": "error_page", "url": "https://example.com/error", "show_log_link": false }', + }; + + createDir(repoDir, { [constants.PAGES_DIRECTORY]: pagesNoHtml }); + + const config = { AUTH0_INPUT_FILE: repoDir }; const context = new Context(config, mockMgmtClient()); await context.load(); - expect(context.assets.pages).to.deep.equal(pagesTarget); + expect(context.assets.pages).to.deep.equal([ + { + html: '', + name: 'error_page', + show_log_link: false, + url: 'https://example.com/error', + }, + { + html: '', + name: 'login', + enabled: false, + }, + ]); }); it('should ignore unknown file', async () => {