Skip to content

Commit 6f20c12

Browse files
committed
test: add e2e tests
1 parent 1b94a38 commit 6f20c12

File tree

25 files changed

+2621
-68
lines changed

25 files changed

+2621
-68
lines changed

.github/workflows/pull-request.yml

Lines changed: 68 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,95 @@ 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: Upload Theme Jar
56+
id: upload
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: keycloak-app-passwords-theme.jar
60+
path: ./theme/dist_keycloak/keycloak-theme-for-kc-all-other-versions.jar
61+
4962
build-extension:
5063
name: Build Extension
5164
runs-on: ubuntu-latest
65+
outputs:
66+
extension-artifact-name: ${{ steps.upload.outputs.artifact-name }}
5267
steps:
5368
- name: Checkout Repo
5469
uses: actions/checkout@v4
70+
5571
- name: Cache Maven
5672
uses: actions/cache@v4
5773
with:
5874
path: ~/.m2/repository
5975
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
6076
restore-keys: |
6177
${{ runner.os }}-maven-
78+
6279
- name: Setup Java
6380
uses: actions/setup-java@v4
6481
with:
65-
distribution: "temurin"
66-
java-version: "17"
67-
- name: Build & Test
82+
distribution: 'temurin'
83+
java-version: '17'
84+
85+
- name: Build & Test Extension
6886
run: ./.internal/ci/build-extension.sh
87+
88+
- name: Upload Extension Jar
89+
id: upload
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: keycloak-app-passwords-extension.jar
93+
path: ./extension/target/keycloak-app-passwords-DEV.jar
94+
95+
test-e2e:
96+
name: Test E2E
97+
runs-on: ubuntu-latest
98+
needs: [build-theme, build-extension]
99+
env:
100+
THEME_PATH: ./keycloak-app-passwords-theme.jar
101+
EXTENSION_PATH: ./keycloak-app-passwords-extension.jar
102+
steps:
103+
- name: Checkout Repo
104+
uses: actions/checkout@v4
105+
106+
- name: Download Theme Jar
107+
uses: actions/download-artifact@v4
108+
with:
109+
name: keycloak-app-passwords-theme.jar
110+
path: ./extension
111+
112+
- name: Download Extension Jar
113+
uses: actions/download-artifact@v4
114+
with:
115+
name: keycloak-app-passwords-extension.jar
116+
path: ./extension
117+
118+
- name: Setup OpenLDAP
119+
run: ./.internal/ci/init-openldap.sh
120+
121+
- name: Import Data
122+
run: ./.internal/ci/import-data.sh
123+
124+
- name: Run Extension
125+
run: ./.internal/ci/run.sh
126+
127+
- name: Install E2E
128+
run: ./.internal/ci/e2e-install.sh
129+
130+
- name: Test E2E
131+
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: 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+
ls -alR
5+
./.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: 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)