Skip to content

Commit 2a43c59

Browse files
committed
More tests for authentication.
1 parent a992859 commit 2a43c59

File tree

6 files changed

+200
-218
lines changed

6 files changed

+200
-218
lines changed

charts/eoapi/profiles/experimental.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,14 @@ stac-auth-proxy:
371371
enabled: true
372372
service:
373373
port: 8080
374-
# Wait for mock-oidc to be ready in testing scenarios
374+
# Wait for dependencies to be ready before starting stac-auth-proxy
375375
initContainers:
376376
- name: wait-for-mock-oidc
377377
image: busybox:1.35
378378
command: ['sh', '-c', 'until nc -z eoapi-mock-oidc-server.eoapi.svc.cluster.local 8080; do echo waiting for mock-oidc; sleep 2; done']
379+
- name: wait-for-stac
380+
image: busybox:1.35
381+
command: ['sh', '-c', 'until nc -z eoapi-stac.eoapi.svc.cluster.local 8080; do echo waiting for stac service; sleep 2; done']
379382
env:
380383
UPSTREAM_URL: "http://eoapi-stac:8080"
381384
# For testing one could deploy a mock OIDC server (https://github.com/alukach/mock-oidc-server)

charts/eoapi/templates/core/stac-auth-proxy-patch.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ spec:
2727
- name: patch-deployment
2828
image: bitnami/kubectl:latest
2929
imagePullPolicy: IfNotPresent
30+
# Use python3 for JSON manipulation (bitnami/kubectl includes python3)
3031
command:
3132
- /bin/bash
3233
- -c
@@ -45,7 +46,8 @@ spec:
4546
exit 0
4647
fi
4748
echo "Patching deployment with initContainers..."
48-
INIT_CONTAINERS_JSON='{{ index .Values "stac-auth-proxy" "initContainers" | toJson }}'
49+
# Use Helm templating to replace service names in the JSON string
50+
INIT_CONTAINERS_JSON='{{ index .Values "stac-auth-proxy" "initContainers" | toJson | replace "eoapi-stac.eoapi" (printf "%s-stac.%s" .Release.Name .Release.Namespace) | replace "eoapi-mock-oidc-server.eoapi" (printf "%s-mock-oidc-server.%s" .Release.Name .Release.Namespace) }}'
4951
kubectl patch deployment "$DEPLOYMENT_NAME" -n "$NAMESPACE" --type='json' -p="[{\"op\":\"add\",\"path\":\"/spec/template/spec/initContainers\",\"value\":$INIT_CONTAINERS_JSON}]"
5052
echo "Waiting for rollout..."
5153
kubectl rollout status deployment/"$DEPLOYMENT_NAME" -n "$NAMESPACE" --timeout=300s

scripts/deploy.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,13 @@ deploy_eoapi() {
393393

394394
# Set UPSTREAM_URL and OIDC_DISCOVERY_URL dynamically for stac-auth-proxy when experimental profile is used
395395
# The experimental profile enables stac-auth-proxy, so we need to set the correct service names
396+
# Also configure STAC service to run without root path when behind auth proxy
396397
HELM_CMD="$HELM_CMD --set stac-auth-proxy.env.UPSTREAM_URL=http://$RELEASE_NAME-stac:8080"
397398
HELM_CMD="$HELM_CMD --set stac-auth-proxy.env.OIDC_DISCOVERY_URL=http://$RELEASE_NAME-mock-oidc-server.$NAMESPACE.svc.cluster.local:8080/.well-known/openid-configuration"
399+
# Note: initContainer service names are dynamically replaced by the stac-auth-proxy-patch job
400+
# Configure STAC service to run without root path when behind auth proxy
401+
# Empty string makes STAC service run at root path (no --root-path argument)
402+
HELM_CMD="$HELM_CMD --set 'stac.overrideRootPath='"
398403

399404
HELM_CMD="$HELM_CMD --set eoapi-notifier.enabled=true"
400405
HELM_CMD="$HELM_CMD --set eoapi-notifier.config.sources[0].config.connection.existingSecret.name=$RELEASE_NAME-pguser-eoapi"

scripts/deployment.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,14 @@ run_deployment() {
8686

8787
# Set UPSTREAM_URL and OIDC_DISCOVERY_URL dynamically for stac-auth-proxy when experimental profile is used
8888
# The experimental profile enables stac-auth-proxy, so we need to set the correct service names
89+
# Also configure STAC service to run without root path when behind auth proxy
8990
if [[ "$use_experimental" == "true" ]]; then
9091
helm_cmd="$helm_cmd --set stac-auth-proxy.env.UPSTREAM_URL=http://$RELEASE_NAME-stac:8080"
9192
helm_cmd="$helm_cmd --set stac-auth-proxy.env.OIDC_DISCOVERY_URL=http://$RELEASE_NAME-mock-oidc-server.$NAMESPACE.svc.cluster.local:8080/.well-known/openid-configuration"
93+
# Note: initContainer service names are dynamically replaced by the stac-auth-proxy-patch job
94+
# Configure STAC service to run without root path when behind auth proxy
95+
# Empty string makes STAC service run at root path (no --root-path argument)
96+
helm_cmd="$helm_cmd --set 'stac.overrideRootPath='"
9297
fi
9398

9499
if is_ci; then

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111

1212
@pytest.fixture(scope="session")
1313
def raster_endpoint() -> str:
14-
return os.getenv("RASTER_ENDPOINT", "http://127.0.0.1/raster")
14+
return os.getenv("RASTER_ENDPOINT", "http://localhost/raster")
1515

1616

1717
@pytest.fixture(scope="session")
1818
def vector_endpoint() -> str:
19-
return os.getenv("VECTOR_ENDPOINT", "http://127.0.0.1/vector")
19+
return os.getenv("VECTOR_ENDPOINT", "http://localhost/vector")
2020

2121

2222
@pytest.fixture(scope="session")
2323
def stac_endpoint() -> str:
24-
return os.getenv("STAC_ENDPOINT", "http://127.0.0.1/stac")
24+
return os.getenv("STAC_ENDPOINT", "http://localhost/stac")
2525

2626

2727
def get_namespace() -> str:

0 commit comments

Comments
 (0)