-
Notifications
You must be signed in to change notification settings - Fork 5
SMART on FHIR pt 3 - frontend changes #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
cd089d6
frontend changes
fzhao99 e0764c6
add in backend controller code
fzhao99 2bf18e6
add in configuration
fzhao99 380927d
Merge branch 'main' into nickclyde/smart-workflow-frontend
fzhao99 d068034
start add client seed
fzhao99 381bb31
add an e2e
fzhao99 8f7a42c
Merge branch 'main' into nickclyde/smart-workflow-frontend
fzhao99 db5d65e
replace hardcode server url with an env var
fzhao99 8baa32d
test rename
fzhao99 392f3de
Merge branch 'nickclyde/smart-workflow-frontend' of https://github.co…
fzhao99 9fb0990
add explicit fill for app hostname
fzhao99 ea177b1
try setting hostnames
fzhao99 c468063
switched to named in CI
fzhao99 87527ee
attempt one
fzhao99 d8f6046
woops the token endpoint is different
fzhao99 4c668d8
remove docker
fzhao99 82fd3d3
add key copy-over in the docker file
fzhao99 6547d61
add in directory copy
fzhao99 0fde529
add a dot
fzhao99 5e87b46
tweak dockerfile to allow for file writes
fzhao99 0d0f55e
pls?
fzhao99 a7c0130
Merge branch 'main' into nickclyde/smart-workflow-frontend
fzhao99 162ce15
add a test for JWT creation (#469)
fzhao99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,72 @@ | ||
import { TEST_URL } from "../playwright-setup"; | ||
import { test, expect } from "@playwright/test"; | ||
import { E2E_SMART_TEST_CLIENT_ID } from "./constants"; | ||
import { | ||
createSmartJwt, | ||
getOrCreateKeys, | ||
} from "@/app/backend/dbServices/smartOnFhir/lib"; | ||
import { decodeJwt, decodeProtectedHeader } from "jose"; | ||
|
||
test.describe("SMART on FHIR", () => { | ||
test("successfully validates the e2e flow", async ({ page }) => { | ||
await page.goto(`${TEST_URL}/fhirServers`); | ||
expect( | ||
page.getByRole("heading", { name: "FHIR server configuration" }), | ||
).toBeVisible(); | ||
|
||
await page.getByRole("button", { name: "New server" }).click(); | ||
await expect( | ||
page.getByRole("heading", { name: "New server" }), | ||
).toBeVisible(); | ||
const serverName = `E2E Smart on FHIR ${Math.random() * 100}`; | ||
await page.getByTestId("server-name").fill(serverName); | ||
|
||
await page | ||
.getByTestId("server-url") | ||
.fill(`${process.env.AIDBOX_BASE_URL}/fhir`); | ||
|
||
await page.getByTestId("auth-method").selectOption("SMART"); | ||
await page.getByTestId("client-id").fill(E2E_SMART_TEST_CLIENT_ID); | ||
|
||
await page.getByTestId("scopes").fill("system/*.read"); | ||
await page | ||
.getByTestId("token-endpoint") | ||
.fill(`${process.env.AIDBOX_BASE_URL}/auth/token`); | ||
|
||
await page.getByRole("button", { name: "Test connection" }).click(); | ||
await expect(page.getByRole("button", { name: "Success" })).toBeVisible(); | ||
|
||
await page.getByRole("button", { name: "Add server" }).click(); | ||
|
||
await expect( | ||
page.getByRole("row").filter({ hasText: serverName }), | ||
).toHaveText(/Connected/); | ||
}); | ||
|
||
// this integration test is stuck in the e2e because it requires connections | ||
// to a fully-seeded Aidbox. That infra was deemed too much to add to the | ||
// integration test docker compose at the time of this writing, so the | ||
// test itself is added here | ||
test("JWT creation generates the correct token and signing creates the right request payload", async () => { | ||
const tokenEndpoint = `${process.env.AIDBOX_BASE_URL}/auth/token`; | ||
|
||
// make sure key pair exist, and create them if they don't | ||
await getOrCreateKeys(); | ||
|
||
const outputJWT = await createSmartJwt( | ||
E2E_SMART_TEST_CLIENT_ID, | ||
tokenEndpoint, | ||
); | ||
|
||
const header = decodeProtectedHeader(outputJWT); | ||
expect(header.alg).toBe("RS384"); | ||
expect(header.typ).toBe("JWT"); | ||
expect(header.jku).toBe( | ||
`${process.env.APP_HOSTNAME}/.well-known/jwks.json`, | ||
); | ||
const claims = decodeJwt(outputJWT); | ||
expect(claims.aud).toBe(tokenEndpoint); | ||
expect(claims.iss).toBe(E2E_SMART_TEST_CLIENT_ID); | ||
expect(claims.sub).toBe(E2E_SMART_TEST_CLIENT_ID); | ||
}); | ||
}); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.