Merge lp:~gesha/linaro-license-protection/check-empty-buildinfo into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Merged
Merged at revision: 156
Proposed branch: lp:~gesha/linaro-license-protection/check-empty-buildinfo
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 64 lines (+18/-0)
5 files modified
license_protected_downloads/buildinfo.py (+2/-0)
license_protected_downloads/tests/test_buildinfo.py (+6/-0)
license_protected_downloads/tests/test_views.py (+8/-0)
license_protected_downloads/tests/testserver_root/build-info/empty-build-info/test.txt (+1/-0)
sampleroot/build-info/empty-build-info/test.txt (+1/-0)
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/check-empty-buildinfo
Reviewer Review Type Date Requested Status
Paul Sokolovsky Approve
Review via email: mp+145575@code.launchpad.net

Description of the change

Recent tests showed that empty BUILD-INFO.txt wasn't handled.
This branch adds check for empty BUILD-INFO.txt

To post a comment you must log in.
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'license_protected_downloads/buildinfo.py'
2--- license_protected_downloads/buildinfo.py 2012-11-28 12:08:55 +0000
3+++ license_protected_downloads/buildinfo.py 2013-01-30 10:48:37 +0000
4@@ -106,6 +106,8 @@
5 return False
6
7 def parseData(self, lines):
8+ if not lines:
9+ raise IncorrectDataFormatException("Array is empty.")
10 if not isinstance(lines, list):
11 raise IncorrectDataFormatException("No array provided.")
12 format_line = lines.pop(0)
13
14=== modified file 'license_protected_downloads/tests/test_buildinfo.py'
15--- license_protected_downloads/tests/test_buildinfo.py 2012-11-28 12:30:30 +0000
16+++ license_protected_downloads/tests/test_buildinfo.py 2013-01-30 10:48:37 +0000
17@@ -78,6 +78,12 @@
18 with self.assertRaises(IncorrectDataFormatException):
19 build_info.parseLine(line)
20
21+ def test_parseData_empty_fails(self):
22+ build_info = BuildInfo(self.buildinfo_file_path)
23+
24+ with self.assertRaises(IncorrectDataFormatException):
25+ build_info.parseData([])
26+
27 def test_parseData_no_format_version_fails(self):
28 build_info = BuildInfo(self.buildinfo_file_path)
29
30
31=== modified file 'license_protected_downloads/tests/test_views.py'
32--- license_protected_downloads/tests/test_views.py 2012-11-29 09:36:04 +0000
33+++ license_protected_downloads/tests/test_views.py 2013-01-30 10:48:37 +0000
34@@ -407,6 +407,14 @@
35 # If a build-info file is invalid, we don't allow access
36 self.assertEqual(response.status_code, 403)
37
38+ def test_empty_build_info_file(self):
39+ target_file = "build-info/empty-build-info/test.txt"
40+ url = urlparse.urljoin("http://testserver/", target_file)
41+ response = self.client.get(url, follow=True)
42+
43+ # If a build-info file is invalid, we don't allow access
44+ self.assertEqual(response.status_code, 403)
45+
46 def test_unable_to_download_hidden_files(self):
47 target_file = '~linaro-android/staging-vexpress-a9/OPEN-EULA.txt'
48 url = urlparse.urljoin("http://testserver/", target_file)
49
50=== added directory 'license_protected_downloads/tests/testserver_root/build-info/empty-build-info'
51=== added file 'license_protected_downloads/tests/testserver_root/build-info/empty-build-info/BUILD-INFO.txt'
52=== added file 'license_protected_downloads/tests/testserver_root/build-info/empty-build-info/test.txt'
53--- license_protected_downloads/tests/testserver_root/build-info/empty-build-info/test.txt 1970-01-01 00:00:00 +0000
54+++ license_protected_downloads/tests/testserver_root/build-info/empty-build-info/test.txt 2013-01-30 10:48:37 +0000
55@@ -0,0 +1,1 @@
56+This is protected with click-through Linaro license.
57
58=== added directory 'sampleroot/build-info/empty-build-info'
59=== added file 'sampleroot/build-info/empty-build-info/BUILD-INFO.txt'
60=== added file 'sampleroot/build-info/empty-build-info/test.txt'
61--- sampleroot/build-info/empty-build-info/test.txt 1970-01-01 00:00:00 +0000
62+++ sampleroot/build-info/empty-build-info/test.txt 2013-01-30 10:48:37 +0000
63@@ -0,0 +1,1 @@
64+This is protected with click-through Linaro license.

Subscribers

People subscribed via source and target branches