-
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.
Merge pull request #22 from button-inc/21-playwright-auth-setup
π playwright config for auth tests
- Loading branch information
Showing
75 changed files
with
1,511 additions
and
1,481 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
API_HOST= | ||
DATABASE= | ||
DATABASE_HOST= | ||
DATABASE_PORT= | ||
DATABASE_PROTOCOL= | ||
DATABASE_SCHEMA_ADMIN= | ||
DATABASE_SCHEMA_CLEAN= | ||
DATABASE_SCHEMA_WORKSPACE= | ||
DATABASE_SCHEMA_VAULT= | ||
DATABASE_USER_ADMIN= | ||
DATABASE_USER_PW_ADMIN= | ||
DATABASE_USER_ANALYST= | ||
DATABASE_USER_PW_ANALYST= | ||
DATABASE_USER_DROPPER= | ||
DATABASE_USER_PW_DROPPER= | ||
DATABASE_USER_MANAGER= | ||
DATABASE_USER_PW_MANAGER= | ||
GOOGLE_BUCKET_NAME= | ||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= | ||
NEXTAUTH_URL= | ||
NEXTAUTH_SECRET= |
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 |
---|---|---|
|
@@ -30,5 +30,15 @@ jobs: | |
target-url: 'http://localhost:3000' | ||
package-manager: 'pnpm' | ||
|
||
|
||
|
||
call-workflow-gitleaks-scan: | ||
uses: button-inc/gh-actions/.github/workflows/[email protected] | ||
with: | ||
notify-user-list: "@shon-button,@YaokunLin" | ||
secrets: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
gitleaks-license: ${{ secrets.GITLEAKS_LICENSE}} | ||
|
||
call-workflow-owasp-zap-scan: | ||
uses: button-inc/gh-actions/.github/workflows/[email protected] | ||
with: | ||
target-url: "http://localhost:3000" |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"typescript.tsdk": "node_modules\\.pnpm\\[email protected]\\node_modules\\typescript\\lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import Anonymized from "@/components/routes/anonymized/Anonymized"; | ||
|
||
export default function Page() { | ||
// ποΈ graphQL query endpoint for this role | ||
const endpoint = "api/analyst/graphql"; | ||
return ( | ||
<> | ||
{/* @ts-expect-error Server Component */} | ||
<Anonymized endpoint={endpoint}></Anonymized> | ||
<Anonymized></Anonymized> | ||
</> | ||
); | ||
} |
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,16 @@ | ||
import ImportedArea from "@/components/routes/imported/id/Area"; | ||
|
||
export default function Page({ | ||
params, | ||
}: { | ||
params: { | ||
id: string; | ||
}; | ||
}) { | ||
return ( | ||
<> | ||
{/* @ts-expect-error Server Component */} | ||
<ImportedArea id={params.id}></ImportedArea> | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import Imported from "@/components/routes/imported/Imported"; | ||
|
||
export default function Page() { | ||
// ποΈ graphQL query endpoint for this role | ||
const endpoint = "api/analyst/graphql"; | ||
return ( | ||
<> | ||
{/* @ts-expect-error Server Component */} | ||
<Imported endpoint={endpoint}></Imported> | ||
<Imported></Imported> | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,71 +1,12 @@ | ||
"use client"; | ||
import { getProviders, signIn, ClientSafeProvider } from "next-auth/react"; | ||
import React, { useEffect, useState } from "react"; | ||
import styles from "./styles.module.css"; | ||
import { useTranslation } from "@/i18n/client"; | ||
import dynamic from "next/dynamic"; | ||
//ποΈ will not be rendered on the server, prevents error: Text content did not match. Server | ||
const Tag = dynamic(() => import("@/components/layout/Tag"), { | ||
const SignIn = dynamic(() => import("@/components/auth/SignIn"), { | ||
ssr: false, | ||
}); | ||
export default function Page() { | ||
const { t } = useTranslation("translation"); | ||
const [data, setData] = useState<Record<string, ClientSafeProvider> | null>( | ||
null | ||
); | ||
|
||
// ποΈ code running on the client-side should be placed inside a useEffect hook with the appropriate condition to ensure it only runs in the browser | ||
useEffect(() => { | ||
// ποΈ call to next-auth providers list | ||
const fetchData = async () => { | ||
const providers = await getProviders(); | ||
setData(providers); | ||
}; | ||
|
||
fetchData(); | ||
}, []); | ||
|
||
// ποΈ render the providers as login buttons with the correct calback url | ||
let hostUrl; | ||
if (typeof window !== "undefined") { | ||
hostUrl = window.location.origin; | ||
} | ||
// ποΈ nextauth signin calback url | ||
const callbackUrl = | ||
hostUrl && hostUrl.includes("http://localhost:4503") | ||
? "http://localhost:3000" | ||
: process.env.NEXTAUTH_URL || "http://localhost:3000"; | ||
|
||
// ποΈ nextauth provider signin | ||
const handleSignIn = async (providerId: string) => { | ||
await signIn(providerId, { | ||
callbackUrl, | ||
}); | ||
}; | ||
|
||
const content = data | ||
? Object.values(data).map((provider: ClientSafeProvider) => ( | ||
<div key={provider.id} className={styles.provider}> | ||
<button | ||
className={styles.button} | ||
onClick={() => handleSignIn(provider.id)} | ||
> | ||
<img | ||
alt={provider.name} | ||
src={`https://authjs.dev/img/providers/${provider.id}.svg`} | ||
/> | ||
<span> | ||
{t("auth.signin")} {provider.name} | ||
</span> | ||
</button> | ||
</div> | ||
)) | ||
: null; | ||
|
||
return ( | ||
<> | ||
<Tag tag={"auth.tag"} crumbs={[]}></Tag> | ||
{content} | ||
<SignIn /> | ||
</> | ||
); | ||
} |
Oops, something went wrong.