Fix tests

This commit is contained in:
Paul Tremberth 2017-01-17 17:57:17 +01:00
parent ebcacd3f54
commit b6c761d2b4
2 changed files with 11 additions and 4 deletions

View File

@ -159,7 +159,8 @@ class StrictOriginPolicy(ReferrerPolicy):
name = POLICY_STRICT_ORIGIN
def referrer(self, response, request):
if ((self.tls_protected(response) and self.potentially_trustworthy(request))
if ((self.tls_protected(response) and
self.potentially_trustworthy(request))
or not self.tls_protected(response)):
return self.origin_referrer(response)
@ -208,9 +209,9 @@ class StrictOriginWhenCrossOriginPolicy(ReferrerPolicy):
origin = self.origin(response)
if origin == self.origin(request):
return self.stripped_referrer(response)
elif ((urlparse_cached(response).scheme in ('https', 'ftps') and
elif ((self.tls_protected(response) and
self.potentially_trustworthy(request))
or urlparse_cached(response).scheme == 'http'):
or not self.tls_protected(response)):
return self.origin_referrer(response)

View File

@ -232,7 +232,13 @@ class MixinStrictOriginWhenCrossOrigin(object):
# downgrade
('https://example4.com/page.html', 'http://example4.com/not-page.html', None),
('https://example4.com/page.html', 'http://not.example4.com/', None),
('ftp://example4.com/urls.zip', 'http://example4.com/not-page.html', None),
# non-TLS to non-TLS
('ftp://example4.com/urls.zip', 'http://example4.com/not-page.html', b'ftp://example4.com/'),
# upgrade
('http://example4.com/page.html', 'https://example4.com/not-page.html', b'http://example4.com/'),
('http://example4.com/page.html', 'https://not.example4.com/', b'http://example4.com/'),
# Different protocols: send origin as referrer
('ftps://example4.com/urls.zip', 'https://example4.com/not-page.html', b'ftps://example4.com/'),