From 314f7f8f31e9976046d96da6f29c61d721244447 Mon Sep 17 00:00:00 2001 From: Sven Aas Date: Tue, 10 Oct 2023 11:39:56 -0400 Subject: [PATCH] feat(admin): Add self authorization fields to organizations and published sites reports #4266 --- admin-client/src/pages/organization/OrgsReport.svelte | 4 ++++ .../pages/organization/PublishedSitesReport.svelte | 6 ++++++ api/admin/controllers/domain.js | 4 ++++ api/admin/controllers/organization.js | 4 ++++ scripts/create-dev-data.js | 6 +++++- test/api/admin/requests/domain.test.js | 7 ++++--- test/api/admin/requests/organization.test.js | 11 +++++++---- 7 files changed, 34 insertions(+), 8 deletions(-) diff --git a/admin-client/src/pages/organization/OrgsReport.svelte b/admin-client/src/pages/organization/OrgsReport.svelte index dbc3af008..8d53d3064 100644 --- a/admin-client/src/pages/organization/OrgsReport.svelte +++ b/admin-client/src/pages/organization/OrgsReport.svelte @@ -12,6 +12,7 @@ Organization Agency + Self Authorized @@ -20,6 +21,9 @@ {org.agency} + + {org.isSelfAuthorized ? 'Yes' : 'No'} + \ No newline at end of file diff --git a/admin-client/src/pages/organization/PublishedSitesReport.svelte b/admin-client/src/pages/organization/PublishedSitesReport.svelte index 0253b9e42..e8fb7a5a8 100644 --- a/admin-client/src/pages/organization/PublishedSitesReport.svelte +++ b/admin-client/src/pages/organization/PublishedSitesReport.svelte @@ -22,6 +22,7 @@ Organization Agency + Self Authorized Site Domains Engine @@ -37,6 +38,11 @@ {domain.Site.Organization.agency} {/if} + + {#if domain.Site && domain.Site.Organization} + {domain.Site.Organization.isSelfAuthorized ? 'Yes' : 'No'} + {/if} + {#if domain.Site } {domain.Site.repository} diff --git a/api/admin/controllers/domain.js b/api/admin/controllers/domain.js index 6bc314671..abdd121fa 100644 --- a/api/admin/controllers/domain.js +++ b/api/admin/controllers/domain.js @@ -100,6 +100,10 @@ module.exports = wrapHandlers({ label: 'Agency', value: 'Site.Organization.agency', }, + { + label: 'Self Authorized', + value: 'Site.Organization.isSelfAuthorized', + }, { label: 'Site', value: 'Site.repository', diff --git a/api/admin/controllers/organization.js b/api/admin/controllers/organization.js index 75c239791..cb17fac79 100644 --- a/api/admin/controllers/organization.js +++ b/api/admin/controllers/organization.js @@ -69,6 +69,10 @@ module.exports = wrapHandlers({ label: 'Agency', value: 'agency', }, + { + label: 'Self Authorized', + value: 'isSelfAuthorized', + }, ]; const parser = new json2csv.Parser({ fields }); diff --git a/scripts/create-dev-data.js b/scripts/create-dev-data.js index 09622e77c..dc40f83d1 100644 --- a/scripts/create-dev-data.js +++ b/scripts/create-dev-data.js @@ -164,7 +164,11 @@ async function createData() { const [agency1, agency2, agency3, agency4, sandbox] = await Promise.all([ Organization.create({ name: 'agency1', agency: 'GSA' }), Organization.create({ name: 'agency2', agency: 'GSA' }), - Organization.create({ name: 'agency3', agency: 'Bureau of Testing' }), + Organization.create({ + name: 'agency3', + agency: 'Bureau of Testing', + selfAuthorizedAt: addDays(new Date(), -183), + }), Organization.create({ name: 'agency4', agency: 'Demonstration Department', diff --git a/test/api/admin/requests/domain.test.js b/test/api/admin/requests/domain.test.js index 2b76853d0..a57b4f3ce 100644 --- a/test/api/admin/requests/domain.test.js +++ b/test/api/admin/requests/domain.test.js @@ -111,6 +111,7 @@ describe('Admin - Domains API', () => { const org = await factory.organization.create({ name: 'Test Org', agency: 'Test Agency', + selfAuthorizedAt: new Date(), }); const site = await factory.site({ organizationId: org.id }); const domain = await factory.domain.create({ @@ -140,14 +141,14 @@ describe('Admin - Domains API', () => { ); [header, ...data] = response.text.split(/\n/); expect(header).to.equal( - '"Organization","Agency","Site","Domain","Engine"' + '"Organization","Agency","Self Authorized","Site","Domain","Engine"' ); expect(data.length).to.equal(2); expect(data[0]).to.equal( - `"${org.name}","${org.agency}","${site.repository}","${domain.names}","${site.engine}"` + `"${org.name}","${org.agency}",true,"${site.repository}","${domain.names}","${site.engine}"` ); expect(data[1]).to.equal( - `,,"${orglessSite.repository}","${orglessDomain.names}","${orglessSite.engine}"` + `,,,"${orglessSite.repository}","${orglessDomain.names}","${orglessSite.engine}"` ); }); }); diff --git a/test/api/admin/requests/organization.test.js b/test/api/admin/requests/organization.test.js index d5185f3ed..57b9020e7 100644 --- a/test/api/admin/requests/organization.test.js +++ b/test/api/admin/requests/organization.test.js @@ -57,7 +57,10 @@ describe('Admin - Organizations API', () => { const user = await factory.user(); const org1 = await factory.organization.create({agency: 'Agency 1'}); - const org2 = await factory.organization.create({agency: 'Agency 2'}); + const org2 = await factory.organization.create({ + agency: 'Agency 2', + selfAuthorizedAt: new Date(), + }); const cookie = await authenticatedSession(user, sessionConfig); const response = await request(app) @@ -73,14 +76,14 @@ describe('Admin - Organizations API', () => { ); [header, ...data] = response.text.split(/\n/); expect(header).to.equal( - '"Organization","Agency"' + '"Organization","Agency","Self Authorized"' ); expect(data.length).to.equal(2); expect(data[0]).to.equal( - `"${org1.name}","${org1.agency}"` + `"${org1.name}","${org1.agency}",false` ); expect(data[1]).to.equal( - `"${org2.name}","${org2.agency}"` + `"${org2.name}","${org2.agency}",true` ); }); });