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
=== modified file '.htaccess'
--- .htaccess 2011-12-19 16:57:20 +0000
+++ .htaccess 2012-01-13 11:52:24 +0000
@@ -3,6 +3,14 @@
33
4RewriteEngine On4RewriteEngine On
55
6RewriteCond %{SERVER_PORT} !^80$
7RewriteCond %{HTTP_HOST} (.*)(\:.*)
8RewriteRule .* - [E=CO_DOMAIN:%1]
9
10RewriteCond %{SERVER_PORT} ^80$
11RewriteCond %{HTTP_HOST} (^.*$)
12RewriteRule .* - [E=CO_DOMAIN:%1]
13
6## Let internal hosts through always.14## Let internal hosts through always.
7# android-build.linaro.org.15# android-build.linaro.org.
8RewriteCond %{REMOTE_ADDR} 50.17.250.69 [OR]16RewriteCond %{REMOTE_ADDR} 50.17.250.69 [OR]
@@ -45,11 +53,11 @@
45# Samsung.53# Samsung.
46RewriteCond %{REQUEST_URI} licenses/samsung-accepted.html$54RewriteCond %{REQUEST_URI} licenses/samsung-accepted.html$
47RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)55RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)
48RewriteRule .* %1%2 [CO=samsunglicenseaccepted-v1:true:.%{HTTP_HOST}:5:%1,R,L]56RewriteRule .* %1%2 [CO=samsunglicenseaccepted-v1:true:.%{ENV:CO_DOMAIN}:5:%1,R,L]
49# ST-E.57# ST-E.
50RewriteCond %{REQUEST_URI} licenses/ste-accepted.html$58RewriteCond %{REQUEST_URI} licenses/ste-accepted.html$
51RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)59RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)
52RewriteRule .* %1%2 [CO=stelicenseaccepted-v1:true:.%{HTTP_HOST}:60:%1,R,L]60RewriteRule .* %1%2 [CO=stelicenseaccepted-v1:true:.%{ENV:CO_DOMAIN}:60:%1,R,L]
5361
54## When license is being declined, show the notice that you have to accept it.62## When license is being declined, show the notice that you have to accept it.
55# Samsung.63# Samsung.
@@ -69,7 +77,7 @@
69## Redirect to the license file protected builds.77## Redirect to the license file protected builds.
70# Samsung.78# Samsung.
71RewriteCond %{REQUEST_URI} ^/.*origen.*$79RewriteCond %{REQUEST_URI} ^/.*origen.*$
72RewriteRule .* /licenses/samsung-v2.html [CO=downloadrequested:%{REQUEST_URI}:.%{HTTP_HOST},R,L]80RewriteRule .* /licenses/samsung-v2.html [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L]
73# ST-E.81# ST-E.
74RewriteCond %{REQUEST_URI} ^/.*snowball.*82RewriteCond %{REQUEST_URI} ^/.*snowball.*
75RewriteRule .* /licenses/ste.html [CO=downloadrequested:%{REQUEST_URI}:.%{HTTP_HOST},R,L]83RewriteRule .* /licenses/ste.html [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L]
7684
=== added file '.testr.conf'
--- .testr.conf 1970-01-01 00:00:00 +0000
+++ .testr.conf 2012-01-13 11:52:24 +0000
@@ -0,0 +1,3 @@
1[DEFAULT]
2test_command=python -m subunit.run $IDLIST
3test_id_list_default=testing.test_suite
04
=== added file 'licenses/nolicense.html'
--- licenses/nolicense.html 1970-01-01 00:00:00 +0000
+++ licenses/nolicense.html 2012-01-13 11:52:24 +0000
@@ -0,0 +1,9 @@
1<html>
2<head>
3 <title>License has not been accepted</title>
4</head>
5<body>
6 <h1>License has not been accepted</h1>
7 <p>Without accepting the license, you can not download the requested files.</p>
8</body>
9</html>
010
=== renamed file 'licenses/nolicense.html' => 'licenses/nolicense.html.moved'
=== added directory 'testing'
=== added file 'testing/__init__.py'
--- testing/__init__.py 1970-01-01 00:00:00 +0000
+++ testing/__init__.py 2012-01-13 11:52:24 +0000
@@ -0,0 +1,11 @@
1import os
2import unittest
3
4def test_suite():
5 module_names = [
6 'testing.test_click_through_license',
7 ]
8 loader = unittest.TestLoader()
9 suite = loader.loadTestsFromNames(module_names)
10 return suite
11
012
=== added file 'testing/apache2.conf.tmpl'
--- testing/apache2.conf.tmpl 1970-01-01 00:00:00 +0000
+++ testing/apache2.conf.tmpl 2012-01-13 11:52:24 +0000
@@ -0,0 +1,104 @@
1ServerRoot ""
2
3LockFile click_through_license.lock
4PidFile click_through_license.pid
5
6Timeout 300
7
8KeepAlive On
9
10KeepAliveTimeout 5
11
12Listen
13
14ServerAdmin you@example.com
15
16#ServerName www.example.com:80
17
18DocumentRoot ""
19
20AccessFileName .htaccess
21
22LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so
23LoadModule cache_module /usr/lib/apache2/modules/mod_cache.so
24LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so
25LoadModule autoindex_module /usr/lib/apache2/modules/mod_autoindex.so
26LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
27
28User daemon
29Group daemon
30
31<IfModule mpm_prefork_module>
32 StartServers 5
33 MinSpareServers 5
34 MaxSpareServers 10
35 MaxClients 150
36 MaxRequestsPerChild 0
37</IfModule>
38
39<IfModule mpm_worker_module>
40 StartServers 2
41 MinSpareThreads 25
42 MaxSpareThreads 75.
43 ThreadLimit 64
44 ThreadsPerChild 25
45 MaxClients 150
46 MaxRequestsPerChild 0
47</IfModule>
48
49<IfModule mpm_event_module>
50 StartServers 2
51 MinSpareThreads 25
52 MaxSpareThreads 75.
53 ThreadLimit 64
54 ThreadsPerChild 25
55 MaxClients 150
56 MaxRequestsPerChild 0
57</IfModule>
58
59<Directory />
60 Options +FollowSymLinks
61 AllowOverride All
62 Order deny,allow
63 Deny from all
64</Directory>
65
66<Directory "">
67 Options Indexes +FollowSymLinks MultiViews
68 AllowOverride All
69 Order allow,deny
70 Allow from all
71</Directory>
72
73<IfModule dir_module>
74 DirectoryIndex index.html
75</IfModule>
76
77<FilesMatch "^\.ht">
78 Order allow,deny
79 Deny from all
80 Satisfy All
81</FilesMatch>
82
83ErrorLog "click_through_license_error.log"
84
85LogLevel warn
86
87<IfModule log_config_module>
88 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
89 LogFormat "%h %l %u %t \"%r\" %>s %b" common
90
91 <IfModule logio_module>
92 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
93 </IfModule>
94
95 CustomLog "click_through_license_access.log" common
96
97</IfModule>
98
99DefaultType text/plain
100
101IndexOptions FancyIndexing VersionSort HTMLTable NameWidth=* DescriptionWidth=* Charset=UTF-8
102ReadmeName README.html
103HeaderName HEADER.html
104IndexIgnore .??* *~ *# RCS CVS *,v *,t.
0105
=== added file 'testing/filefetcher.py'
--- testing/filefetcher.py 1970-01-01 00:00:00 +0000
+++ testing/filefetcher.py 2012-01-13 11:52:24 +0000
@@ -0,0 +1,129 @@
1#!/usr/bin/env python
2
3# Changes required to address EULA for the origen hwpacks
4
5import argparse
6import os
7import pycurl
8import re
9import urlparse
10
11
12class LicenseProtectedFileFetcher:
13 """Fetch a file from the web that may be protected by a license redirect
14
15 This is designed to run on snapshots.linaro.org. License HTML file are in
16 the form:
17
18 <vendor>.html has a link to <vendor>-accept.html
19
20 If self.get is pointed at a file that has to go through one of these
21 licenses, it should be able to automatically accept the license and
22 download the file.
23
24 Once a license has been accepted, it will be used for all following
25 downloads.
26
27 If self.close() is called before the object is deleted, cURL will store
28 the license accept cookie to cookies.txt, so it can be used for later
29 downloads.
30
31 """
32 def __init__(self):
33 """Set up cURL"""
34 self.curl = pycurl.Curl()
35 self.curl.setopt(pycurl.FOLLOWLOCATION, 1)
36 self.curl.setopt(pycurl.WRITEFUNCTION, self._write_body)
37 self.curl.setopt(pycurl.HEADERFUNCTION, self._write_header)
38 self.curl.setopt(pycurl.COOKIEFILE, "cookies.txt")
39 self.curl.setopt(pycurl.COOKIEJAR, "cookies.txt")
40
41 def _get(self, url):
42 """Clear out header and body storage, fetch URL, filling them in."""
43 self.curl.setopt(pycurl.URL, url)
44
45 self.body = ""
46 self.header = ""
47
48 self.curl.perform()
49
50 def get(self, url, ignore_license=False, accept_license=True):
51 """Fetch the requested URL, ignoring license at all or
52 accepting or declining licenses, returns file body.
53
54 Fetches the file at url. If a redirect is encountered, it is
55 expected to be to a license that has an accept or decline link.
56 Follow that link, then download original file or nolicense notice.
57
58 """
59 self._get(url)
60
61 if ignore_license:
62 return self.body
63
64 location = self._get_location()
65 if location:
66 # Off to the races - we have been redirected.
67 # Expect to find a link to self.location with -accepted or
68 # -declined inserted before the .html,
69 # i.e. ste.html -> ste-accepted.html
70
71 # Get the file from the URL (full path)
72 file = urlparse.urlparse(location).path
73
74 # Get the file without the rest of the path
75 file = os.path.split(file)[-1]
76
77 # Look for a link with accepted.html or declined.html
78 # in the page name. Follow it.
79 new_file = None
80 for line in self.body.splitlines():
81 if accept_license:
82 link_search = re.search("""href=.*?["'](.*?-accepted.html)""",
83 line)
84 else:
85 link_search = re.search("""href=.*?["'](.*?-declined.html)""",
86 line)
87 if link_search:
88 # Have found license decline URL!
89 new_file = link_search.group(1)
90
91 if new_file:
92 # accept or decline the license...
93 next_url = re.sub(file, new_file, location)
94 self._get(next_url)
95
96 # The above get *should* take us to the file requested via
97 # a redirect. If we manually need to follow that redirect,
98 # do that now.
99
100 if accept_license and self._get_location():
101 # If we haven't been redirected to our original file,
102 # we should be able to just download it now.
103 self._get(url)
104
105 return self.body
106
107 def _search_header(self, field):
108 """Search header for the supplied field, return field / None"""
109 for line in self.header.splitlines():
110 search = re.search(field + ":\s+(.*?)$", line)
111 if search:
112 return search.group(1)
113 return None
114
115 def _get_location(self):
116 """Return content of Location field in header / None"""
117 return self._search_header("Location")
118
119 def _write_body(self, buf):
120 """Used by curl as a sink for body content"""
121 self.body += buf
122
123 def _write_header(self, buf):
124 """Used by curl as a sink for header content"""
125 self.header += buf
126
127 def close(self):
128 """Wrapper to close curl - this will allow curl to write out cookies"""
129 self.curl.close()
0130
=== added file 'testing/mime.types'
--- testing/mime.types 1970-01-01 00:00:00 +0000
+++ testing/mime.types 2012-01-13 11:52:24 +0000
@@ -0,0 +1,6 @@
1text/css css
2text/directory
3text/html html htm shtml
4text/plain asc txt text pot brf
5text/uri-list
6
07
=== added file 'testing/test_click_through_license.py'
--- testing/test_click_through_license.py 1970-01-01 00:00:00 +0000
+++ testing/test_click_through_license.py 2012-01-13 11:52:24 +0000
@@ -0,0 +1,212 @@
1#!/usr/bin/env python
2
3import re
4import os
5import shutil
6import shlex
7import subprocess
8import socket
9
10from testtools import TestCase
11from testtools.matchers import Mismatch
12from filefetcher import LicenseProtectedFileFetcher
13
14fetcher = LicenseProtectedFileFetcher()
15cwd = os.getcwd()
16docroot = cwd
17srvroot = os.path.abspath(os.path.join(*([cwd] + ['testing'])))
18local_rewrite = 'RewriteCond %{REMOTE_ADDR} 127.0.0.1 [OR]'
19
20host = 'http://127.0.0.1'
21port = '0' # 0 == Pick a free port.
22samsung_license_path = '/licenses/samsung-v2.html'
23ste_license_path = '/licenses/ste.html'
24samsung_test_file = '/android/~linaro-android/staging-origen/test.txt'
25ste_test_file = '/android/~linaro-android/staging-snowball/test.txt'
26not_protected_test_file = '/android/~linaro-android/staging-panda/test.txt'
27
28
29class Contains(object):
30 '''Match if a string contains substring'''
31 def __init__(self, substr):
32 self.substr = substr
33
34 def __str__(self):
35 return 'Contains(%s)' % (self.substr,)
36
37 def match(self, actual):
38 for line in actual.splitlines():
39 res = re.search(self.substr, line)
40 if res:
41 return None
42 return Mismatch("Initial string doesn't contain substring (%s)" %
43 self.substr)
44
45
46class CommandNotFoundException(Exception):
47 ''' Unable to find command '''
48
49
50class NonZeroReturnValueException(Exception):
51 ''' Command exited with nonzero return value '''
52
53
54class TestLicense(TestCase):
55 '''Tests for accessing files and directories with license protection'''
56
57 @classmethod
58 def setUpClass(cls):
59 global host
60 global port
61 if port == '0':
62 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
63 s.bind(('127.0.0.1', 0))
64 port = str(s.getsockname()[1])
65 s.close()
66 host = host + ':' + port
67 shutil.copy("%s/apache2.conf.tmpl" % srvroot, "%s/apache2.conf" %
68 srvroot)
69 shutil.copy("%s/.htaccess" % docroot, "%s/dothtaccess" % docroot)
70 subprocess.Popen(['sed', '-i', 's/ServerRoot \"\"/ServerRoot \"%s\"/'
71 % srvroot.replace('/', '\/'), '%s/apache2.conf' % srvroot],
72 stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait()
73 subprocess.Popen(['sed', '-i', 's/DocumentRoot \"\"/DocumentRoot '
74 '\"%s\"/' % docroot.replace('/', '\/'), '%s/apache2.conf'
75 % srvroot], stdout=open('/dev/null', 'w'),
76 stderr=subprocess.STDOUT).wait()
77 subprocess.Popen(['sed', '-i', 's/Directory \"\"/Directory \"%s\"/'
78 % docroot.replace('/', '\/'), '%s/apache2.conf' % srvroot],
79 stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait()
80 subprocess.Popen(['sed', '-i', 's/Listen/Listen %s/' % port,
81 '%s/apache2.conf' % srvroot], stdout=open('/dev/null', 'w'),
82 stderr=subprocess.STDOUT).wait()
83 if subprocess.Popen(['which', 'apache2'],
84 stdout=open('/dev/null', 'w'),
85 stderr=subprocess.STDOUT).wait():
86 raise CommandNotFoundException("apache2 command not found. Please "
87 "install apache2 web server and rerun tests.")
88 args = shlex.split('apache2 -d %s -f apache2.conf -k start' % srvroot)
89 rc = subprocess.Popen(args, stdout=open('/dev/null', 'w'),
90 stderr=subprocess.STDOUT).wait()
91 if rc:
92 raise NonZeroReturnValueException("apache2 server exited with "
93 "error %s" % rc)
94
95 @classmethod
96 def tearDownClass(cls):
97 if os.path.exists("%s/cookies.txt" % docroot):
98 os.unlink("%s/cookies.txt" % docroot)
99 args = shlex.split('apache2 -d %s -f apache2.conf -k stop' % srvroot)
100 subprocess.Popen(args, stdout=open('/dev/null', 'w'),
101 stderr=subprocess.STDOUT).wait()
102 if os.path.exists("%s/apache2.conf" % srvroot):
103 os.unlink("%s/apache2.conf" % srvroot)
104 if os.path.exists("%s/click_through_license_access.log" % srvroot):
105 os.unlink("%s/click_through_license_access.log" % srvroot)
106 if os.path.exists("%s/click_through_license_error.log" % srvroot):
107 os.unlink("%s/click_through_license_error.log" % srvroot)
108 os.rename("%s/dothtaccess" % docroot, "%s/.htaccess" % docroot)
109
110 def setUp(self):
111 super(TestLicense, self).setUp()
112 global fetcher
113 fetcher = LicenseProtectedFileFetcher()
114
115 def tearDown(self):
116 super(TestLicense, self).tearDown()
117 if isinstance(fetcher, LicenseProtectedFileFetcher):
118 fetcher.close()
119 if os.path.exists("%s/cookies.txt" % docroot):
120 os.unlink("%s/cookies.txt" % docroot)
121
122 def test_licensefile_directly_samsung(self):
123 search = "Index of /"
124 testfile = fetcher.get(host + samsung_license_path)
125 self.assertThat(testfile, Contains(search))
126
127 def test_licensefile_directly_ste(self):
128 search = "Index of /"
129 testfile = fetcher.get(host + ste_license_path)
130 self.assertThat(testfile, Contains(search))
131
132 def test_redirect_to_license_samsung(self):
133 search = "SAMSUNG DEVELOPMENT TOOL KIT END-USER LICENSE AGREEMENT"
134 testfile = fetcher.get(host + samsung_test_file, ignore_license=True)
135 self.assertThat(testfile, Contains(search))
136
137 def test_redirect_to_license_ste(self):
138 search = "LIMITED LICENSE AGREEMENT FOR APPLICATION DEVELOPERS"
139 testfile = fetcher.get(host + ste_test_file, ignore_license=True)
140 self.assertThat(testfile, Contains(search))
141
142 def test_decline_license_samsung(self):
143 search = "License has not been accepted"
144 testfile = fetcher.get(host + samsung_test_file, accept_license=False)
145 self.assertThat(testfile, Contains(search))
146
147 def test_decline_license_ste(self):
148 search = "License has not been accepted"
149 testfile = fetcher.get(host + ste_test_file, accept_license=False)
150 self.assertThat(testfile, Contains(search))
151
152 def test_non_protected_dirs(self):
153 search = "This is always available."
154 testfile = fetcher.get(host + not_protected_test_file)
155 self.assertThat(testfile, Contains(search))
156
157 def test_accept_license_samsung_file(self):
158 search = "This is a protected with click-through Samsung license."
159 testfile = fetcher.get(host + samsung_test_file)
160 fetcher.close()
161 if os.path.exists("%s/cookies.txt" % docroot):
162 os.rename("%s/cookies.txt" % docroot,
163 "%s/cookies.samsung" % docroot)
164 self.assertThat(testfile, Contains(search))
165
166 def test_accept_license_samsung_dir(self):
167 search = "Index of /android/~linaro-android/staging-origen"
168 testfile = fetcher.get(host + os.path.dirname(samsung_test_file))
169 self.assertThat(testfile, Contains(search))
170
171 def test_accept_license_ste_file(self):
172 search = "This is a protected with click-through ST-E license."
173 testfile = fetcher.get(host + ste_test_file)
174 fetcher.close()
175 if os.path.exists("%s/cookies.txt" % docroot):
176 os.rename("%s/cookies.txt" % docroot, "%s/cookies.ste" % docroot)
177 self.assertThat(testfile, Contains(search))
178
179 def test_accept_license_ste_dir(self):
180 search = "Index of /android/~linaro-android/staging-snowball"
181 testfile = fetcher.get(host + os.path.dirname(ste_test_file))
182 self.assertThat(testfile, Contains(search))
183
184 def test_license_accepted_samsung(self):
185 search = "This is a protected with click-through Samsung license."
186 os.rename("%s/cookies.samsung" % docroot, "%s/cookies.txt" % docroot)
187 testfile = fetcher.get(host + samsung_test_file, ignore_license=True)
188 self.assertThat(testfile, Contains(search))
189
190 def test_license_accepted_ste(self):
191 search = "This is a protected with click-through ST-E license."
192 os.rename("%s/cookies.ste" % docroot, "%s/cookies.txt" % docroot)
193 testfile = fetcher.get(host + ste_test_file, ignore_license=True)
194 self.assertThat(testfile, Contains(search))
195
196 def test_internal_host_samsung(self):
197 search = "This is a protected with click-through Samsung license."
198 subprocess.Popen(['sed', '-i', '/## Let internal hosts through '
199 'always./ a %s' % local_rewrite, '%s/.htaccess' % docroot],
200 stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait()
201 testfile = fetcher.get(host + samsung_test_file, ignore_license=True)
202 shutil.copy("%s/dothtaccess" % docroot, "%s/.htaccess" % docroot)
203 self.assertThat(testfile, Contains(search))
204
205 def test_internal_host_ste(self):
206 search = "This is a protected with click-through ST-E license."
207 subprocess.Popen(['sed', '-i', '/## Let internal hosts through '
208 'always./ a %s' % local_rewrite, '%s/.htaccess' % docroot],
209 stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT).wait()
210 testfile = fetcher.get(host + ste_test_file, ignore_license=True)
211 shutil.copy("%s/dothtaccess" % docroot, "%s/.htaccess" % docroot)
212 self.assertThat(testfile, Contains(search))

Subscribers

People subscribed via source and target branches