Skip to content

Commit

Permalink
Merge pull request #4267 from cloud-gov/4266-add-self-auth-flag-to-re…
Browse files Browse the repository at this point in the history
…ports

Add self authorization fields to organizations and published sites reports
  • Loading branch information
svenaas authored Oct 10, 2023
2 parents 160e605 + 314f7f8 commit 8bc5095
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
4 changes: 4 additions & 0 deletions admin-client/src/pages/organization/OrgsReport.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<tr slot="header">
<th scope="col">Organization</th>
<th scope="col">Agency</th>
<th scope="col">Self Authorized</th>
</tr>
<tr slot="item" let:item={org}>
<td>
Expand All @@ -20,6 +21,9 @@
<td>
{org.agency}
</td>
<td>
{org.isSelfAuthorized ? 'Yes' : 'No'}
</td>
</tr>
</DataTable>
</PaginatedQueryPage>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<tr slot="header">
<th scope="col">Organization</th>
<th scope="col">Agency</th>
<th scope="col">Self Authorized</th>
<th scope="col">Site</th>
<th scope="col">Domains</th>
<th scope="col">Engine</th>
Expand All @@ -37,6 +38,11 @@
{domain.Site.Organization.agency}
{/if}
</td>
<td>
{#if domain.Site && domain.Site.Organization}
{domain.Site.Organization.isSelfAuthorized ? 'Yes' : 'No'}
{/if}
</td>
<td>
{#if domain.Site }
<a href="/sites/{domain.Site.id}">{domain.Site.repository}</a>
Expand Down
4 changes: 4 additions & 0 deletions api/admin/controllers/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions api/admin/controllers/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ module.exports = wrapHandlers({
label: 'Agency',
value: 'agency',
},
{
label: 'Self Authorized',
value: 'isSelfAuthorized',
},
];

const parser = new json2csv.Parser({ fields });
Expand Down
6 changes: 5 additions & 1 deletion scripts/create-dev-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 4 additions & 3 deletions test/api/admin/requests/domain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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}"`
);
});
});
Expand Down
11 changes: 7 additions & 4 deletions test/api/admin/requests/organization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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`
);
});
});
Expand Down

0 comments on commit 8bc5095

Please sign in to comment.