aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2015-08-19 10:52:20 -0500
committerAndy Doan <andy.doan@linaro.org>2015-08-19 10:52:20 -0500
commit57c8878f3fefc5d8d483b19d0a04e1547958ef23 (patch)
treea0d526e93959ef5cd1fa2964617e2f19eadae6ed
parente7bda062601c0c64c7630050eeada9c5d4bc62f9 (diff)
downloadlinaro-license-protection-57c8878f3fefc5d8d483b19d0a04e1547958ef23.tar.gz
regression: fix accept license redirection
Normal behavior of l-l-p when clicking a protected file is: 1) go to license accept 2) accept 3) get dir-listing page with "refresh" header pointing at file 4) page will refresh to automatically download file Commit: 65cd78e65b1bfb7836f170bc3b4af58a02a5b075 broke this function. Step 3 just gave the user a standard directory listing and they had to click the file to download. Additionally, the unit test failed to test item #3. This fixes the issue, and fixes the test. Change-Id: I1aa223766148b132919c5bf383589911f8363cad
-rw-r--r--license_protected_downloads/tests/test_views.py9
-rw-r--r--license_protected_downloads/views.py9
2 files changed, 11 insertions, 7 deletions
diff --git a/license_protected_downloads/tests/test_views.py b/license_protected_downloads/tests/test_views.py
index 6cf7674..3d6e872 100644
--- a/license_protected_downloads/tests/test_views.py
+++ b/license_protected_downloads/tests/test_views.py
@@ -325,10 +325,15 @@ class ViewTests(BaseServeViewTest):
# cookies from the current session, and re-introduce them.
client = Client()
client.cookies[accept_cookie_name] = accept_cookie_name
- response = client.get(url)
+ response = client.get(response['Location'])
- # If we have access to the file, we will get an X-Sendfile response
+ # If we have access to the file, we get a page with "refresh" directive
self.assertEqual(response.status_code, 200)
+ self.assertIn(
+ '<meta http-equiv="REFRESH" content="0;url=', response.content)
+
+ # now download the file
+ response = client.get(url)
file_path = os.path.join(TESTSERVER_ROOT, target_file)
self.assertEqual(response['X-Sendfile'], file_path)
diff --git a/license_protected_downloads/views.py b/license_protected_downloads/views.py
index 5bcd6ee..e5a87cc 100644
--- a/license_protected_downloads/views.py
+++ b/license_protected_downloads/views.py
@@ -154,7 +154,10 @@ def _check_build_info(request, build_info):
def _handle_dir_list(request, artifact):
- if request.path[-1] != '/':
+ download = None
+ if 'dl' in request.GET:
+ download = request.GET['dl']
+ elif request.path[-1] != '/':
return redirect(request.path + '/')
# Generate a link to the parent directory (if one exists)
@@ -172,10 +175,6 @@ def _handle_dir_list(request, artifact):
# must come before call to find_and_render to optimize s3
dirlist = dir_list(artifact)
-
- download = None
- if 'dl' in request.GET:
- download = request.GET['dl']
rendered_files = RenderTextFiles.find_and_render(artifact)
ann = artifact.get_annotated_manifest()
if ann: