Merge lp:~gesha/linaro-license-protection/clickthrough-testing into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Superseded
Proposed branch: lp:~gesha/linaro-license-protection/clickthrough-testing
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 553 lines (+486/-4) (has conflicts)
8 files modified
.htaccess (+12/-4)
.testr.conf (+3/-0)
licenses/nolicense.html (+9/-0)
testing/__init__.py (+11/-0)
testing/apache2.conf.tmpl (+104/-0)
testing/filefetcher.py (+129/-0)
testing/mime.types (+6/-0)
testing/test_click_through_license.py (+212/-0)
Conflict adding file licenses/nolicense.html.  Moved existing file to licenses/nolicense.html.moved.
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/clickthrough-testing
Reviewer Review Type Date Requested Status
Linaro Infrastructure Pending
Review via email: mp+88387@code.launchpad.net

This proposal supersedes a proposal from 2012-01-10.

This proposal has been superseded by a proposal from 2012-01-13.

Description of the change

Added tests for click-through license feature using Testtools and Testrepository.

To post a comment you must log in.
33. By Georgy Redkozubov

Fixed issue with non-standart http port

Revision history for this message
James Tunnicliffe (dooferlad) wrote :
Download full text (22.4 KiB)

Hi,

I have stuff running on port 8080, I modified
test_click_through_license.py to get a free port from the OS:

=== modified file 'testing/test_click_through_license.py'
--- testing/test_click_through_license.py 2012-01-13 08:02:11 +0000
+++ testing/test_click_through_license.py 2012-01-13 11:04:58 +0000
@@ -2,14 +2,13 @@

 import re
 import os
-import sys
 import shutil
 import shlex
 import subprocess
+import socket

 from testtools import TestCase
 from testtools.matchers import Mismatch
-from testtools.matchers import MatchesAny
 from filefetcher import LicenseProtectedFileFetcher

 fetcher = LicenseProtectedFileFetcher()
@@ -19,7 +18,7 @@
 local_rewrite = 'RewriteCond %{REMOTE_ADDR} 127.0.0.1 [OR]'

 host = 'http://127.0.0.1'
-port = '8080'
+port = '0' # 0 == Pick a free port.
 samsung_license_path = '/licenses/samsung-v2.html'
 ste_license_path = '/licenses/ste.html'
 samsung_test_file = '/android/~linaro-android/staging-origen/test.txt'
@@ -55,7 +54,12 @@
     @classmethod
     def setUpClass(cls):
         global host
- if port != '80':
+ global port
+ if port == '0':
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind(('127.0.0.1', 0))
+ port = str(s.getsockname()[1])
+ s.close()
             host = host + ':' + port
         shutil.copy("%s/apache2.conf.tmpl" % srvroot, "%s/apache2.conf" %
                 srvroot)

I think you missed checking in a file: licenses/nolicense.html - after
the above modification I have failing tests because of this.

I also deleted a few unused libraries. If you use the pep8 tool you
will find a string of issues that it has found with style. If you use
gedit you can install pep8 and pylint they will nag you about all
sorts of things :-) If you use gedit and install pylint, activate all
the plugins that ship with it and you will find that when you save a
python file you get the pep8 output as a sidebar, which is quite
useful. We also have a license for pycharm, which is a nice Python
IDE:

https://wiki.linaro.org/Internal/Licenses/PyCharm

This has some stuff built in that makes hacking easier, but doesn't do
quite as much style nagging.

Nice start though - thanks for testing this.

James

On 12 January 2012 14:39, Georgy Redkozubov
<email address hidden> wrote:
> Georgy Redkozubov has proposed merging lp:~gesha/linaro-license-protection/clickthrough-testing into lp:linaro-license-protection.
>
> Requested reviews:
>  Linaro Infrastructure (linaro-infrastructure)
>
> For more details, see:
> https://code.launchpad.net/~gesha/linaro-license-protection/clickthrough-testing/+merge/88387
>
> Added tests for click-through license feature using Testtools and Testrepository.
> --
> https://code.launchpad.net/~gesha/linaro-license-protection/clickthrough-testing/+merge/88387
> Your team Linaro Infrastructure is requested to review the proposed merge of lp:~gesha/linaro-license-protection/clickthrough-testing into lp:linaro-license-protection.
>
> === modified file '.htaccess'
> --- .htaccess   2011-12-19 16:57:20 +0000
> +++ .htaccess   2012-01-12 14:37:26 +0000
> @@ -6,6 +6,8 @@
>  ## Let internal hosts through always.
>  ...

34. By Georgy Redkozubov

Added port autoselection adviced by James Tunnicliffe and corrected to match pep8 style

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.htaccess'
2--- .htaccess 2011-12-19 16:57:20 +0000
3+++ .htaccess 2012-01-13 11:52:24 +0000
4@@ -3,6 +3,14 @@
5
6 RewriteEngine On
7
8+RewriteCond %{SERVER_PORT} !^80$
9+RewriteCond %{HTTP_HOST} (.*)(\:.*)
10+RewriteRule .* - [E=CO_DOMAIN:%1]
11+
12+RewriteCond %{SERVER_PORT} ^80$
13+RewriteCond %{HTTP_HOST} (^.*$)
14+RewriteRule .* - [E=CO_DOMAIN:%1]
15+
16 ## Let internal hosts through always.
17 # android-build.linaro.org.
18 RewriteCond %{REMOTE_ADDR} 50.17.250.69 [OR]
19@@ -45,11 +53,11 @@
20 # Samsung.
21 RewriteCond %{REQUEST_URI} licenses/samsung-accepted.html$
22 RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)
23-RewriteRule .* %1%2 [CO=samsunglicenseaccepted-v1:true:.%{HTTP_HOST}:5:%1,R,L]
24+RewriteRule .* %1%2 [CO=samsunglicenseaccepted-v1:true:.%{ENV:CO_DOMAIN}:5:%1,R,L]
25 # ST-E.
26 RewriteCond %{REQUEST_URI} licenses/ste-accepted.html$
27 RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)
28-RewriteRule .* %1%2 [CO=stelicenseaccepted-v1:true:.%{HTTP_HOST}:60:%1,R,L]
29+RewriteRule .* %1%2 [CO=stelicenseaccepted-v1:true:.%{ENV:CO_DOMAIN}:60:%1,R,L]
30
31 ## When license is being declined, show the notice that you have to accept it.
32 # Samsung.
33@@ -69,7 +77,7 @@
34 ## Redirect to the license file protected builds.
35 # Samsung.
36 RewriteCond %{REQUEST_URI} ^/.*origen.*$
37-RewriteRule .* /licenses/samsung-v2.html [CO=downloadrequested:%{REQUEST_URI}:.%{HTTP_HOST},R,L]
38+RewriteRule .* /licenses/samsung-v2.html [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L]
39 # ST-E.
40 RewriteCond %{REQUEST_URI} ^/.*snowball.*
41-RewriteRule .* /licenses/ste.html [CO=downloadrequested:%{REQUEST_URI}:.%{HTTP_HOST},R,L]
42+RewriteRule .* /licenses/ste.html [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L]
43
44=== added file '.testr.conf'
45--- .testr.conf 1970-01-01 00:00:00 +0000
46+++ .testr.conf 2012-01-13 11:52:24 +0000
47@@ -0,0 +1,3 @@
48+[DEFAULT]
49+test_command=python -m subunit.run $IDLIST
50+test_id_list_default=testing.test_suite
51
52=== added file 'licenses/nolicense.html'
53--- licenses/nolicense.html 1970-01-01 00:00:00 +0000
54+++ licenses/nolicense.html 2012-01-13 11:52:24 +0000
55@@ -0,0 +1,9 @@
56+<html>
57+<head>
58+ <title>License has not been accepted</title>
59+</head>
60+<body>
61+ <h1>License has not been accepted</h1>
62+ <p>Without accepting the license, you can not download the requested files.</p>
63+</body>
64+</html>
65
66=== renamed file 'licenses/nolicense.html' => 'licenses/nolicense.html.moved'
67=== added directory 'testing'
68=== added file 'testing/__init__.py'
69--- testing/__init__.py 1970-01-01 00:00:00 +0000
70+++ testing/__init__.py 2012-01-13 11:52:24 +0000
71@@ -0,0 +1,11 @@
72+import os
73+import unittest
74+
75+def test_suite():
76+ module_names = [
77+ 'testing.test_click_through_license',
78+ ]
79+ loader = unittest.TestLoader()
80+ suite = loader.loadTestsFromNames(module_names)
81+ return suite
82+
83
84=== added file 'testing/apache2.conf.tmpl'
85--- testing/apache2.conf.tmpl 1970-01-01 00:00:00 +0000
86+++ testing/apache2.conf.tmpl 2012-01-13 11:52:24 +0000
87@@ -0,0 +1,104 @@
88+ServerRoot ""
89+
90+LockFile click_through_license.lock
91+PidFile click_through_license.pid
92+
93+Timeout 300
94+
95+KeepAlive On
96+
97+KeepAliveTimeout 5
98+
99+Listen
100+
101+ServerAdmin you@example.com
102+
103+#ServerName www.example.com:80
104+
105+DocumentRoot ""
106+
107+AccessFileName .htaccess
108+
109+LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so
110+LoadModule cache_module /usr/lib/apache2/modules/mod_cache.so
111+LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so
112+LoadModule autoindex_module /usr/lib/apache2/modules/mod_autoindex.so
113+LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
114+
115+User daemon
116+Group daemon
117+
118+<IfModule mpm_prefork_module>
119+ StartServers 5
120+ MinSpareServers 5
121+ MaxSpareServers 10
122+ MaxClients 150
123+ MaxRequestsPerChild 0
124+</IfModule>
125+
126+<IfModule mpm_worker_module>
127+ StartServers 2
128+ MinSpareThreads 25
129+ MaxSpareThreads 75.
130+ ThreadLimit 64
131+ ThreadsPerChild 25
132+ MaxClients 150
133+ MaxRequestsPerChild 0
134+</IfModule>
135+
136+<IfModule mpm_event_module>
137+ StartServers 2
138+ MinSpareThreads 25
139+ MaxSpareThreads 75.
140+ ThreadLimit 64
141+ ThreadsPerChild 25
142+ MaxClients 150
143+ MaxRequestsPerChild 0
144+</IfModule>
145+
146+<Directory />
147+ Options +FollowSymLinks
148+ AllowOverride All
149+ Order deny,allow
150+ Deny from all
151+</Directory>
152+
153+<Directory "">
154+ Options Indexes +FollowSymLinks MultiViews
155+ AllowOverride All
156+ Order allow,deny
157+ Allow from all
158+</Directory>
159+
160+<IfModule dir_module>
161+ DirectoryIndex index.html
162+</IfModule>
163+
164+<FilesMatch "^\.ht">
165+ Order allow,deny
166+ Deny from all
167+ Satisfy All
168+</FilesMatch>
169+
170+ErrorLog "click_through_license_error.log"
171+
172+LogLevel warn
173+
174+<IfModule log_config_module>
175+ LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
176+ LogFormat "%h %l %u %t \"%r\" %>s %b" common
177+
178+ <IfModule logio_module>
179+ LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
180+ </IfModule>
181+
182+ CustomLog "click_through_license_access.log" common
183+
184+</IfModule>
185+
186+DefaultType text/plain
187+
188+IndexOptions FancyIndexing VersionSort HTMLTable NameWidth=* DescriptionWidth=* Charset=UTF-8
189+ReadmeName README.html
190+HeaderName HEADER.html
191+IndexIgnore .??* *~ *# RCS CVS *,v *,t.
192
193=== added file 'testing/filefetcher.py'
194--- testing/filefetcher.py 1970-01-01 00:00:00 +0000
195+++ testing/filefetcher.py 2012-01-13 11:52:24 +0000
196@@ -0,0 +1,129 @@
197+#!/usr/bin/env python
198+
199+# Changes required to address EULA for the origen hwpacks
200+
201+import argparse
202+import os
203+import pycurl
204+import re
205+import urlparse
206+
207+
208+class LicenseProtectedFileFetcher:
209+ """Fetch a file from the web that may be protected by a license redirect
210+
211+ This is designed to run on snapshots.linaro.org. License HTML file are in
212+ the form:
213+
214+ <vendor>.html has a link to <vendor>-accept.html
215+
216+ If self.get is pointed at a file that has to go through one of these
217+ licenses, it should be able to automatically accept the license and
218+ download the file.
219+
220+ Once a license has been accepted, it will be used for all following
221+ downloads.
222+
223+ If self.close() is called before the object is deleted, cURL will store
224+ the license accept cookie to cookies.txt, so it can be used for later
225+ downloads.
226+
227+ """
228+ def __init__(self):
229+ """Set up cURL"""
230+ self.curl = pycurl.Curl()
231+ self.curl.setopt(pycurl.FOLLOWLOCATION, 1)
232+ self.curl.setopt(pycurl.WRITEFUNCTION, self._write_body)
233+ self.curl.setopt(pycurl.HEADERFUNCTION, self._write_header)
234+ self.curl.setopt(pycurl.COOKIEFILE, "cookies.txt")
235+ self.curl.setopt(pycurl.COOKIEJAR, "cookies.txt")
236+
237+ def _get(self, url):
238+ """Clear out header and body storage, fetch URL, filling them in."""
239+ self.curl.setopt(pycurl.URL, url)
240+
241+ self.body = ""
242+ self.header = ""
243+
244+ self.curl.perform()
245+
246+ def get(self, url, ignore_license=False, accept_license=True):
247+ """Fetch the requested URL, ignoring license at all or
248+ accepting or declining licenses, returns file body.
249+
250+ Fetches the file at url. If a redirect is encountered, it is
251+ expected to be to a license that has an accept or decline link.
252+ Follow that link, then download original file or nolicense notice.
253+
254+ """
255+ self._get(url)
256+
257+ if ignore_license:
258+ return self.body
259+
260+ location = self._get_location()
261+ if location:
262+ # Off to the races - we have been redirected.
263+ # Expect to find a link to self.location with -accepted or
264+ # -declined inserted before the .html,
265+ # i.e. ste.html -> ste-accepted.html
266+
267+ # Get the file from the URL (full path)
268+ file = urlparse.urlparse(location).path
269+
270+ # Get the file without the rest of the path
271+ file = os.path.split(file)[-1]
272+
273+ # Look for a link with accepted.html or declined.html
274+ # in the page name. Follow it.
275+ new_file = None
276+ for line in self.body.splitlines():
277+ if accept_license:
278+ link_search = re.search("""href=.*?["'](.*?-accepted.html)""",
279+ line)
280+ else:
281+ link_search = re.search("""href=.*?["'](.*?-declined.html)""",
282+ line)
283+ if link_search:
284+ # Have found license decline URL!
285+ new_file = link_search.group(1)
286+
287+ if new_file:
288+ # accept or decline the license...
289+ next_url = re.sub(file, new_file, location)
290+ self._get(next_url)
291+
292+ # The above get *should* take us to the file requested via
293+ # a redirect. If we manually need to follow that redirect,
294+ # do that now.
295+
296+ if accept_license and self._get_location():
297+ # If we haven't been redirected to our original file,
298+ # we should be able to just download it now.
299+ self._get(url)
300+
301+ return self.body
302+
303+ def _search_header(self, field):
304+ """Search header for the supplied field, return field / None"""
305+ for line in self.header.splitlines():
306+ search = re.search(field + ":\s+(.*?)$", line)
307+ if search:
308+ return search.group(1)
309+ return None
310+
311+ def _get_location(self):
312+ """Return content of Location field in header / None"""
313+ return self._search_header("Location")
314+
315+ def _write_body(self, buf):
316+ """Used by curl as a sink for body content"""
317+ self.body += buf
318+
319+ def _write_header(self, buf):
320+ """Used by curl as a sink for header content"""
321+ self.header += buf
322+
323+ def close(self):
324+ """Wrapper to close curl - this will allow curl to write out cookies"""
325+ self.curl.close()
326
327=== added file 'testing/mime.types'
328--- testing/mime.types 1970-01-01 00:00:00 +0000
329+++ testing/mime.types 2012-01-13 11:52:24 +0000
330@@ -0,0 +1,6 @@
331+text/css css
332+text/directory
333+text/html html htm shtml
334+text/plain asc txt text pot brf
335+text/uri-list
336+
337
338=== added file 'testing/test_click_through_license.py'
339--- testing/test_click_through_license.py 1970-01-01 00:00:00 +0000
340+++ testing/test_click_through_license.py 2012-01-13 11:52:24 +0000
341@@ -0,0 +1,212 @@
342+#!/usr/bin/env python
343+
344+import re
345+import os
346+import shutil
347+import shlex
348+import subprocess
349+import socket
350+
351+from testtools import TestCase
352+from testtools.matchers import Mismatch
353+from filefetcher import LicenseProtectedFileFetcher
354+
355+fetcher = LicenseProtectedFileFetcher()
356+cwd = os.getcwd()
357+docroot = cwd
358+srvroot = os.path.abspath(os.path.join(*([cwd] + ['testing'])))
359+local_rewrite = 'RewriteCond %{REMOTE_ADDR} 127.0.0.1 [OR]'
360+
361+host = 'http://127.0.0.1'
362+port = '0' # 0 == Pick a free port.
363+samsung_license_path = '/licenses/samsung-v2.html'
364+ste_license_path = '/licenses/ste.html'
365+samsung_test_file = '/android/~linaro-android/staging-origen/test.txt'
366+ste_test_file = '/android/~linaro-android/staging-snowball/test.txt'
367+not_protected_test_file = '/android/~linaro-android/staging-panda/test.txt'
368+
369+
370+class Contains(object):
371+ '''Match if a string contains substring'''
372+ def __init__(self, substr):
373+ self.substr = substr
374+
375+ def __str__(self):
376+ return 'Contains(%s)' % (self.substr,)
377+
378+ def match(self, actual):
379+ for line in actual.splitlines():
380+ res = re.search(self.substr, line)
381+ if res:
382+ return None
383+ return Mismatch("Initial string doesn't contain substring (%s)" %
384+ self.substr)
385+
386+
387+class CommandNotFoundException(Exception):
388+ ''' Unable to find command '''
389+
390+
391+class NonZeroReturnValueException(Exception):
392+ ''' Command exited with nonzero return value '''
393+
394+
395+class TestLicense(TestCase):
396+ '''Tests for accessing files and directories with license protection'''
397+
398+ @classmethod
399+ def setUpClass(cls):
400+ global host
401+ global port
402+ if port == '0':
403+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
404+ s.bind(('127.0.0.1', 0))
405+ port = str(s.getsockname()[1])
406+ s.close()
407+ host = host + ':' + port
408+ shutil.copy("%s/apache2.conf.tmpl" % srvroot, "%s/apache2.conf" %
409+ srvroot)
410+ shutil.copy("%s/.htaccess" % docroot, "%s/dothtaccess" % docroot)
411+ subprocess.Popen(['sed', '-i', 's/ServerRoot \"\"/ServerRoot \"%s\"/'
412+ % srvroot.replace('/', '\/'), '%s/apache2.conf' % srvroot],
413+ stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait()
414+ subprocess.Popen(['sed', '-i', 's/DocumentRoot \"\"/DocumentRoot '
415+ '\"%s\"/' % docroot.replace('/', '\/'), '%s/apache2.conf'
416+ % srvroot], stdout=open('/dev/null', 'w'),
417+ stderr=subprocess.STDOUT).wait()
418+ subprocess.Popen(['sed', '-i', 's/Directory \"\"/Directory \"%s\"/'
419+ % docroot.replace('/', '\/'), '%s/apache2.conf' % srvroot],
420+ stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait()
421+ subprocess.Popen(['sed', '-i', 's/Listen/Listen %s/' % port,
422+ '%s/apache2.conf' % srvroot], stdout=open('/dev/null', 'w'),
423+ stderr=subprocess.STDOUT).wait()
424+ if subprocess.Popen(['which', 'apache2'],
425+ stdout=open('/dev/null', 'w'),
426+ stderr=subprocess.STDOUT).wait():
427+ raise CommandNotFoundException("apache2 command not found. Please "
428+ "install apache2 web server and rerun tests.")
429+ args = shlex.split('apache2 -d %s -f apache2.conf -k start' % srvroot)
430+ rc = subprocess.Popen(args, stdout=open('/dev/null', 'w'),
431+ stderr=subprocess.STDOUT).wait()
432+ if rc:
433+ raise NonZeroReturnValueException("apache2 server exited with "
434+ "error %s" % rc)
435+
436+ @classmethod
437+ def tearDownClass(cls):
438+ if os.path.exists("%s/cookies.txt" % docroot):
439+ os.unlink("%s/cookies.txt" % docroot)
440+ args = shlex.split('apache2 -d %s -f apache2.conf -k stop' % srvroot)
441+ subprocess.Popen(args, stdout=open('/dev/null', 'w'),
442+ stderr=subprocess.STDOUT).wait()
443+ if os.path.exists("%s/apache2.conf" % srvroot):
444+ os.unlink("%s/apache2.conf" % srvroot)
445+ if os.path.exists("%s/click_through_license_access.log" % srvroot):
446+ os.unlink("%s/click_through_license_access.log" % srvroot)
447+ if os.path.exists("%s/click_through_license_error.log" % srvroot):
448+ os.unlink("%s/click_through_license_error.log" % srvroot)
449+ os.rename("%s/dothtaccess" % docroot, "%s/.htaccess" % docroot)
450+
451+ def setUp(self):
452+ super(TestLicense, self).setUp()
453+ global fetcher
454+ fetcher = LicenseProtectedFileFetcher()
455+
456+ def tearDown(self):
457+ super(TestLicense, self).tearDown()
458+ if isinstance(fetcher, LicenseProtectedFileFetcher):
459+ fetcher.close()
460+ if os.path.exists("%s/cookies.txt" % docroot):
461+ os.unlink("%s/cookies.txt" % docroot)
462+
463+ def test_licensefile_directly_samsung(self):
464+ search = "Index of /"
465+ testfile = fetcher.get(host + samsung_license_path)
466+ self.assertThat(testfile, Contains(search))
467+
468+ def test_licensefile_directly_ste(self):
469+ search = "Index of /"
470+ testfile = fetcher.get(host + ste_license_path)
471+ self.assertThat(testfile, Contains(search))
472+
473+ def test_redirect_to_license_samsung(self):
474+ search = "SAMSUNG DEVELOPMENT TOOL KIT END-USER LICENSE AGREEMENT"
475+ testfile = fetcher.get(host + samsung_test_file, ignore_license=True)
476+ self.assertThat(testfile, Contains(search))
477+
478+ def test_redirect_to_license_ste(self):
479+ search = "LIMITED LICENSE AGREEMENT FOR APPLICATION DEVELOPERS"
480+ testfile = fetcher.get(host + ste_test_file, ignore_license=True)
481+ self.assertThat(testfile, Contains(search))
482+
483+ def test_decline_license_samsung(self):
484+ search = "License has not been accepted"
485+ testfile = fetcher.get(host + samsung_test_file, accept_license=False)
486+ self.assertThat(testfile, Contains(search))
487+
488+ def test_decline_license_ste(self):
489+ search = "License has not been accepted"
490+ testfile = fetcher.get(host + ste_test_file, accept_license=False)
491+ self.assertThat(testfile, Contains(search))
492+
493+ def test_non_protected_dirs(self):
494+ search = "This is always available."
495+ testfile = fetcher.get(host + not_protected_test_file)
496+ self.assertThat(testfile, Contains(search))
497+
498+ def test_accept_license_samsung_file(self):
499+ search = "This is a protected with click-through Samsung license."
500+ testfile = fetcher.get(host + samsung_test_file)
501+ fetcher.close()
502+ if os.path.exists("%s/cookies.txt" % docroot):
503+ os.rename("%s/cookies.txt" % docroot,
504+ "%s/cookies.samsung" % docroot)
505+ self.assertThat(testfile, Contains(search))
506+
507+ def test_accept_license_samsung_dir(self):
508+ search = "Index of /android/~linaro-android/staging-origen"
509+ testfile = fetcher.get(host + os.path.dirname(samsung_test_file))
510+ self.assertThat(testfile, Contains(search))
511+
512+ def test_accept_license_ste_file(self):
513+ search = "This is a protected with click-through ST-E license."
514+ testfile = fetcher.get(host + ste_test_file)
515+ fetcher.close()
516+ if os.path.exists("%s/cookies.txt" % docroot):
517+ os.rename("%s/cookies.txt" % docroot, "%s/cookies.ste" % docroot)
518+ self.assertThat(testfile, Contains(search))
519+
520+ def test_accept_license_ste_dir(self):
521+ search = "Index of /android/~linaro-android/staging-snowball"
522+ testfile = fetcher.get(host + os.path.dirname(ste_test_file))
523+ self.assertThat(testfile, Contains(search))
524+
525+ def test_license_accepted_samsung(self):
526+ search = "This is a protected with click-through Samsung license."
527+ os.rename("%s/cookies.samsung" % docroot, "%s/cookies.txt" % docroot)
528+ testfile = fetcher.get(host + samsung_test_file, ignore_license=True)
529+ self.assertThat(testfile, Contains(search))
530+
531+ def test_license_accepted_ste(self):
532+ search = "This is a protected with click-through ST-E license."
533+ os.rename("%s/cookies.ste" % docroot, "%s/cookies.txt" % docroot)
534+ testfile = fetcher.get(host + ste_test_file, ignore_license=True)
535+ self.assertThat(testfile, Contains(search))
536+
537+ def test_internal_host_samsung(self):
538+ search = "This is a protected with click-through Samsung license."
539+ subprocess.Popen(['sed', '-i', '/## Let internal hosts through '
540+ 'always./ a %s' % local_rewrite, '%s/.htaccess' % docroot],
541+ stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait()
542+ testfile = fetcher.get(host + samsung_test_file, ignore_license=True)
543+ shutil.copy("%s/dothtaccess" % docroot, "%s/.htaccess" % docroot)
544+ self.assertThat(testfile, Contains(search))
545+
546+ def test_internal_host_ste(self):
547+ search = "This is a protected with click-through ST-E license."
548+ subprocess.Popen(['sed', '-i', '/## Let internal hosts through '
549+ 'always./ a %s' % local_rewrite, '%s/.htaccess' % docroot],
550+ stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait()
551+ testfile = fetcher.get(host + ste_test_file, ignore_license=True)
552+ shutil.copy("%s/dothtaccess" % docroot, "%s/.htaccess" % docroot)
553+ self.assertThat(testfile, Contains(search))

Subscribers

People subscribed via source and target branches