From 1e82f47d22bc54ee66192accc733d2d7f064de42 Mon Sep 17 00:00:00 2001 From: George J Padayatti Date: Tue, 9 Jan 2024 14:31:47 +0530 Subject: [PATCH] Fix: Modify Caddyfile and configuration in runtime to support http://caddy:80 route for docker services without Authorization header Signed-off-by: George J Padayatti --- Makefile | 3 --- behave.ini | 2 +- fixtures/main.py | 9 ++++++--- test/Caddyfile | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a7abcc8..58cfb97 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,6 @@ build-test: ## Build behave image run-test: ## Run BDD test docker run --network=test_custom_network igrantio/bb-consent-test-runner:dev -run-test-behave: - behave - setup-dev: ## Setup api, admin and privacy dashboard for development branch tests sudo rm -rf temp && \ mkdir temp && \ diff --git a/behave.ini b/behave.ini index 4d8c675..b29223f 100644 --- a/behave.ini +++ b/behave.ini @@ -2,6 +2,6 @@ paths = features/ [behave.userdata] -base_url = http://localhost:3333 +base_url = http://caddy:80 username = admin@skatteverket.se password = qwerty123 \ No newline at end of file diff --git a/fixtures/main.py b/fixtures/main.py index d432869..6ce121e 100644 --- a/fixtures/main.py +++ b/fixtures/main.py @@ -123,7 +123,8 @@ def login_individual(host, port, username, password): def update_caddy_configuration(org_admin_token, individual_token): # Caddy API endpoint URL - url = f"http://{caddy_host}:{caddy_port}/config/apps/http/servers/srv0/routes/0/handle/0/routes/0" + url0 = f"http://{caddy_host}:{caddy_port}/config/apps/http/servers/srv0/routes/0/handle/0/routes/0" + url1 = f"http://{caddy_host}:{caddy_port}/config/apps/http/servers/srv0/routes/1/handle/0/routes/0" # Caddy API request payload payload = { @@ -147,7 +148,8 @@ def update_caddy_configuration(org_admin_token, individual_token): } # Send a request to Caddy API to update the configuration - requests.put(url, json=payload) + requests.put(url0, json=payload) + requests.put(url1, json=payload) # Caddy API request payload payload = { @@ -161,7 +163,8 @@ def update_caddy_configuration(org_admin_token, individual_token): } # Send a request to Caddy API to update the configuration - requests.put(url, json=payload) + requests.put(url0, json=payload) + requests.put(url1, json=payload) def populate_individuals(db): diff --git a/test/Caddyfile b/test/Caddyfile index 89f3ebf..328b9a0 100644 --- a/test/Caddyfile +++ b/test/Caddyfile @@ -2,6 +2,22 @@ admin 0.0.0.0:2019 } +http://caddy:80 { + @api { + path /* + } + + reverse_proxy @api { + to http://api:80 + } + + # Log all requests to stdout for Docker logs + log { + output stdout + level DEBUG + } +} + http://localhost:80 { @api { path /*