Merge lp:~dooferlad/linaro-license-protection/files_default_protected into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by James Tunnicliffe
Status: Merged
Approved by: Stevan Radaković
Approved revision: 108
Merged at revision: 109
Proposed branch: lp:~dooferlad/linaro-license-protection/files_default_protected
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 121 lines (+69/-3)
4 files modified
license_protected_downloads/tests/test_views.py (+34/-0)
license_protected_downloads/tests/testserver_root/partial-license-settings/partially-complete-build-info/BUILD-INFO.txt (+13/-0)
license_protected_downloads/views.py (+9/-3)
sampleroot/partial-license-settings/partially-complete-build-info/BUILD-INFO.txt (+13/-0)
To merge this branch: bzr merge lp:~dooferlad/linaro-license-protection/files_default_protected
Reviewer Review Type Date Requested Status
Stevan Radaković Approve
Review via email: mp+120773@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stevan Radaković (stevanr) wrote :

Looks good.
Approve +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'license_protected_downloads/tests/test_views.py'
--- license_protected_downloads/tests/test_views.py 2012-08-20 15:41:26 +0000
+++ license_protected_downloads/tests/test_views.py 2012-08-22 13:37:44 +0000
@@ -411,5 +411,39 @@
411 # If a build-info file is invalid, we don't allow access411 # If a build-info file is invalid, we don't allow access
412 self.assertEqual(response.status_code, 403)412 self.assertEqual(response.status_code, 403)
413413
414 def test_partial_build_info_file_open(self):
415 target_file = ("partial-license-settings/"
416 "partially-complete-build-info/"
417 "should_be_open.txt")
418 url = urlparse.urljoin("http://testserver/", target_file)
419 response = self.client.get(url, follow=True)
420
421 # If a build-info file specifies this file is open
422 self.assertEqual(response.status_code, 200)
423
424 def test_partial_build_info_file_protected(self):
425 target_file = ("partial-license-settings/"
426 "partially-complete-build-info/"
427 "should_be_protected.txt")
428 file_path = os.path.join(TESTSERVER_ROOT, target_file)
429 build_info = BuildInfo(file_path)
430
431 # Try to fetch file from server - we should be redirected
432 url = urlparse.urljoin("http://testserver/", target_file)
433 response = self.client.get(url, follow=True)
434 digest = hashlib.md5(build_info.get("license-text")).hexdigest()
435 self.assertRedirects(response, '/license?lic=%s&url=%s' %
436 (digest, target_file))
437
438 def test_partial_build_info_file_unspecified(self):
439 target_file = ("partial-license-settings/"
440 "partially-complete-build-info/"
441 "should_be_inaccessible.txt")
442 url = urlparse.urljoin("http://testserver/", target_file)
443 response = self.client.get(url, follow=True)
444
445 # If a build-info file has no information about this file
446 self.assertEqual(response.status_code, 403)
447
414if __name__ == '__main__':448if __name__ == '__main__':
415 unittest.main()449 unittest.main()
416450
=== added directory 'license_protected_downloads/tests/testserver_root/partial-license-settings'
=== added directory 'license_protected_downloads/tests/testserver_root/partial-license-settings/partially-complete-build-info'
=== added file 'license_protected_downloads/tests/testserver_root/partial-license-settings/partially-complete-build-info/BUILD-INFO.txt'
--- license_protected_downloads/tests/testserver_root/partial-license-settings/partially-complete-build-info/BUILD-INFO.txt 1970-01-01 00:00:00 +0000
+++ license_protected_downloads/tests/testserver_root/partial-license-settings/partially-complete-build-info/BUILD-INFO.txt 2012-08-22 13:37:44 +0000
@@ -0,0 +1,13 @@
1Format-Version: 0.1
2
3Files-Pattern: *protected*
4Build-Name: landing-multi-license
5Theme: samsung
6License-Type: protected
7License-Text: <p>IMPORTANT — PLEASE READ THE FOLLOWING AGREEMENT CAREFULLY.</p>
8 <p>
9 </p>
10
11Files-Pattern: *open*
12Build-Name: false-positive
13License-Type: open
014
=== added file 'license_protected_downloads/tests/testserver_root/partial-license-settings/partially-complete-build-info/should_be_inaccessible.txt'
=== added file 'license_protected_downloads/tests/testserver_root/partial-license-settings/partially-complete-build-info/should_be_open.txt'
=== added file 'license_protected_downloads/tests/testserver_root/partial-license-settings/partially-complete-build-info/should_be_protected.txt'
=== modified file 'license_protected_downloads/views.py'
--- license_protected_downloads/views.py 2012-08-20 15:41:26 +0000
+++ license_protected_downloads/views.py 2012-08-22 13:37:44 +0000
@@ -177,7 +177,11 @@
177177
178 digests = []178 digests = []
179179
180 if license_type and license_type != "open":180 if license_type:
181 if license_type == "open":
182 return "OPEN"
183
184 # File matches a license, isn't open.
181 if openid_teams:185 if openid_teams:
182 return "OPEN"186 return "OPEN"
183 elif license_text:187 elif license_text:
@@ -189,9 +193,11 @@
189 digests.append(digest)193 digests.append(digest)
190 _insert_license_into_db(digest, license_text, theme)194 _insert_license_into_db(digest, license_text, theme)
191 else:195 else:
192 return None196 # No license text - file as inaccessible.
197 return []
193 else:198 else:
194 return "OPEN"199 # No license found - file is inaccessible.
200 return []
195201
196 return digests202 return digests
197203
198204
=== added directory 'sampleroot/partial-license-settings'
=== added directory 'sampleroot/partial-license-settings/partially-complete-build-info'
=== added file 'sampleroot/partial-license-settings/partially-complete-build-info/BUILD-INFO.txt'
--- sampleroot/partial-license-settings/partially-complete-build-info/BUILD-INFO.txt 1970-01-01 00:00:00 +0000
+++ sampleroot/partial-license-settings/partially-complete-build-info/BUILD-INFO.txt 2012-08-22 13:37:44 +0000
@@ -0,0 +1,13 @@
1Format-Version: 0.1
2
3Files-Pattern: *protected*
4Build-Name: landing-multi-license
5Theme: samsung
6License-Type: protected
7License-Text: <p>IMPORTANT — PLEASE READ THE FOLLOWING AGREEMENT CAREFULLY.</p>
8 <p>
9 </p>
10
11Files-Pattern: *open*
12Build-Name: false-positive
13License-Type: open
014
=== added file 'sampleroot/partial-license-settings/partially-complete-build-info/should_be_inaccessible.txt'
=== added file 'sampleroot/partial-license-settings/partially-complete-build-info/should_be_open.txt'
=== added file 'sampleroot/partial-license-settings/partially-complete-build-info/should_be_protected.txt'

Subscribers

People subscribed via source and target branches