-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin): Create 'Relying Parties' page & display RPs from db
Because: * We want a single source of truth to view FxA / Subplat relying parties This commit: * Adds a new RP model and resolver, uses a new query to read desired rows from clients table in fxa_oauth database * Displays this data in the UI with a new /relying-parties page * Adds RP guard to existing admin panel guards and to server/client * Contains a Nav account icon update, CSS tweaks
- Loading branch information
Showing
23 changed files
with
571 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
packages/fxa-admin-panel/src/components/PageRelyingParties/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { MockedProvider, MockedResponse } from '@apollo/client/testing'; | ||
import PageRelyingParties, { GET_RELYING_PARTIES } from '.'; | ||
import { RelyingParty } from 'fxa-admin-server/src/graphql'; | ||
|
||
const mockGetRelyingParties = ( | ||
relyingParties: RelyingParty[] = [] | ||
): MockedResponse => ({ | ||
request: { | ||
query: GET_RELYING_PARTIES, | ||
}, | ||
result: { | ||
data: { | ||
relyingParties, | ||
}, | ||
}, | ||
}); | ||
|
||
const MOCK_RP_ALL_FIELDS = { | ||
id: 'fced6b5e3f4c66b9', | ||
name: 'Firefox Send local-dev', | ||
redirectUri: 'http://localhost:1337/oauth', | ||
canGrant: true, | ||
publicClient: true, | ||
createdAt: 1583259953, | ||
trusted: true, | ||
imageUri: | ||
'https://mozorg.cdn.mozilla.net/media/img/firefox/new/header-firefox.png', | ||
allowedScopes: 'https://identity.mozilla.com/apps/send', | ||
} as RelyingParty; | ||
|
||
const MOCK_RP_FALSY_FIELDS = { | ||
id: '38a6b9b3a65a1871', | ||
name: '123Done PKCE', | ||
redirectUri: 'http://localhost:8080/?oauth_pkce_redirect=1', | ||
canGrant: false, | ||
publicClient: false, | ||
createdAt: 1583259953, | ||
trusted: false, | ||
imageUri: '', | ||
allowedScopes: null, | ||
} as RelyingParty; | ||
|
||
it('renders without imploding and shows loading text', () => { | ||
render( | ||
<MockedProvider mocks={[mockGetRelyingParties()]} addTypename={false}> | ||
<PageRelyingParties /> | ||
</MockedProvider> | ||
); | ||
const rpHeading = screen.getByRole('heading', { level: 2 }); | ||
expect(rpHeading).toHaveTextContent('Relying Parties'); | ||
screen.getByText('Loading...'); | ||
}); | ||
|
||
it('renders as expected with zero relying parties', async () => { | ||
render( | ||
<MockedProvider mocks={[mockGetRelyingParties()]} addTypename={false}> | ||
<PageRelyingParties /> | ||
</MockedProvider> | ||
); | ||
await new Promise((resolve) => setTimeout(resolve, 0)); | ||
screen.getByText('No relying parties were found', { exact: false }); | ||
}); | ||
|
||
it('renders as expected with a relying party containing all fields', async () => { | ||
render( | ||
<MockedProvider | ||
mocks={[mockGetRelyingParties([MOCK_RP_ALL_FIELDS])]} | ||
addTypename={false} | ||
> | ||
<PageRelyingParties /> | ||
</MockedProvider> | ||
); | ||
await new Promise((resolve) => setTimeout(resolve, 0)); | ||
screen.getByText(MOCK_RP_ALL_FIELDS.id); | ||
screen.getByText(MOCK_RP_ALL_FIELDS.name); | ||
screen.getByText(MOCK_RP_ALL_FIELDS.redirectUri); | ||
screen.getByText(MOCK_RP_ALL_FIELDS.allowedScopes!); | ||
screen.getByText('1970', { exact: false }); | ||
expect(screen.getAllByText('Yes')).toHaveLength(3); | ||
}); | ||
|
||
it('renders as expected with a relying party containing falsy fields', async () => { | ||
render( | ||
<MockedProvider | ||
mocks={[mockGetRelyingParties([MOCK_RP_FALSY_FIELDS])]} | ||
addTypename={false} | ||
> | ||
<PageRelyingParties /> | ||
</MockedProvider> | ||
); | ||
await new Promise((resolve) => setTimeout(resolve, 0)); | ||
expect(screen.getAllByText('No')).toHaveLength(3); | ||
screen.getByText('(empty string)'); | ||
screen.getByText('NULL'); | ||
}); |
Oops, something went wrong.