-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Etusivu palvelulle ennen palvelun avaamista (#606)
* Lisää uusi next-app väliaikaiselle etusivulle * mahdollista tyypillisen layoutin käytöstä poistaminen sivuilla * parantele sivulayoutin tyyliä, jos sisällölle tulee scrollbar * käytä väliaikaisessa appissa _documenttia, joka on pääasiallisessa next-apissa ja muokkaa Headin titlejä HASSU:sta Valtion liikenneväylien suunnitteluksi * lisää next.configiin assetPrefix, jotta tailwindcss tyylit löytyy * muokkaa kuvien urleja * ohjaa pyynnöt frontendilta /etusivu:lle jos basic auth ei ole kunnossa. Pyydä basic auth /yllapito/kirjaudu-polusta. --------- Co-authored-by: Mikko Haapamäki <mikko.haapamaki@cgi.com>
- Loading branch information
1 parent
8ad485b
commit a8dce19
Showing
25 changed files
with
354 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface CFResponse { | ||
readonly headers: Record<string, Record<string, { value: string }>[]>; | ||
readonly status: number; | ||
readonly statusText: string; | ||
} |
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,56 @@ | ||
import { describe } from "mocha"; | ||
import { CFResponse } from "./cfUtil"; | ||
|
||
const handler = require("../../../deployment/lib/lambda/frontendRequest").handler; | ||
|
||
const { expect } = require("chai"); | ||
const authorizedFakeHeader = "Basic " + Buffer.from("${BASIC_USERNAME}:${BASIC_PASSWORD}").toString("base64"); | ||
|
||
function runTest(uri: string, authenticated: boolean, expectedStatus: number | undefined, expectedLocation?: string) { | ||
handler( | ||
{ | ||
Records: [ | ||
{ | ||
cf: { | ||
request: { | ||
headers: authenticated | ||
? { | ||
authorization: [{ value: authorizedFakeHeader }], | ||
} | ||
: {}, | ||
method: "GET", | ||
uri, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
null, | ||
(_request: unknown, response: CFResponse) => { | ||
const testData = "(uri:" + uri + ", " + (authenticated ? "authenticated" : "unauthenticated") + ")"; | ||
expect(response.status).to.eq(expectedStatus, "testData:" + testData); | ||
if (expectedLocation !== undefined) { | ||
expect(response.headers["location"]?.[0].value).to.eq( | ||
expectedLocation, | ||
"expected redirect location to be " + expectedLocation + " testData:" + testData | ||
); | ||
} | ||
} | ||
); | ||
} | ||
|
||
describe("frontendRequest lambda@edge", () => { | ||
it("should return correct response for different paths", async () => { | ||
runTest("/", false, 302, "/etusivu/index.html"); | ||
runTest("/something", false, 401); | ||
runTest("/yllapito/kirjaudu", false, 401); | ||
|
||
// Basic auth kunnossa | ||
runTest("/something", true, undefined); | ||
runTest("/yllapito/kirjaudu", true, undefined); | ||
|
||
// Etusivu on auki kaikille | ||
runTest("/etusivu", false, undefined); | ||
runTest("/etusivu/index.html", false, undefined); | ||
}); | ||
}); |
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
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
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 @@ | ||
etusivu |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
import React, { FC, ReactNode, ComponentProps } from "react"; | ||
|
||
type ConditionalWrapperProps<T extends FC> = { | ||
condition: boolean; | ||
wrapper: T; | ||
children?: ReactNode; | ||
wrapperProps?: Omit<ComponentProps<T>, "children">; | ||
}; | ||
|
||
function ConditionalWrapper<T extends FC>({ condition, wrapper, children, wrapperProps }: ConditionalWrapperProps<T>) { | ||
return <>{condition ? wrapper({ children, ...wrapperProps }) : children}</>; | ||
} | ||
|
||
export default ConditionalWrapper; |
Oops, something went wrong.