Skip to content

Commit 70de715

Browse files
authored
feat: add website test workflow (#577)
- Adds workflow to run supertokens-website tests - Updates `frontendIntegration` servers to support test changes
1 parent 3f8a417 commit 70de715

File tree

32 files changed

+622
-369
lines changed

32 files changed

+622
-369
lines changed

.github/workflows/website-test.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: "Website Tests"
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
push:
10+
branches:
11+
- master
12+
- "v[0-9]+.[0-9]+"
13+
tags:
14+
- "(dev-)?v[0-9]+.[0-9]+.[0-9]+"
15+
16+
jobs:
17+
define-versions:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
fdiVersions: ${{ steps.versions.outputs.fdiVersions }}
21+
cdiVersions: ${{ steps.versions.outputs.cdiVersions }}
22+
pyVersions: '["3.8", "3.13"]'
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: supertokens/get-supported-versions-action@main
26+
id: versions
27+
with:
28+
has-fdi: true
29+
has-cdi: true
30+
31+
test:
32+
runs-on: ubuntu-latest
33+
needs: define-versions
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
py-version: ${{ fromJSON(needs.define-versions.outputs.pyVersions) }}
38+
fdi-version: ${{ fromJSON(needs.define-versions.outputs.fdiVersions) }}
39+
framework:
40+
- django2x
41+
- django3x
42+
- drf_sync
43+
- drf_async
44+
- fastapi
45+
- flask
46+
- flask-nest-asyncio
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
with:
51+
path: supertokens-python
52+
53+
- uses: actions/setup-python@v5
54+
with:
55+
python-version: ${{ matrix.py-version }}
56+
57+
- uses: supertokens/get-versions-action@main
58+
id: versions
59+
with:
60+
driver-name: python
61+
fdi-version: ${{ matrix.fdi-version }}
62+
env:
63+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
64+
65+
- name: Start core
66+
working-directory: supertokens-python
67+
run: docker compose up --wait
68+
69+
- name: Setup venv
70+
working-directory: supertokens-python
71+
run: |
72+
python3 -m venv venv
73+
source venv/bin/activate
74+
python3 -m pip install pip setuptools --upgrade
75+
76+
- name: Install dependencies and start servers (django2x)
77+
if: matrix.framework == 'django2x'
78+
working-directory: supertokens-python
79+
run: |
80+
source venv/bin/activate
81+
make with-django2x
82+
83+
# Django2 uses `cgi`, deprecated in 3.13
84+
if [ ${{ matrix.py-version == '3.13' }} ]; then
85+
pip install legacy-cgi
86+
fi
87+
88+
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
89+
cd tests/frontendIntegration/django2x
90+
91+
gunicorn mysite.wsgi --bind 0.0.0.0:8080 &> app-server.log &
92+
gunicorn mysite.wsgi --bind 0.0.0.0:8082 &> app-server-cross-domain.log &
93+
94+
- name: Install dependencies and start servers (django3x)
95+
if: matrix.framework == 'django3x'
96+
working-directory: supertokens-python
97+
run: |
98+
source venv/bin/activate
99+
make with-django
100+
101+
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
102+
cd tests/frontendIntegration/django3x
103+
104+
uvicorn mysite.asgi:application --port 8080 &> app-server.log &
105+
uvicorn mysite.asgi:application --port 8082 &> app-server-cross-domain.log &
106+
107+
- name: Install dependencies and start servers (drf_sync)
108+
if: matrix.framework == 'drf_sync'
109+
working-directory: supertokens-python
110+
run: |
111+
source venv/bin/activate
112+
make with-drf
113+
114+
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
115+
cd tests/frontendIntegration/drf_sync
116+
117+
gunicorn mysite.wsgi --bind 0.0.0.0:8080 &> app-server.log &
118+
gunicorn mysite.wsgi --bind 0.0.0.0:8082 &> app-server-cross-domain.log &
119+
120+
- name: Install dependencies and start servers (drf_async)
121+
if: matrix.framework == 'drf_async'
122+
working-directory: supertokens-python
123+
run: |
124+
source venv/bin/activate
125+
make with-drf
126+
127+
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
128+
cd tests/frontendIntegration/drf_async
129+
130+
uvicorn mysite.asgi:application --port 8080 &> app-server.log &
131+
uvicorn mysite.asgi:application --port 8082 &> app-server-cross-domain.log &
132+
133+
- name: Install dependencies and start servers (fastapi)
134+
if: matrix.framework == 'fastapi'
135+
working-directory: supertokens-python
136+
run: |
137+
source venv/bin/activate
138+
make with-fastapi
139+
140+
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
141+
cd tests/frontendIntegration/fastapi-server
142+
143+
uvicorn app:app --host 0.0.0.0 --port 8080 &> app-server.log &
144+
uvicorn app:app --host 0.0.0.0 --port 8082 &> app-server-cross-domain.log &
145+
146+
- name: Install dependencies and start servers (flask)
147+
if: matrix.framework == 'flask'
148+
working-directory: supertokens-python
149+
run: |
150+
source venv/bin/activate
151+
make with-flask
152+
153+
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
154+
cd tests/frontendIntegration/flask-server
155+
156+
python3 app.py --port 8080 &> app-server.log &
157+
python3 app.py --port 8082 &> app-server-cross-domain.log &
158+
159+
- name: Install dependencies and start servers (flask-nest-asyncio)
160+
if: matrix.framework == 'flask-nest-asyncio'
161+
working-directory: supertokens-python
162+
run: |
163+
source venv/bin/activate
164+
make with-flask
165+
python -m pip install nest-asyncio
166+
167+
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
168+
cd tests/frontendIntegration/flask-server
169+
170+
python3 app.py --port 8080 &> app-server.log &
171+
python3 app.py --port 8082 &> app-server-cross-domain.log &
172+
173+
- uses: supertokens/website-testing-action@main
174+
with:
175+
version: ${{ steps.versions.outputs.frontendVersionXy }}
176+
node-sdk-version: ${{ steps.versions.outputs.nodeTag }}
177+
path: supertokens-website
178+
check-name-suffix: '[Py=${{ matrix.py-version }}][FDI=${{ matrix.fdi-version }}][Framework=${{ matrix.framework }}]'

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
## [unreleased]
1010
- Sets up workflow to run backend-sdk-testing
1111
- Updates test-servers to work with updated tests
12+
- Adds workflow to test supertokens-website
13+
- Updates `frontendIntegration` servers
1214

1315
## [0.29.1] - 2025-04-11
1416
- Fixes an issue where `removeDevice` API allowed removing verified TOTP devices without the user completing MFA.

tests/frontendIntegration/django2x/mysite/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@
2828
# SECURITY WARNING: don't run with debug turned on in production!
2929
DEBUG = True
3030

31-
ALLOWED_HOSTS = ["localhost.org", "localhost", "0.0.0.0"]
31+
ALLOWED_HOSTS = ["localhost.org", "localhost", "0.0.0.0", "cross.localhost"]
3232

3333
CORS_ORIGIN_WHITELIST = [
34-
"http://localhost.org:8080",
34+
"http://localhost:8080",
3535
]
3636
CORS_ALLOW_ALL_ORIGINS = True
3737
CORS_ALLOW_CREDENTIALS = True
3838
CORS_ALLOWED_ORIGINS = [
39-
"http://localhost.org:8080",
39+
"http://localhost:8080",
4040
]
4141
CORS_ALLOWED_ORIGIN_REGEXES = [
42-
"http://localhost.org:8080",
42+
"http://localhost:8080",
4343
]
4444

4545
CORS_ALLOW_METHODS = [

tests/frontendIntegration/django2x/mysite/wsgi.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
# to help middleware function with uvicorn (to ensure supertokens init is called)
1818
from polls.views import config
1919

20-
config(True, False, None)
20+
core_host = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost")
21+
core_port = os.environ.get("SUPERTOKENS_CORE_PORT", "3567")
22+
23+
config(
24+
core_url=f"http://{core_host}:{core_port}",
25+
enable_anti_csrf=True,
26+
enable_jwt=False,
27+
jwt_property_name=None,
28+
)
2129

2230
application = get_wsgi_application()

tests/frontendIntegration/django2x/polls/urls.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
path("index.html", views.send_file, name="index.html"), # type: ignore
88
path("login", views.login, name="login"), # type: ignore
99
path("login-2.18", views.login_218, name="login_218"), # type: ignore
10+
path(
11+
"test/setup/st",
12+
views.setup_st, # type: ignore
13+
name="setup_st",
14+
),
1015
path("beforeeach", views.before_each, name="beforeeach"), # type: ignore
16+
path("after", views.after, name="after"), # type: ignore
1117
path("testUserConfig", views.test_config, name="testUserConfig"), # type: ignore
1218
path(
1319
"multipleInterceptors",
@@ -40,8 +46,6 @@
4046
name="refreshAttemptedTime",
4147
),
4248
path("auth/session/refresh", views.refresh, name="refresh"), # type: ignore
43-
path("setAntiCsrf", views.set_anti_csrf, name="setAntiCsrf"),
44-
path("setEnableJWT", views.set_enable_jwt, name="setEnableJWT"),
4549
path("featureFlags", views.feature_flags, name="featureFlags"),
4650
path(
4751
"reinitialiseBackendConfig",

0 commit comments

Comments
 (0)