Skip to content

Commit 2926cb9

Browse files
committed
start to test suite for example resource server
1 parent b5b7bf5 commit 2926cb9

7 files changed

Lines changed: 184 additions & 4 deletions

File tree

.github/workflows/run-e2e-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ jobs:
1919
with:
2020
BUN_VERSION: ${{ inputs.BUN_VERSION }}
2121
test-suite-name: superuser
22+
Run-Example-Resource-Server-E2E-Tests:
23+
uses: ./.github/workflows/run-e2e-test-suite.yml
24+
with:
25+
BUN_VERSION: ${{ inputs.BUN_VERSION }}
26+
test-suite-name: example_resource_server
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe("ExampleResourceServer", () => {
2+
test("can visit the example resource server", async () => {
3+
cy.visit("http://example-nextjs-resource-server:3007");
4+
});
5+
});

tests/e2e-auth-tests/docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
- schemavaults-auth
2020
profiles:
2121
- e2e
22+
- e2e_with_resource_server
2223
command:
2324
[
2425
"bun",
@@ -28,6 +29,29 @@ services:
2829
"./cypress/e2e/${TEST_SUITE_NAME:?error}/**.cy.ts",
2930
]
3031

32+
example-nextjs-resource-server:
33+
build:
34+
context: ../..
35+
dockerfile: tests/example-nextjs-resource-server/Dockerfile
36+
args:
37+
BUN_VERSION: 1.3.6
38+
NODEJS_VERSION: 24-alpine
39+
target: production
40+
depends_on:
41+
- schemavaults-auth
42+
links:
43+
- schemavaults-auth
44+
environment:
45+
SCHEMAVAULTS_APP_ENVIRONMENT: test
46+
NEXT_PUBLIC_SCHEMAVAULTS_APP_ENVIRONMENT: test
47+
NODE_ENV: test
48+
expose:
49+
- 3007
50+
ports:
51+
- 3007:3007
52+
profiles:
53+
- e2e_with_resource_server
54+
3155
schemavaults-auth:
3256
build:
3357
context: ../..

tests/e2e-auth-tests/e2e-auth-tests-cli.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ e2eAuthTestsCli
114114
process.exit(404);
115115
}
116116

117-
const defaultDockerComposeProfile = "e2e" as const;
118-
const dockerComposeProfile: string = defaultDockerComposeProfile;
117+
const dockerComposeProfile: string = test_suite_name.includes(
118+
"resource_server",
119+
)
120+
? ("e2e_with_resource_server" as const)
121+
: ("e2e" as const);
119122

120123
// args for the `docker compose up` command that launches the e2e test
121124
const args: string[] = [

tests/e2e-auth-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@schemavaults/e2e-auth-tests",
3-
"version": "0.2.9",
3+
"version": "0.2.10",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/schemavaults/auth.git",
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Dockerfile for @schemavaults/example-nextjs-resource-server
2+
3+
ARG BUN_VERSION
4+
ARG NODEJS_VERSION
5+
6+
FROM oven/bun:${BUN_VERSION} AS bunbase
7+
FROM node:${NODEJS_VERSION} AS nodejsbase
8+
9+
FROM bunbase AS deps
10+
11+
WORKDIR /schemavaults/auth
12+
13+
### Monorepo Root Package Details ###
14+
COPY --chown=bun:bun package.json package.json
15+
COPY --chown=bun:bun bun.lock bun.lock
16+
COPY --chown=bun:bun turbo.json turbo.json
17+
18+
# Copy helper script for removing "./auth-server" from 'workspaces' definitions. we only need packages and tests.
19+
COPY scripts/remove-auth-server-from-workspaces-definition.sh scripts/remove-auth-server-from-workspaces-definition.sh
20+
21+
# Set permissions for the helper script
22+
RUN chmod +x scripts/remove-auth-server-from-workspaces-definition.sh
23+
RUN /bin/bash ./scripts/remove-auth-server-from-workspaces-definition.sh
24+
25+
### Example Resource Server Config Files ###
26+
COPY --chown=bun:bun tests/example-nextjs-resource-server/package.json tests/example-nextjs-resource-server/package.json
27+
COPY --chown=bun:bun tests/example-nextjs-resource-server/postcss.config.js tests/example-nextjs-resource-server/postcss.config.js
28+
COPY --chown=bun:bun tests/example-nextjs-resource-server/tailwind.config.ts tests/example-nextjs-resource-server/tailwind.config.ts
29+
COPY --chown=bun:bun tests/example-nextjs-resource-server/next.config.ts tests/example-nextjs-resource-server/next.config.ts
30+
COPY --chown=bun:bun tests/example-nextjs-resource-server/tsconfig.json tests/example-nextjs-resource-server/tsconfig.json
31+
32+
### Supporting Auth Packages (Config Files) ###
33+
34+
# @schemavaults/app-definitions
35+
COPY --chown=bun:bun packages/app-definitions/package.json packages/app-definitions/package.json
36+
COPY --chown=bun:bun packages/app-definitions/tsconfig.json packages/app-definitions/tsconfig.json
37+
COPY --chown=bun:bun packages/app-definitions/eslint.config.cjs packages/app-definitions/eslint.config.cjs
38+
39+
# @schemavaults/auth-client-sdk
40+
COPY --chown=bun:bun packages/auth-client-sdk/package.json packages/auth-client-sdk/package.json
41+
COPY --chown=bun:bun packages/auth-client-sdk/tsconfig.json packages/auth-client-sdk/tsconfig.json
42+
COPY --chown=bun:bun packages/auth-client-sdk/eslint.config.cjs packages/auth-client-sdk/eslint.config.cjs
43+
COPY --chown=bun:bun packages/auth-client-sdk/generate-version.sh packages/auth-client-sdk/generate-version.sh
44+
COPY --chown=bun:bun packages/auth-client-sdk/turbo.json packages/auth-client-sdk/turbo.json
45+
46+
# @schemavaults/auth-common
47+
COPY --chown=bun:bun packages/auth-common/package.json packages/auth-common/package.json
48+
COPY --chown=bun:bun packages/auth-common/tsconfig.json packages/auth-common/tsconfig.json
49+
COPY --chown=bun:bun packages/auth-common/eslint.config.cjs packages/auth-common/eslint.config.cjs
50+
51+
# @schemavaults/auth-react-provider
52+
COPY --chown=bun:bun packages/auth-react-provider/package.json packages/auth-react-provider/package.json
53+
COPY --chown=bun:bun packages/auth-react-provider/tsconfig.json packages/auth-react-provider/tsconfig.json
54+
COPY --chown=bun:bun packages/auth-react-provider/eslint.config.cjs packages/auth-react-provider/eslint.config.cjs
55+
56+
# @schemavaults/auth-resource-server-codegen-templates
57+
COPY --chown=bun:bun packages/auth-resource-server-codegen-templates/package.json packages/auth-resource-server-codegen-templates/package.json
58+
COPY --chown=bun:bun packages/auth-resource-server-codegen-templates/tsconfig.json packages/auth-resource-server-codegen-templates/tsconfig.json
59+
COPY --chown=bun:bun packages/auth-resource-server-codegen-templates/eslint.config.cjs packages/auth-resource-server-codegen-templates/eslint.config.cjs
60+
61+
# @schemavaults/auth-server-sdk
62+
COPY --chown=bun:bun packages/auth-server-sdk/package.json packages/auth-server-sdk/package.json
63+
COPY --chown=bun:bun packages/auth-server-sdk/tsconfig.json packages/auth-server-sdk/tsconfig.json
64+
COPY --chown=bun:bun packages/auth-server-sdk/eslint.config.cjs packages/auth-server-sdk/eslint.config.cjs
65+
COPY --chown=bun:bun packages/auth-server-sdk/copy-codegen-templates.sh packages/auth-server-sdk/copy-codegen-templates.sh
66+
COPY --chown=bun:bun packages/auth-server-sdk/prepare-cli.sh packages/auth-server-sdk/prepare-cli.sh
67+
68+
# @schemavaults/jwt
69+
COPY --chown=bun:bun packages/jwt/package.json packages/jwt/package.json
70+
COPY --chown=bun:bun packages/jwt/tsconfig.json packages/jwt/tsconfig.json
71+
COPY --chown=bun:bun packages/jwt/eslint.config.cjs packages/jwt/eslint.config.cjs
72+
73+
### Install packages
74+
RUN bun install
75+
76+
FROM deps AS development
77+
78+
### Command to launch development environment
79+
# You'll want to ensure that src/ directories are mounted
80+
WORKDIR /schemavaults/auth
81+
CMD [ "bun", "run", "dev", "--filter", "@schemavaults/example-nextjs-resource-server" ]
82+
83+
FROM deps AS source
84+
85+
WORKDIR /schemavaults/auth
86+
87+
### Example Resource Server (Source Code) ###
88+
89+
COPY --chown=bun:bun tests/example-nextjs-resource-server/src/ tests/example-nextjs-resource-server/src/
90+
COPY --chown=bun:bun tests/example-nextjs-resource-server/public/ tests/example-nextjs-resource-server/public/
91+
92+
### Supporting Auth Packages (Source Code) ###
93+
94+
# @schemavaults/app-definitions
95+
COPY --chown=bun:bun packages/app-definitions/src/ packages/app-definitions/src/
96+
97+
# @schemavaults/auth-client-sdk
98+
COPY --chown=bun:bun packages/auth-client-sdk/src/ packages/auth-client-sdk/src/
99+
100+
# @schemavaults/auth-common
101+
COPY --chown=bun:bun packages/auth-common/src/ packages/auth-common/src/
102+
103+
# @schemavaults/auth-react-provider
104+
COPY --chown=bun:bun packages/auth-react-provider/src/ packages/auth-react-provider/src/
105+
106+
# @schemavaults/auth-resource-server-codegen-templates
107+
COPY --chown=bun:bun packages/auth-resource-server-codegen-templates/src/ packages/auth-resource-server-codegen-templates/src/
108+
109+
# @schemavaults/auth-server-sdk
110+
COPY --chown=bun:bun packages/auth-server-sdk/src/ packages/auth-server-sdk/src/
111+
112+
# @schemavaults/jwt
113+
COPY --chown=bun:bun packages/jwt/src/ packages/jwt/src/
114+
115+
### Build final server code ###
116+
FROM source AS build
117+
118+
WORKDIR /schemavaults/auth
119+
120+
# Build server
121+
ENV NEXT_STANDALONE_DOCKER_BUILD true
122+
ENV NEXT_TELEMETRY_DISABLED 1
123+
RUN bun run build --filter @schemavaults/example-nextjs-resource-server
124+
125+
FROM nodejsbase AS production
126+
127+
WORKDIR /schemavaults/auth
128+
129+
COPY --from=build --chown=nodejs:nodejs /schemavaults/auth/example-nextjs-resource-server/package.json tests/example-nextjs-resource-server/package.json
130+
COPY --from=build --chown=nodejs:nodejs /schemavaults/auth/example-nextjs-resource-server/.next/standalone/ tests/example-nextjs-resource-server/.next/standalone/
131+
COPY --from=build --chown=nodejs:nodejs /schemavaults/auth/example-nextjs-resource-server/.next/static/ tests/example-nextjs-resource-server/.next/standalone/tests/example-nextjs-resource-server/.next/static/
132+
COPY --from=build --chown=nodejs:nodejs /schemavaults/auth/example-nextjs-resource-server/public/ tests/example-nextjs-resource-server/.next/standalone/tests/example-nextjs-resource-server/public/
133+
134+
WORKDIR /schemavaults/auth/tests/example-nextjs-resource-server
135+
136+
EXPOSE 80
137+
ENV PORT 80
138+
ENV HOSTNAME 0.0.0.0
139+
140+
ENV NEXT_TELEMETRY_DISABLED 1
141+
ENV NEXT_STANDALONE_DOCKER_BUILD true
142+
143+
CMD [ "node", "./.next/standalone/tests/example-nextjs-resource-server/server.js" ]

tests/example-nextjs-resource-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@schemavaults/example-nextjs-resource-server",
3-
"version": "0.0.5",
3+
"version": "0.1.0",
44
"license": "UNLICENSED",
55
"private": false,
66
"repository": {

0 commit comments

Comments
 (0)