Skip to content

Commit

Permalink
Fix: Modify Caddyfile and configuration in runtime to support http://…
Browse files Browse the repository at this point in the history
…caddy:80 route for docker services without Authorization header

Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed Jan 9, 2024
1 parent 4a7d058 commit 1e82f47
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
2 changes: 1 addition & 1 deletion behave.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
paths = features/

[behave.userdata]
base_url = http://localhost:3333
base_url = http://caddy:80
username = [email protected]
password = qwerty123
9 changes: 6 additions & 3 deletions fixtures/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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):
Expand Down
16 changes: 16 additions & 0 deletions test/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 /*
Expand Down

0 comments on commit 1e82f47

Please sign in to comment.