Skip to content

Commit

Permalink
Merge pull request #3188 from Opetushallitus/tor-2210-samplen-parannu…
Browse files Browse the repository at this point in the history
…ksia

TOR-2210: OmaData OAuth2 samplen parannuksia
  • Loading branch information
AleksiAhtiainen authored Oct 31, 2024
2 parents 378cd8f + 6a89f08 commit cb70252
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 23 deletions.
61 changes: 45 additions & 16 deletions omadata-oauth2-sample/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion omadata-oauth2-sample/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react-hooks": "^5.0.0",
"http-proxy-middleware": "^3.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
Expand All @@ -26,7 +27,6 @@
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
"proxy": "http://localhost:7051",
"scripts": {
"start": "FORCE_COLOR=true npm run start-react-scripts | cat",
"start-react-scripts": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion omadata-oauth2-sample/client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

.App-header {
background-color: #282c34;
min-height: 100vh;
min-height: 20vh;
display: flex;
flex-direction: column;
align-items: center;
Expand Down
13 changes: 11 additions & 2 deletions omadata-oauth2-sample/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ function App() {
<div className="App">
<header className="App-header">
<p>OmaDataOAuth2 Sample app</p>
<p>{!data ? "Loading..." : JSON.stringify(data)}</p>
<p>{!error ? "Checking errors..." : error}</p>
</header>
<p>
<a href={"/api/openid-api-test"}>Test whole authorization code flow</a>
</p>
<p>
<a href={"/api/openid-api-test/invalid-redirect-uri"}>
Test authorization code flow with invalid redirect_uri
</a>
</p>
<h2>Fetch resource using access token result:</h2>
<p>{!data ? "Loading..." : JSON.stringify(data)}</p>
<p>{!error ? "Checking errors..." : error}</p>
</div>
)
}
Expand Down
11 changes: 11 additions & 0 deletions omadata-oauth2-sample/client/src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:7051/api',
changeOrigin: true,
})
);
};
6 changes: 3 additions & 3 deletions omadata-oauth2-sample/client/test/e2e/front-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test("Front page opens", async ({ page }) => {

test("Front page contains content from KOSKI", async ({ page }) => {
await page.goto("/")
await expect(page.getByRole("banner")).toContainText("SUCCESS")
await expect(page.getByRole("banner")).toContainText("henkilö")
await expect(page.getByRole("banner")).toContainText("opiskeluoikeudet")
await expect(page.getByText("SUCCESS")).toBeVisible()
await expect(page.locator("#root")).toContainText("henkilö")
await expect(page.locator("#root")).toContainText("opiskeluoikeudet")
})

0 comments on commit cb70252

Please sign in to comment.