Skip to content

Commit 65336ff

Browse files
authored
Add external auth e2e coverage (#457)
* add external auth e2e coverage * keep local e2e auth tests opt-in * cover external auth failure cases
1 parent 43e1795 commit 65336ff

5 files changed

Lines changed: 391 additions & 5 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ jobs:
4848
timeout-minutes: 30
4949

5050
env:
51-
KITE_E2E_CLUSTER_NAME: kite-e2e
52-
KUBECONFIG: ${{ github.workspace }}/kite-e2e.kubeconfig
51+
E2E_KIND_NAME: kite-e2e
52+
E2E_KUBECONFIG: ${{ github.workspace }}/kite-e2e.kubeconfig
5353
KIND_LOGS_DIR: ${{ github.workspace }}/kind-logs
54-
KITE_E2E_PORT: "38080"
54+
E2E_PORT: "38080"
55+
KITE_E2E_LDAP_URL: ldap://127.0.0.1:3389
56+
KITE_E2E_OAUTH_ISSUER: http://127.0.0.1:5556
5557

5658
steps:
5759
- name: Checkout code
@@ -87,12 +89,24 @@ jobs:
8789
chmod +x ./kind
8890
sudo mv ./kind /usr/local/bin/kind
8991
92+
- name: Start OpenLDAP
93+
run: make e2e-setup-ldap
94+
95+
- name: Start Dex
96+
run: make e2e-setup-dex
97+
9098
- name: Run E2E tests
9199
run: make e2e-test
92100

93101
- name: Export kind logs
94102
if: always()
95-
run: kind export logs "${KIND_LOGS_DIR}" --name "${KITE_E2E_CLUSTER_NAME}"
103+
run: kind export logs "${KIND_LOGS_DIR}" --name "${E2E_KIND_NAME}"
104+
105+
- name: Collect external auth logs
106+
if: always()
107+
run: |
108+
docker logs kite-e2e-ldap > "${GITHUB_WORKSPACE}/kite-e2e-ldap.log" 2>&1 || true
109+
docker logs kite-e2e-dex > "${GITHUB_WORKSPACE}/kite-e2e-dex.log" 2>&1 || true
96110
97111
- name: Upload E2E artifacts
98112
if: always()
@@ -103,3 +117,5 @@ jobs:
103117
e2e/playwright-report
104118
e2e/test-results
105119
${{ env.KIND_LOGS_DIR }}
120+
${{ github.workspace }}/kite-e2e-ldap.log
121+
${{ github.workspace }}/kite-e2e-dex.log

Makefile

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Makefile for Kite project
2-
.PHONY: help dev build clean test docker-build docker-run frontend backend install deps e2e-install e2e-kind-up e2e-kind-down e2e-stop-app e2e-test e2e-test-headed
2+
.PHONY: help dev build clean test docker-build docker-run frontend backend install deps e2e-install e2e-kind-up e2e-kind-down e2e-stop-app e2e-setup-ldap e2e-setup-dex e2e-test e2e-test-headed
33

44
# Variables
55
BINARY_NAME=kite
@@ -10,6 +10,11 @@ DOCKER_TAG=latest
1010
E2E_KIND_NAME ?= kite-e2e
1111
E2E_PORT ?= 38080
1212
E2E_KUBECONFIG ?= $(shell printf '%s' "$${TMPDIR:-/tmp/}kite-e2e.kubeconfig")
13+
E2E_AUTH_NETWORK ?= kite-e2e-auth
14+
E2E_LDAP_CONTAINER ?= kite-e2e-ldap
15+
E2E_LDAP_PORT ?= 3389
16+
E2E_DEX_CONTAINER ?= kite-e2e-dex
17+
E2E_OAUTH_PORT ?= 5556
1318
SPEC ?=
1419

1520
# Version information
@@ -172,6 +177,44 @@ e2e-stop-app: ## Stop any local e2e app process listening on the e2e port
172177
sleep 1; \
173178
fi
174179

180+
e2e-setup-ldap: ## Start the OpenLDAP service used by external-auth e2e
181+
@docker network inspect "$(E2E_AUTH_NETWORK)" >/dev/null 2>&1 || docker network create "$(E2E_AUTH_NETWORK)" >/dev/null
182+
@docker rm -f "$(E2E_LDAP_CONTAINER)" >/dev/null 2>&1 || true
183+
docker run -d --name "$(E2E_LDAP_CONTAINER)" \
184+
--network "$(E2E_AUTH_NETWORK)" \
185+
--network-alias ldap \
186+
-p "$(E2E_LDAP_PORT):389" \
187+
-e LDAP_ORGANISATION="Kite E2E" \
188+
-e LDAP_DOMAIN="kite.test" \
189+
-e LDAP_ADMIN_PASSWORD="admin" \
190+
-e LDAP_CONFIG_PASSWORD="admin" \
191+
-e LDAP_TLS="false" \
192+
-v "$(CURDIR)/e2e/fixtures/openldap:/container/service/slapd/assets/config/bootstrap/ldif/custom:ro" \
193+
osixia/openldap:1.5.0 --copy-service
194+
@for i in $$(seq 1 60); do \
195+
if docker exec "$(E2E_LDAP_CONTAINER)" ldapsearch -x -H ldap://localhost:389 -b dc=kite,dc=test -D "cn=admin,dc=kite,dc=test" -w admin >/dev/null 2>&1; then \
196+
break; \
197+
fi; \
198+
sleep 1; \
199+
done
200+
docker exec "$(E2E_LDAP_CONTAINER)" ldapsearch -x -H ldap://localhost:389 -b dc=kite,dc=test -D "cn=admin,dc=kite,dc=test" -w admin >/dev/null
201+
202+
e2e-setup-dex: ## Start the Dex service used by external-auth e2e
203+
@docker network inspect "$(E2E_AUTH_NETWORK)" >/dev/null 2>&1 || docker network create "$(E2E_AUTH_NETWORK)" >/dev/null
204+
@docker rm -f "$(E2E_DEX_CONTAINER)" >/dev/null 2>&1 || true
205+
docker run -d --name "$(E2E_DEX_CONTAINER)" \
206+
--network "$(E2E_AUTH_NETWORK)" \
207+
-p "$(E2E_OAUTH_PORT):5556" \
208+
-v "$(CURDIR)/e2e/fixtures/dex/config.yaml:/etc/dex/config.yaml:ro" \
209+
ghcr.io/dexidp/dex:v2.45.1 dex serve /etc/dex/config.yaml
210+
@for i in $$(seq 1 60); do \
211+
if curl -fsS "http://127.0.0.1:$(E2E_OAUTH_PORT)/.well-known/openid-configuration" >/dev/null; then \
212+
break; \
213+
fi; \
214+
sleep 1; \
215+
done
216+
curl -fsS "http://127.0.0.1:$(E2E_OAUTH_PORT)/.well-known/openid-configuration" >/dev/null
217+
175218
e2e-test: e2e-install e2e-kind-up e2e-stop-app ## Run e2e tests against the local kind cluster
176219
@echo "🧪 Running e2e tests..."
177220
cd $(E2E_DIR) && KUBECONFIG="$(E2E_KUBECONFIG)" KITE_E2E_CLUSTER_NAME="$(E2E_KIND_NAME)" KITE_E2E_PORT="$(E2E_PORT)" pnpm exec playwright test $(SPEC)

e2e/fixtures/dex/config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
issuer: http://127.0.0.1:5556
2+
storage:
3+
type: memory
4+
web:
5+
http: 0.0.0.0:5556
6+
oauth2:
7+
skipApprovalScreen: true
8+
staticClients:
9+
- id: kite-e2e
10+
secret: kite-e2e-secret
11+
name: Kite E2E
12+
redirectURIs:
13+
- http://127.0.0.1:38080/api/auth/callback
14+
connectors:
15+
- type: ldap
16+
id: ldap
17+
name: LDAP
18+
config:
19+
host: ldap:389
20+
insecureNoSSL: true
21+
bindDN: cn=admin,dc=kite,dc=test
22+
bindPW: admin
23+
usernamePrompt: Username
24+
userSearch:
25+
baseDN: ou=users,dc=kite,dc=test
26+
filter: "(objectClass=inetOrgPerson)"
27+
username: uid
28+
idAttr: uid
29+
emailAttr: mail
30+
nameAttr: cn
31+
preferredUsernameAttr: uid
32+
groupSearch:
33+
baseDN: ou=groups,dc=kite,dc=test
34+
filter: "(objectClass=groupOfNames)"
35+
userMatchers:
36+
- userAttr: DN
37+
groupAttr: member
38+
nameAttr: cn
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
dn: ou=users,{{ LDAP_BASE_DN }}
2+
objectClass: organizationalUnit
3+
ou: users
4+
5+
dn: ou=groups,{{ LDAP_BASE_DN }}
6+
objectClass: organizationalUnit
7+
ou: groups
8+
9+
dn: uid=ldap-e2e,ou=users,{{ LDAP_BASE_DN }}
10+
objectClass: inetOrgPerson
11+
objectClass: organizationalPerson
12+
objectClass: person
13+
objectClass: top
14+
uid: ldap-e2e
15+
cn: LDAP E2E
16+
sn: LDAP
17+
mail: ldap-e2e@kite.test
18+
userPassword: KiteLDAP!2345
19+
20+
dn: uid=oauth-e2e,ou=users,{{ LDAP_BASE_DN }}
21+
objectClass: inetOrgPerson
22+
objectClass: organizationalPerson
23+
objectClass: person
24+
objectClass: top
25+
uid: oauth-e2e
26+
cn: OAuth E2E
27+
sn: OAuth
28+
mail: oauth-e2e@kite.test
29+
userPassword: KiteOAuth!2345
30+
31+
dn: uid=oauth-no-group,ou=users,{{ LDAP_BASE_DN }}
32+
objectClass: inetOrgPerson
33+
objectClass: organizationalPerson
34+
objectClass: person
35+
objectClass: top
36+
uid: oauth-no-group
37+
cn: OAuth No Group
38+
sn: OAuth
39+
mail: oauth-no-group@kite.test
40+
userPassword: KiteOAuthNoGroup!2345
41+
42+
dn: cn=e2e-viewers,ou=groups,{{ LDAP_BASE_DN }}
43+
objectClass: groupOfNames
44+
cn: e2e-viewers
45+
member: uid=ldap-e2e,ou=users,{{ LDAP_BASE_DN }}
46+
member: uid=oauth-e2e,ou=users,{{ LDAP_BASE_DN }}

0 commit comments

Comments
 (0)