Skip to content

Commit 445a5aa

Browse files
committed
test: add e2e tests
1 parent 1b94a38 commit 445a5aa

File tree

26 files changed

+2649
-71
lines changed

26 files changed

+2649
-71
lines changed

.github/workflows/pull-request.yml

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ jobs:
1919
uses: actions/checkout@v4
2020
with:
2121
fetch-depth: 0
22+
2223
- name: Setup Pyhon
2324
uses: actions/setup-python@v5
2425
with:
25-
python-version: "3.13"
26+
python-version: '3.13'
27+
2628
- name: Install Commitizen
2729
run: ./.internal/ci/install-cz.sh
30+
2831
- name: Check Commits
2932
run: ./.internal/ci/version-check.sh
3033

@@ -34,35 +37,115 @@ jobs:
3437
steps:
3538
- name: Checkout Repo
3639
uses: actions/checkout@v4
40+
3741
- name: Cache NPM
3842
uses: actions/cache@v4
3943
with:
4044
path: ~/.npm
4145
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
4246
restore-keys: |
4347
${{ runner.os }}-node-
48+
4449
- name: Setup Node
4550
uses: actions/setup-node@v4
46-
- name: Build
51+
52+
- name: Build Theme
4753
run: ./.internal/ci/build-theme.sh
4854

55+
- name: Rename Jar
56+
run: |
57+
mv ./theme/dist_keycloak/keycloak-theme-for-kc-all-other-versions.jar ./keycloak-app-passwords-theme.jar
58+
59+
- name: Upload Jar
60+
id: upload
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: theme
64+
path: ./keycloak-app-passwords-theme.jar
65+
4966
build-extension:
5067
name: Build Extension
5168
runs-on: ubuntu-latest
69+
outputs:
70+
extension-artifact-name: ${{ steps.upload.outputs.artifact-name }}
5271
steps:
5372
- name: Checkout Repo
5473
uses: actions/checkout@v4
74+
5575
- name: Cache Maven
5676
uses: actions/cache@v4
5777
with:
5878
path: ~/.m2/repository
5979
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
6080
restore-keys: |
6181
${{ runner.os }}-maven-
82+
6283
- name: Setup Java
6384
uses: actions/setup-java@v4
6485
with:
65-
distribution: "temurin"
66-
java-version: "17"
67-
- name: Build & Test
86+
distribution: 'temurin'
87+
java-version: '17'
88+
89+
- name: Build & Test Extension
6890
run: ./.internal/ci/build-extension.sh
91+
92+
- name: Rename Jar
93+
run: |
94+
mv ./extension/target/keycloak-app-passwords-DEV.jar ./keycloak-app-passwords-extension.jar
95+
96+
- name: Upload Jar
97+
id: upload
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: extension
101+
path: ./keycloak-app-passwords-extension.jar
102+
103+
test-e2e:
104+
name: Test E2E
105+
runs-on: ubuntu-latest
106+
needs: [build-theme, build-extension]
107+
env:
108+
THEME_PATH: ./keycloak-app-passwords-theme.jar
109+
EXTENSION_PATH: ./keycloak-app-passwords-extension.jar
110+
CONFIG_PATH: ./keycloak-app-passwords.config.json
111+
steps:
112+
- name: Checkout Repo
113+
uses: actions/checkout@v4
114+
115+
- name: Cache NPM
116+
uses: actions/cache@v4
117+
with:
118+
path: ~/.npm
119+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
120+
restore-keys: |
121+
${{ runner.os }}-node-
122+
123+
- name: Setup Node
124+
uses: actions/setup-node@v4
125+
126+
- name: Download Theme Jar
127+
uses: actions/download-artifact@v4
128+
with:
129+
name: theme
130+
path: ./extension
131+
132+
- name: Download Extension Jar
133+
uses: actions/download-artifact@v4
134+
with:
135+
name: extension
136+
path: ./extension
137+
138+
- name: Setup OpenLDAP
139+
run: ./.internal/ci/init-openldap.sh
140+
141+
- name: Import Data
142+
run: ./.internal/ci/import-data.sh
143+
144+
- name: Run Extension
145+
run: ./.internal/ci/run.sh
146+
147+
- name: Install E2E
148+
run: ./.internal/ci/e2e-install.sh
149+
150+
- name: Test E2E
151+
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
cd extension
4+
mkdir -p ./.internal/data
5+
chmod 777 ./.internal/data
6+
ls -lahR ./
7+
./.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" '(objectClass=*)' dn >/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: 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+
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)