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
=== modified file 'license_protected_downloads/buildinfo.py'
--- license_protected_downloads/buildinfo.py 2012-11-28 12:08:55 +0000
+++ license_protected_downloads/buildinfo.py 2013-01-30 10:48:37 +0000
@@ -106,6 +106,8 @@
106 return False106 return False
107107
108 def parseData(self, lines):108 def parseData(self, lines):
109 if not lines:
110 raise IncorrectDataFormatException("Array is empty.")
109 if not isinstance(lines, list):111 if not isinstance(lines, list):
110 raise IncorrectDataFormatException("No array provided.")112 raise IncorrectDataFormatException("No array provided.")
111 format_line = lines.pop(0)113 format_line = lines.pop(0)
112114
=== modified file 'license_protected_downloads/tests/test_buildinfo.py'
--- license_protected_downloads/tests/test_buildinfo.py 2012-11-28 12:30:30 +0000
+++ license_protected_downloads/tests/test_buildinfo.py 2013-01-30 10:48:37 +0000
@@ -78,6 +78,12 @@
78 with self.assertRaises(IncorrectDataFormatException):78 with self.assertRaises(IncorrectDataFormatException):
79 build_info.parseLine(line)79 build_info.parseLine(line)
8080
81 def test_parseData_empty_fails(self):
82 build_info = BuildInfo(self.buildinfo_file_path)
83
84 with self.assertRaises(IncorrectDataFormatException):
85 build_info.parseData([])
86
81 def test_parseData_no_format_version_fails(self):87 def test_parseData_no_format_version_fails(self):
82 build_info = BuildInfo(self.buildinfo_file_path)88 build_info = BuildInfo(self.buildinfo_file_path)
8389
8490
=== modified file 'license_protected_downloads/tests/test_views.py'
--- license_protected_downloads/tests/test_views.py 2012-11-29 09:36:04 +0000
+++ license_protected_downloads/tests/test_views.py 2013-01-30 10:48:37 +0000
@@ -407,6 +407,14 @@
407 # If a build-info file is invalid, we don't allow access407 # If a build-info file is invalid, we don't allow access
408 self.assertEqual(response.status_code, 403)408 self.assertEqual(response.status_code, 403)
409409
410 def test_empty_build_info_file(self):
411 target_file = "build-info/empty-build-info/test.txt"
412 url = urlparse.urljoin("http://testserver/", target_file)
413 response = self.client.get(url, follow=True)
414
415 # If a build-info file is invalid, we don't allow access
416 self.assertEqual(response.status_code, 403)
417
410 def test_unable_to_download_hidden_files(self):418 def test_unable_to_download_hidden_files(self):
411 target_file = '~linaro-android/staging-vexpress-a9/OPEN-EULA.txt'419 target_file = '~linaro-android/staging-vexpress-a9/OPEN-EULA.txt'
412 url = urlparse.urljoin("http://testserver/", target_file)420 url = urlparse.urljoin("http://testserver/", target_file)
413421
=== added directory 'license_protected_downloads/tests/testserver_root/build-info/empty-build-info'
=== added file 'license_protected_downloads/tests/testserver_root/build-info/empty-build-info/BUILD-INFO.txt'
=== added file 'license_protected_downloads/tests/testserver_root/build-info/empty-build-info/test.txt'
--- license_protected_downloads/tests/testserver_root/build-info/empty-build-info/test.txt 1970-01-01 00:00:00 +0000
+++ license_protected_downloads/tests/testserver_root/build-info/empty-build-info/test.txt 2013-01-30 10:48:37 +0000
@@ -0,0 +1,1 @@
1This is protected with click-through Linaro license.
02
=== added directory 'sampleroot/build-info/empty-build-info'
=== added file 'sampleroot/build-info/empty-build-info/BUILD-INFO.txt'
=== added file 'sampleroot/build-info/empty-build-info/test.txt'
--- sampleroot/build-info/empty-build-info/test.txt 1970-01-01 00:00:00 +0000
+++ sampleroot/build-info/empty-build-info/test.txt 2013-01-30 10:48:37 +0000
@@ -0,0 +1,1 @@
1This is protected with click-through Linaro license.

Subscribers

People subscribed via source and target branches