Merge lp:~gesha/linaro-license-protection/per-file-EULA into lp:~linaro-automation/linaro-license-protection/trunk
- per-file-EULA
- Merge into trunk
Proposed by
Georgy Redkozubov
Status: | Merged |
---|---|
Merged at revision: | 60 |
Proposed branch: | lp:~gesha/linaro-license-protection/per-file-EULA |
Merge into: | lp:~linaro-automation/linaro-license-protection/trunk |
Diff against target: |
451 lines (+192/-75) 14 files modified
.htaccess (+10/-34) android/images/MANIFEST (+1/-0) android/images/origen-blob.txt (+1/-0) android/images/snowball-blob.txt (+1/-0) android/~linaro-android/staging-origen/test.txt (+1/-1) android/~linaro-android/staging-panda/test.txt (+1/-1) android/~linaro-android/staging-snowball/173/target/product/snowball/test.txt (+1/-1) android/~linaro-android/staging-snowball/173/test.txt (+1/-0) licenses/license.php (+117/-16) licenses/linaro.html (+1/-6) licenses/linaro.txt (+1/-0) licenses/samsung.html (+1/-5) licenses/ste.html (+0/-5) testing/test_click_through_license.py (+55/-6) |
To merge this branch: | bzr merge lp:~gesha/linaro-license-protection/per-file-EULA |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Данило Шеган (community) | Approve | ||
Review via email: mp+103238@code.launchpad.net |
Commit message
Description of the change
This branch adds per file EULA support for downloads click-through license protection.
To post a comment you must log in.
- 61. By Georgy Redkozubov
-
Fixed indentation
- 62. By Georgy Redkozubov
-
Added test for directory containing only directories
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.htaccess' |
2 | --- .htaccess 2012-03-27 13:50:19 +0000 |
3 | +++ .htaccess 2012-04-24 10:59:21 +0000 |
4 | @@ -31,6 +31,7 @@ |
5 | RewriteCond %{REQUEST_URI} /licenses/ste.html$ [OR] |
6 | RewriteCond %{REQUEST_URI} /licenses/samsung.html$ [OR] |
7 | RewriteCond %{REQUEST_URI} /licenses/linaro.html$ [OR] |
8 | +RewriteCond %{REQUEST_URI} /licenses/nolicense.html$ [OR] |
9 | RewriteCond %{REQUEST_URI} /licenses/license.php$ |
10 | RewriteCond %{HTTP_COOKIE} downloadrequested |
11 | RewriteCond %{HTTP_COOKIE} !licenseaccepted=true |
12 | @@ -45,13 +46,11 @@ |
13 | RewriteCond %{HTTP_COOKIE} !downloadrequested=(.*) |
14 | RewriteRule .* / [R,L] |
15 | |
16 | -## Exception for <iframe> |
17 | -RewriteCond %{REQUEST_URI} ^.*/EULA.txt$ |
18 | -RewriteRule .* - [L] |
19 | - |
20 | ## If there is a cookie indicating license has been accepted, pass through. |
21 | +## Unset it to be able to process several protected files in the same dir |
22 | RewriteCond %{HTTP_COOKIE} licenseaccepted=true |
23 | -RewriteRule .* - [L] |
24 | +RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*) |
25 | +RewriteRule .* - [CO=licenseaccepted:INVALID:;:-1:%1,L] |
26 | |
27 | ## When license is accepted, set the cookie. |
28 | RewriteCond %{REQUEST_URI} licenses/.*-accepted.html$ |
29 | @@ -72,36 +71,13 @@ |
30 | RewriteCond %{ENV:LP_DOWNLOAD_DIR}/OPEN-EULA.txt -f |
31 | RewriteRule .* - [L] |
32 | |
33 | +## Unset cookie indicating redirect from license.php |
34 | +RewriteCond %{HTTP_COOKIE} redirectlicensephp=yes |
35 | +RewriteRule .* - [CO=redirectlicensephp:INVALID:;:-1,L] |
36 | + |
37 | ## Redirect to the Samsung license file protected builds. |
38 | -RewriteCond %{REQUEST_FILENAME} -d |
39 | -RewriteCond %{REQUEST_FILENAME} .*origen.* |
40 | -RewriteCond %{REQUEST_FILENAME}/EULA.txt -f |
41 | -RewriteRule .* /licenses/license.php?samsung [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L] |
42 | - |
43 | -RewriteCond %{REQUEST_FILENAME} -f |
44 | -RewriteCond %{REQUEST_FILENAME} .*origen.* |
45 | -RewriteCond %{ENV:LP_DOWNLOAD_DIR}/EULA.txt -f |
46 | -RewriteRule .* /licenses/license.php?samsung [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L] |
47 | - |
48 | -## Redirect to the ST-E license file protected builds. |
49 | -RewriteCond %{REQUEST_FILENAME} -d |
50 | -RewriteCond %{REQUEST_FILENAME} .*snowball.* |
51 | -RewriteCond %{REQUEST_FILENAME}/EULA.txt -f |
52 | -RewriteRule .* /licenses/license.php?ste [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L] |
53 | - |
54 | -RewriteCond %{REQUEST_FILENAME} -f |
55 | -RewriteCond %{REQUEST_FILENAME} .*snowball.* |
56 | -RewriteCond %{ENV:LP_DOWNLOAD_DIR}/EULA.txt -f |
57 | -RewriteRule .* /licenses/license.php?ste [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L] |
58 | - |
59 | -## Redirect to the Linaro license file protected builds. |
60 | -RewriteCond %{REQUEST_FILENAME} -d |
61 | -RewriteCond %{REQUEST_FILENAME}/EULA.txt -f |
62 | -RewriteRule .* /licenses/license.php?linaro [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L] |
63 | - |
64 | -RewriteCond %{REQUEST_FILENAME} -f |
65 | -RewriteCond %{ENV:LP_DOWNLOAD_DIR}/EULA.txt -f |
66 | -RewriteRule .* /licenses/license.php?linaro [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L] |
67 | +RewriteCond %{REQUEST_URI} !^/$ |
68 | +RewriteRule .* /licenses/license.php [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},L,R] |
69 | |
70 | ## Return "Permission denied" if no EULA/OPEN-EULA exists |
71 | RewriteCond %{REQUEST_URI} !^/$ |
72 | |
73 | === added directory 'android/images' |
74 | === added file 'android/images/MANIFEST' |
75 | --- android/images/MANIFEST 1970-01-01 00:00:00 +0000 |
76 | +++ android/images/MANIFEST 2012-04-24 10:59:21 +0000 |
77 | @@ -0,0 +1,1 @@ |
78 | +MANIFEST |
79 | \ No newline at end of file |
80 | |
81 | === added file 'android/images/origen-blob.EULA.txt.samsung' |
82 | === added file 'android/images/origen-blob.txt' |
83 | --- android/images/origen-blob.txt 1970-01-01 00:00:00 +0000 |
84 | +++ android/images/origen-blob.txt 2012-04-24 10:59:21 +0000 |
85 | @@ -0,0 +1,1 @@ |
86 | +This is protected with click-through Samsung license. |
87 | \ No newline at end of file |
88 | |
89 | === added file 'android/images/snowball-blob.EULA.txt.ste' |
90 | === added file 'android/images/snowball-blob.txt' |
91 | --- android/images/snowball-blob.txt 1970-01-01 00:00:00 +0000 |
92 | +++ android/images/snowball-blob.txt 2012-04-24 10:59:21 +0000 |
93 | @@ -0,0 +1,1 @@ |
94 | +This is protected with click-through ST-E license. |
95 | \ No newline at end of file |
96 | |
97 | === modified file 'android/~linaro-android/staging-origen/test.txt' |
98 | --- android/~linaro-android/staging-origen/test.txt 2011-12-09 16:08:16 +0000 |
99 | +++ android/~linaro-android/staging-origen/test.txt 2012-04-24 10:59:21 +0000 |
100 | @@ -1,1 +1,1 @@ |
101 | -This is a protected with click-through Samsung license. |
102 | +This is protected with click-through Samsung license. |
103 | |
104 | === modified file 'android/~linaro-android/staging-panda/test.txt' |
105 | --- android/~linaro-android/staging-panda/test.txt 2012-03-27 09:53:11 +0000 |
106 | +++ android/~linaro-android/staging-panda/test.txt 2012-04-24 10:59:21 +0000 |
107 | @@ -1,1 +1,1 @@ |
108 | -This is a protected with click-through Linaro license. |
109 | +This is protected with click-through Linaro license. |
110 | |
111 | === added file 'android/~linaro-android/staging-snowball/173/OPEN-EULA.txt' |
112 | === modified file 'android/~linaro-android/staging-snowball/173/target/product/snowball/test.txt' |
113 | --- android/~linaro-android/staging-snowball/173/target/product/snowball/test.txt 2012-03-27 13:57:57 +0000 |
114 | +++ android/~linaro-android/staging-snowball/173/target/product/snowball/test.txt 2012-04-24 10:59:21 +0000 |
115 | @@ -1,1 +1,1 @@ |
116 | -This is a protected with click-through ST-E license. |
117 | +This is protected with click-through ST-E license. |
118 | |
119 | === added file 'android/~linaro-android/staging-snowball/173/test.txt' |
120 | --- android/~linaro-android/staging-snowball/173/test.txt 1970-01-01 00:00:00 +0000 |
121 | +++ android/~linaro-android/staging-snowball/173/test.txt 2012-04-24 10:59:21 +0000 |
122 | @@ -0,0 +1,1 @@ |
123 | +This is always available. |
124 | |
125 | === modified file 'licenses/license.php' |
126 | --- licenses/license.php 2012-04-20 16:00:26 +0000 |
127 | +++ licenses/license.php 2012-04-24 10:59:21 +0000 |
128 | @@ -1,18 +1,119 @@ |
129 | <?php |
130 | - $down = $_COOKIE["downloadrequested"]; |
131 | - $lic = $_SERVER["QUERY_STRING"]; |
132 | - $host = $_SERVER["HTTP_HOST"]; |
133 | - $doc = $_SERVER["DOCUMENT_ROOT"]; |
134 | - $fn = $doc.$down; |
135 | - if (file_exists($fn) and is_file($fn)) { |
136 | - $repl = dirname($down); |
137 | - } else { |
138 | - $repl = $down; |
139 | - } |
140 | - |
141 | - $template_content = file_get_contents($doc."/licenses/".$lic.".html"); |
142 | - $eula_content = file_get_contents($doc."/licenses/".$lic.".txt"); |
143 | - |
144 | - $out = str_replace("EULA.txt", $eula_content, $template_content); |
145 | - echo $out; |
146 | +// Get list of files into array to process them later. |
147 | +// Used to find special licenses and dirs with only subdirs. |
148 | +function getFilesList($dirname) |
149 | +{ |
150 | + $files = array(); |
151 | + if ($handle = opendir($dirname)) { |
152 | + while ($handle && false !== ($entry = readdir($handle))) { |
153 | + if ($entry != "." && $entry != ".." && !is_dir($dirname.$entry) && !is_link($dirname.$entry)) { |
154 | + $files[] = $entry; |
155 | + } |
156 | + } |
157 | + } |
158 | + closedir($handle); |
159 | + return $files; |
160 | +} |
161 | + |
162 | +// Get array of file name and extension from full filename. |
163 | +function splitFilename($filename) |
164 | +{ |
165 | + $pos = strpos($filename, '.'); |
166 | + if ($pos === false) { // dot is not found in the filename |
167 | + return array($filename, ''); // no extension |
168 | + } else { |
169 | + $basename = substr($filename, 0, $pos); |
170 | + $extension = substr($filename, $pos+1); |
171 | + return array($basename, $extension); |
172 | + } |
173 | +} |
174 | + |
175 | +// Find special EULA based on filename template. |
176 | +function findSpecialEULA($fl, $pattern) |
177 | +{ |
178 | + if (!empty($fl)) { |
179 | + foreach ($fl as $f) { |
180 | + if (preg_match($pattern, $f, $matches)) { |
181 | + return $f; |
182 | + } |
183 | + } |
184 | + } |
185 | + return false; |
186 | +} |
187 | + |
188 | +// Get license theme name from EULA filename. |
189 | +function getTheme($eula, $down) |
190 | +{ |
191 | + if ($eula != 'EULA.txt') { // Special EULA file was found |
192 | + $theme = array_pop(explode(".", $eula)); |
193 | + } else { // No special EULA file was found |
194 | + $eula = "EULA.txt"; |
195 | + if (preg_match("/.*snowball.*/", $down)) { |
196 | + $theme = "ste"; |
197 | + } elseif (preg_match("/.*origen.*/", $down)) { |
198 | + $theme = "samsung"; |
199 | + } else { |
200 | + $theme = "linaro"; |
201 | + } |
202 | + } |
203 | + return $theme; |
204 | +} |
205 | + |
206 | +$down = $_COOKIE["downloadrequested"]; |
207 | +$host = $_SERVER["HTTP_HOST"]; |
208 | +$doc = $_SERVER["DOCUMENT_ROOT"]; |
209 | +$fn = $doc.$down; // Filename on server |
210 | +$flist = array(); |
211 | +$eula = ''; |
212 | + |
213 | +if (file_exists($fn) and is_file($fn)) { // Requested download is file |
214 | + $search_dir = dirname($fn); |
215 | + $repl = dirname($down); |
216 | + $name_only = splitFilename(basename($down)); |
217 | +} elseif (is_dir($fn)) { // Requested download is directory |
218 | + $search_dir = $fn; |
219 | + $repl = $down; |
220 | + $name_only = array(); |
221 | +} else { // Requested download not found on server |
222 | + header("HTTP/1.0 404 Not Found"); |
223 | + header("Status: 404"); |
224 | + echo "<h1>404 Not Found</h1>"; |
225 | + echo "The requested URL was not found on this server."; |
226 | + exit; |
227 | +} |
228 | + |
229 | +$flist = getFilesList($search_dir); |
230 | + |
231 | +if (!empty($name_only)) { |
232 | + $pattern = "/^".$name_only[0]."\.EULA\.txt.*/"; |
233 | + $eula = findSpecialEULA($flist, $pattern); |
234 | +} |
235 | + |
236 | +if (is_file($doc."/".$repl."/".$eula)) { // Special EULA found |
237 | + $theme = getTheme($eula, $down); |
238 | +} elseif (is_file($doc."/".$repl."/EULA.txt")) { // No special EULA found |
239 | + $theme = getTheme("EULA.txt", $down); |
240 | +} elseif (file_exists($fn) and findSpecialEULA($flist, "/.*EULA.txt.*/")) { |
241 | + // If file is requested but no special EULA for it and no EULA.txt is present, |
242 | + // look for any EULA and if found decide that current file is not protected. |
243 | + setcookie("redirectlicensephp", "yes", 0, "/"); |
244 | + header("Location: ".$down); |
245 | + exit; |
246 | +} elseif (empty($flist)) { // Directory contains only subdirs |
247 | + setcookie("redirectlicensephp", "yes", 0, "/"); |
248 | + header("Location: ".$down); |
249 | + exit; |
250 | +} else { // No special EULA, no EULA.txt, no OPEN-EULA.txt found |
251 | + header("HTTP/1.1 403 Forbidden"); |
252 | + header("Status: 403"); |
253 | + echo "<h1>Forbidden</h1>"; |
254 | + echo "You don't have permission to access ".$down." on this server."; |
255 | + exit; |
256 | +} |
257 | + |
258 | +$template_content = file_get_contents($doc."/licenses/".$theme.".html"); |
259 | +$eula_content = file_get_contents($doc."/licenses/".$theme.".txt"); |
260 | + |
261 | +$out = str_replace("EULA.txt", $eula_content, $template_content); |
262 | +echo $out; |
263 | ?> |
264 | |
265 | === modified file 'licenses/linaro.html' |
266 | --- licenses/linaro.html 2012-03-27 13:57:57 +0000 |
267 | +++ licenses/linaro.html 2012-04-24 10:59:21 +0000 |
268 | @@ -82,11 +82,6 @@ |
269 | #actions .button-accept:hover { |
270 | background: #9c5; |
271 | } |
272 | - iframe#eula { |
273 | - width: 100%; |
274 | - height: 100%; |
275 | - scrolling: auto; |
276 | - } |
277 | </style> |
278 | </head> |
279 | <body> |
280 | @@ -101,7 +96,7 @@ |
281 | <div id="content"> |
282 | |
283 | <div id="license-text"> |
284 | -<iframe id="eula" frameborder=0 src="EULA.txt"></iframe> |
285 | +EULA.txt |
286 | </div><!-- license-text --> |
287 | |
288 | <div id="actions"> |
289 | |
290 | === added file 'licenses/linaro.txt' |
291 | --- licenses/linaro.txt 1970-01-01 00:00:00 +0000 |
292 | +++ licenses/linaro.txt 2012-04-24 10:59:21 +0000 |
293 | @@ -0,0 +1,1 @@ |
294 | +Linaro license. |
295 | \ No newline at end of file |
296 | |
297 | === modified file 'licenses/samsung.html' |
298 | --- licenses/samsung.html 2012-04-20 16:00:26 +0000 |
299 | +++ licenses/samsung.html 2012-04-24 10:59:21 +0000 |
300 | @@ -45,6 +45,7 @@ |
301 | color: black; |
302 | margin: 2em; |
303 | padding: 2em; |
304 | + overflow: scroll; |
305 | text-align: left; |
306 | -moz-border-radius: 10px; |
307 | -webkit-border-radius: 10px; |
308 | @@ -82,11 +83,6 @@ |
309 | #actions .button-accept:hover { |
310 | background: #9c5; |
311 | } |
312 | - iframe#eula { |
313 | - width: 100%; |
314 | - height: 100%; |
315 | - scrolling: auto; |
316 | - } |
317 | </style> |
318 | </head> |
319 | <body> |
320 | |
321 | === modified file 'licenses/ste.html' |
322 | --- licenses/ste.html 2012-04-20 16:00:26 +0000 |
323 | +++ licenses/ste.html 2012-04-24 10:59:21 +0000 |
324 | @@ -88,11 +88,6 @@ |
325 | #actions .button-accept:hover { |
326 | background: #9c5; |
327 | } |
328 | - iframe#eula { |
329 | - width: 100%; |
330 | - height: 100%; |
331 | - scrolling: auto; |
332 | - } |
333 | </style> |
334 | </head> |
335 | <body> |
336 | |
337 | === modified file 'testing/test_click_through_license.py' |
338 | --- testing/test_click_through_license.py 2012-03-27 09:53:11 +0000 |
339 | +++ testing/test_click_through_license.py 2012-04-24 10:59:21 +0000 |
340 | @@ -24,9 +24,14 @@ |
341 | linaro_license_path = '/licenses/linaro.html' |
342 | samsung_test_file = '/android/~linaro-android/staging-origen/test.txt' |
343 | ste_test_file = '/android/~linaro-android/staging-snowball/173/target/product/snowball/test.txt' |
344 | +ste_open_test_file = '/android/~linaro-android/staging-snowball/173/test.txt' |
345 | never_available = '/android/~linaro-android/staging-imx53/test.txt' |
346 | linaro_test_file = '/android/~linaro-android/staging-panda/test.txt' |
347 | not_protected_test_file = '/android/~linaro-android/staging-vexpress-a9/test.txt' |
348 | +per_file_samsung_test_file = '/android/images/origen-blob.txt' |
349 | +per_file_ste_test_file = '/android/images/snowball-blob.txt' |
350 | +per_file_not_protected_test_file = '/android/images/MANIFEST' |
351 | +dirs_only_dir = '/android/~linaro-android/' |
352 | |
353 | |
354 | class Contains(object): |
355 | @@ -180,7 +185,7 @@ |
356 | self.assertThat(testfile, Contains(search)) |
357 | |
358 | def test_accept_license_samsung_file(self): |
359 | - search = "This is a protected with click-through Samsung license." |
360 | + search = "This is protected with click-through Samsung license." |
361 | testfile = fetcher.get(host + samsung_test_file) |
362 | fetcher.close() |
363 | if os.path.exists("%s/cookies.txt" % docroot): |
364 | @@ -194,7 +199,7 @@ |
365 | self.assertThat(testfile, Contains(search)) |
366 | |
367 | def test_accept_license_ste_file(self): |
368 | - search = "This is a protected with click-through ST-E license." |
369 | + search = "This is protected with click-through ST-E license." |
370 | testfile = fetcher.get(host + ste_test_file) |
371 | fetcher.close() |
372 | if os.path.exists("%s/cookies.txt" % docroot): |
373 | @@ -207,19 +212,19 @@ |
374 | self.assertThat(testfile, Contains(search)) |
375 | |
376 | def test_license_accepted_samsung(self): |
377 | - search = "This is a protected with click-through Samsung license." |
378 | + search = "This is protected with click-through Samsung license." |
379 | os.rename("%s/cookies.samsung" % docroot, "%s/cookies.txt" % docroot) |
380 | testfile = fetcher.get(host + samsung_test_file, ignore_license=True) |
381 | self.assertThat(testfile, Contains(search)) |
382 | |
383 | def test_license_accepted_ste(self): |
384 | - search = "This is a protected with click-through ST-E license." |
385 | + search = "This is protected with click-through ST-E license." |
386 | os.rename("%s/cookies.ste" % docroot, "%s/cookies.txt" % docroot) |
387 | testfile = fetcher.get(host + ste_test_file, ignore_license=True) |
388 | self.assertThat(testfile, Contains(search)) |
389 | |
390 | def test_internal_host_samsung(self): |
391 | - search = "This is a protected with click-through Samsung license." |
392 | + search = "This is protected with click-through Samsung license." |
393 | subprocess.Popen(['sed', '-i', '/## Let internal hosts through ' |
394 | 'always./ a %s' % local_rewrite, '%s/.htaccess' % docroot], |
395 | stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait() |
396 | @@ -228,10 +233,54 @@ |
397 | self.assertThat(testfile, Contains(search)) |
398 | |
399 | def test_internal_host_ste(self): |
400 | - search = "This is a protected with click-through ST-E license." |
401 | + search = "This is protected with click-through ST-E license." |
402 | subprocess.Popen(['sed', '-i', '/## Let internal hosts through ' |
403 | 'always./ a %s' % local_rewrite, '%s/.htaccess' % docroot], |
404 | stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait() |
405 | testfile = fetcher.get(host + ste_test_file, ignore_license=True) |
406 | shutil.copy("%s/dothtaccess" % docroot, "%s/.htaccess" % docroot) |
407 | self.assertThat(testfile, Contains(search)) |
408 | + |
409 | + def test_ste_open_file(self): |
410 | + search = "This is always available." |
411 | + testfile = fetcher.get(host + ste_open_test_file) |
412 | + self.assertThat(testfile, Contains(search)) |
413 | + |
414 | + def test_per_file_accept_license_samsung_file(self): |
415 | + search = "This is protected with click-through Samsung license." |
416 | + testfile = fetcher.get(host + per_file_samsung_test_file) |
417 | + fetcher.close() |
418 | + if os.path.exists("%s/cookies.txt" % docroot): |
419 | + os.rename("%s/cookies.txt" % docroot, |
420 | + "%s/cookies.samsung" % docroot) |
421 | + self.assertThat(testfile, Contains(search)) |
422 | + |
423 | + def test_per_file_accept_license_ste_file(self): |
424 | + search = "This is protected with click-through ST-E license." |
425 | + testfile = fetcher.get(host + per_file_ste_test_file) |
426 | + fetcher.close() |
427 | + if os.path.exists("%s/cookies.txt" % docroot): |
428 | + os.rename("%s/cookies.txt" % docroot, "%s/cookies.ste" % docroot) |
429 | + self.assertThat(testfile, Contains(search)) |
430 | + |
431 | + def test_per_file_license_accepted_samsung(self): |
432 | + search = "This is protected with click-through Samsung license." |
433 | + os.rename("%s/cookies.samsung" % docroot, "%s/cookies.txt" % docroot) |
434 | + testfile = fetcher.get(host + per_file_samsung_test_file, ignore_license=True) |
435 | + self.assertThat(testfile, Contains(search)) |
436 | + |
437 | + def test_per_file_license_accepted_ste(self): |
438 | + search = "This is protected with click-through ST-E license." |
439 | + os.rename("%s/cookies.ste" % docroot, "%s/cookies.txt" % docroot) |
440 | + testfile = fetcher.get(host + per_file_ste_test_file, ignore_license=True) |
441 | + self.assertThat(testfile, Contains(search)) |
442 | + |
443 | + def test_per_file_non_protected_dirs(self): |
444 | + search = "MANIFEST" |
445 | + testfile = fetcher.get(host + per_file_not_protected_test_file) |
446 | + self.assertThat(testfile, Contains(search)) |
447 | + |
448 | + def test_dir_containing_only_dirs(self): |
449 | + search = "Index of /android/~linaro-android" |
450 | + testfile = fetcher.get(host + dirs_only_dir) |
451 | + self.assertThat(testfile, Contains(search)) |
Looks good, it'd be nice to have a test for dirs only containing other dirs.