Skip to content

Commit 99799b7

Browse files
committed
test: add e2e tests
1 parent 1b94a38 commit 99799b7

File tree

25 files changed

+2685
-114
lines changed

25 files changed

+2685
-114
lines changed

.github/workflows/pull-request.yml

Lines changed: 133 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,140 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
check-commits:
15-
name: Check Commitizen
14+
test-e2e:
15+
name: Test E2E
1616
runs-on: ubuntu-latest
17+
env:
18+
THEME_PATH: ./keycloak-app-passwords-theme.jar
19+
EXTENSION_PATH: ./keycloak-app-passwords-extension.jar
1720
steps:
1821
- name: Checkout Repo
1922
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 0
22-
- name: Setup Pyhon
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: "3.13"
26-
- name: Install Commitizen
27-
run: ./.internal/ci/install-cz.sh
28-
- name: Check Commits
29-
run: ./.internal/ci/version-check.sh
30-
31-
build-theme:
32-
name: Build Theme
33-
runs-on: ubuntu-latest
34-
steps:
35-
- name: Checkout Repo
36-
uses: actions/checkout@v4
37-
- name: Cache NPM
38-
uses: actions/cache@v4
39-
with:
40-
path: ~/.npm
41-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
42-
restore-keys: |
43-
${{ runner.os }}-node-
44-
- name: Setup Node
45-
uses: actions/setup-node@v4
46-
- name: Build
47-
run: ./.internal/ci/build-theme.sh
48-
49-
build-extension:
50-
name: Build Extension
51-
runs-on: ubuntu-latest
52-
steps:
53-
- name: Checkout Repo
54-
uses: actions/checkout@v4
55-
- name: Cache Maven
56-
uses: actions/cache@v4
57-
with:
58-
path: ~/.m2/repository
59-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
60-
restore-keys: |
61-
${{ runner.os }}-maven-
62-
- name: Setup Java
63-
uses: actions/setup-java@v4
64-
with:
65-
distribution: "temurin"
66-
java-version: "17"
67-
- name: Build & Test
68-
run: ./.internal/ci/build-extension.sh
23+
24+
- name: Setup OpenLDAP
25+
run: ./.internal/ci/init-openldap.sh
26+
27+
- name: Import Data
28+
run: |
29+
touch ./extension/keycloak-app-passwords-theme.jar
30+
touch ./extension/keycloak-app-passwords-extension.jar
31+
./.internal/ci/import-data.sh
32+
33+
# check-commits:
34+
# name: Check Commitizen
35+
# runs-on: ubuntu-latest
36+
# steps:
37+
# - name: Checkout Repo
38+
# uses: actions/checkout@v4
39+
# with:
40+
# fetch-depth: 0
41+
42+
# - name: Setup Pyhon
43+
# uses: actions/setup-python@v5
44+
# with:
45+
# python-version: '3.13'
46+
47+
# - name: Install Commitizen
48+
# run: ./.internal/ci/install-cz.sh
49+
50+
# - name: Check Commits
51+
# run: ./.internal/ci/version-check.sh
52+
53+
# build-theme:
54+
# name: Build Theme
55+
# runs-on: ubuntu-latest
56+
# steps:
57+
# - name: Checkout Repo
58+
# uses: actions/checkout@v4
59+
60+
# - name: Cache NPM
61+
# uses: actions/cache@v4
62+
# with:
63+
# path: ~/.npm
64+
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
65+
# restore-keys: |
66+
# ${{ runner.os }}-node-
67+
68+
# - name: Setup Node
69+
# uses: actions/setup-node@v4
70+
71+
# - name: Build Theme
72+
# run: ./.internal/ci/build-theme.sh
73+
74+
# - name: Upload Theme Jar
75+
# id: upload
76+
# uses: actions/upload-artifact@v4
77+
# with:
78+
# name: keycloak-app-passwords-theme.jar
79+
# path: ./theme/dist_keycloak/keycloak-theme-for-kc-all-other-versions.jar
80+
81+
# build-extension:
82+
# name: Build Extension
83+
# runs-on: ubuntu-latest
84+
# outputs:
85+
# extension-artifact-name: ${{ steps.upload.outputs.artifact-name }}
86+
# steps:
87+
# - name: Checkout Repo
88+
# uses: actions/checkout@v4
89+
90+
# - name: Cache Maven
91+
# uses: actions/cache@v4
92+
# with:
93+
# path: ~/.m2/repository
94+
# key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
95+
# restore-keys: |
96+
# ${{ runner.os }}-maven-
97+
98+
# - name: Setup Java
99+
# uses: actions/setup-java@v4
100+
# with:
101+
# distribution: 'temurin'
102+
# java-version: '17'
103+
104+
# - name: Build & Test Extension
105+
# run: ./.internal/ci/build-extension.sh
106+
107+
# - name: Upload Extension Jar
108+
# id: upload
109+
# uses: actions/upload-artifact@v4
110+
# with:
111+
# name: keycloak-app-passwords-extension.jar
112+
# path: ./extension/target/keycloak-app-passwords-DEV.jar
113+
114+
# test-e2e:
115+
# name: Test E2E
116+
# runs-on: ubuntu-latest
117+
# needs: [build-theme, build-extension]
118+
# env:
119+
# THEME_PATH: ./keycloak-app-passwords-theme.jar
120+
# EXTENSION_PATH: ./keycloak-app-passwords-extension.jar
121+
# steps:
122+
# - name: Checkout Repo
123+
# uses: actions/checkout@v4
124+
125+
# - name: Download Theme Jar
126+
# uses: actions/download-artifact@v4
127+
# with:
128+
# name: keycloak-app-passwords-theme.jar
129+
# path: ./extenion/keycloak-app-passwords-theme.jar
130+
131+
# - name: Download Extension Jar
132+
# uses: actions/download-artifact@v4
133+
# with:
134+
# name: keycloak-app-passwords-extension.jar
135+
# path: ./extension/keycloak-app-passwords-extension.jar
136+
137+
# - name: Setup OpenLDAP
138+
# run: ./.internal/ci/init-openldap.sh
139+
140+
# - name: Import Data
141+
# run: ./.internal/ci/import-data.sh
142+
143+
# - name: Run Extension
144+
# run: ./.internal/ci/run.sh
145+
146+
# - name: Install E2E
147+
# run: ./.internal/ci/e2e-install.sh
148+
149+
# - name: Test E2E
150+
# run: ./.internal/ci/e2e.sh

.github/workflows/push-main.yml

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
- name: Setup Pyhon
2222
uses: actions/setup-python@v5
2323
with:
24-
python-version: "3.13"
24+
python-version: '3.13'
2525
- name: Install Commitizen
2626
run: ./.internal/ci/install-cz.sh
2727
- name: Determine Next Version
2828
id: next-version
2929
run: echo "version=$(./.internal/ci/version-next.sh)" >> $GITHUB_OUTPUT
3030

31-
build-theme:
32-
name: Build Theme
31+
build-and-test:
32+
name: Build and Test
3333
runs-on: ubuntu-latest
3434
needs: version
3535
if: needs.version.outputs.version != ''
@@ -38,45 +38,57 @@ jobs:
3838
steps:
3939
- name: Checkout Repo
4040
uses: actions/checkout@v4
41+
4142
- name: Cache NPM
4243
uses: actions/cache@v4
4344
with:
4445
path: ~/.npm
4546
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
4647
restore-keys: |
4748
${{ runner.os }}-node-
48-
- name: Setup Node
49-
uses: actions/setup-node@v4
50-
- name: Build
51-
run: ./.internal/ci/build-theme.sh
5249
53-
build-extension:
54-
name: Build Extension
55-
runs-on: ubuntu-latest
56-
needs: version
57-
if: needs.version.outputs.version != ''
58-
steps:
59-
- name: Checkout Repo
60-
uses: actions/checkout@v4
61-
- name: Setup Java
62-
uses: actions/setup-java@v4
63-
with:
64-
distribution: "temurin"
65-
java-version: "17"
6650
- name: Cache Maven
6751
uses: actions/cache@v4
6852
with:
6953
path: ~/.m2/repository
7054
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
7155
restore-keys: |
7256
${{ runner.os }}-maven-
73-
- name: Build & Test
57+
58+
- name: Setup Node
59+
uses: actions/setup-node@v4
60+
61+
- name: Setup Java
62+
uses: actions/setup-java@v4
63+
with:
64+
distribution: 'temurin'
65+
java-version: '17'
66+
67+
- name: Build Theme
68+
run: ./.internal/ci/build-theme.sh
69+
70+
- name: Build & Test Extension
7471
run: ./.internal/ci/build-extension.sh
7572

73+
- name: Setup OpenLDAP
74+
run: ./.internal/ci/init-openldap.sh
75+
76+
- name: Import Data
77+
run: ./.internal/ci/import-data.sh
78+
79+
- name: Run Extension
80+
run: ./.internal/ci/run.sh
81+
82+
- name: Install E2E
83+
run: ./.internal/ci/e2e-install.sh
84+
85+
- name: Test E2E
86+
run: ./.internal/ci/e2e.sh
87+
7688
release:
7789
name: Release
7890
runs-on: ubuntu-latest
79-
needs: [version, build-theme, build-extension]
91+
needs: [version, build-and-test]
8092
if: needs.version.outputs.version != ''
8193
environment: release
8294
permissions:
@@ -96,12 +108,12 @@ jobs:
96108
- name: Setup Java
97109
uses: actions/setup-java@v4
98110
with:
99-
distribution: "temurin"
100-
java-version: "17"
111+
distribution: 'temurin'
112+
java-version: '17'
101113
- name: Setup Pyhon
102114
uses: actions/setup-python@v5
103115
with:
104-
python-version: "3.13"
116+
python-version: '3.13'
105117
- name: Install Commitizen
106118
run: ./.internal/ci/install-cz.sh
107119
- name: Bump Version

.internal/ci/build-extension.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22

33
cd extension
4-
make
4+
make build-dev

.internal/ci/e2e-install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
cd e2e
4+
npm install

.internal/ci/e2e.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env
2+
3+
cd e2e
4+
5+
echo "Waiting for Keycloak to be ready..."
6+
for i in {1..30}; do
7+
if curl -sSf http://localhost:8080/ > /dev/null; then
8+
echo "localhost:8080 is ready!"
9+
break
10+
fi
11+
echo "Waiting... ($i)"
12+
sleep 1
13+
done
14+
15+
npm test

.internal/ci/import-data.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
cd extension
4+
./.internal/scripts/import.sh

.internal/ci/init-openldap.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
cd extension
4+
5+
docker compose up -d openldap
6+
7+
echo "Waiting for LDAP to be ready..."
8+
for i in {1..30}; do
9+
if docker exec openldap ldapsearch -Y EXTERNAL -H ldapi:/// -b "dc=example,dc=org" >/dev/null 2>&1; then
10+
echo "LDAP is ready!"
11+
break
12+
fi
13+
echo "Waiting for LDAP... ($i)"
14+
sleep 1
15+
done
16+
17+
docker exec openldap sh -c 'cd /tmp/ldapscripts && sh add-schema.sh'

.internal/ci/run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
cd extension
4+
5+
docker compose up -d

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false,
4+
"trailingComma": "all",
5+
"tabWidth": 2
6+
}

e2e/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

0 commit comments

Comments
 (0)