Skip to content

Commit 7381430

Browse files
Merge pull request #215 from scality/PTFE-3070-resolve-redirection-web-ui
(PTFE-3070) Fix redirection web ui
2 parents 00cc706 + 32a3c67 commit 7381430

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

conf/nginx.conf.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ http {
271271
# Directory listings (trailing slash) always go to /download/.
272272
# $builds_backend is set by the map directive in the http block above.
273273
#
274-
rewrite ^/builds/([^/]+/.+[^/])$ $builds_backend$1 last;
274+
if ($builds_backend = /redirect/) {
275+
rewrite ^/builds/([^/]+/.+[^/])$ /redirect/$1 last;
276+
}
275277
rewrite ^/builds/(.*)$ /download/$1 last;
276278

277279
# Handle subdir listing under "/redirect/"

tests/end2end/test_routing.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,19 @@ def test_builds_cli_ua_redirects_to_presigned_url(upload_file, session, artifact
8686

8787

8888
def test_builds_browser_ua_proxied_directly(upload_file, session, artifacts_url):
89-
"""GET /builds/ with a Mozilla UA is rewritten to /download/ → 200 proxied."""
90-
upload_file(STAGING_BUILD, 'file.txt')
89+
"""GET /builds/ with a Mozilla UA is rewritten to /download/ → 200 proxied.
90+
91+
The response body must be the file content, not an HTML directory listing.
92+
"""
93+
data = b'browser-proxied content'
94+
upload_file(STAGING_BUILD, 'file.txt', data=data)
9195
resp = session.get(
9296
f'{artifacts_url}/builds/{STAGING_BUILD}/file.txt',
9397
headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64)'},
9498
allow_redirects=False,
9599
)
96100
assert resp.status_code == 200
101+
assert resp.content == data
97102

98103

99104
def test_builds_head_always_proxied_regardless_of_ua(upload_file, session, artifacts_url):

0 commit comments

Comments
 (0)