Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Internal update.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 317675028
  • Loading branch information
craigcitro authored and colaboratory-team committed Jun 22, 2020
1 parent 75fd8d9 commit 355b157
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions jupyter_http_over_ws/handlers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _get_http_client(self):
return AlwaysThrowingHTTPClient()


WHITELISTED_ORIGIN = 'http://www.examplewhitelistedorigin.com'
ALLOWED_ORIGIN = 'http://www.exampleallowedorigin.com'


class _TestBase(six.with_metaclass(abc.ABCMeta)):
Expand All @@ -174,7 +174,7 @@ def get_app(self):
'local_hostnames': ['localhost'],
# This flag controls which domains cross-origin requests are allowed
# for.
'allow_origin': WHITELISTED_ORIGIN,
'allow_origin': ALLOWED_ORIGIN,
}
config = self.get_config()
if config is not None:
Expand Down Expand Up @@ -391,7 +391,7 @@ def test_proxied_endpoint_has_error(self):
self.assertTrue(response['done'])

@testing.gen_test
def test_unwhitelisted_cross_domain_origin(self):
def test_disallowed_cross_domain_origin(self):
request = self.get_ws_connection_request('http_over_websocket')
request.headers.add('Origin', 'http://www.example.com')
with self.assertRaises(httpclient.HTTPError) as e:
Expand All @@ -400,9 +400,9 @@ def test_unwhitelisted_cross_domain_origin(self):
self.assertEqual(403, e.exception.code)

@testing.gen_test
def test_whitelisted_cross_domain_origin(self):
def test_allowed_cross_domain_origin(self):
request = self.get_ws_connection_request('http_over_websocket')
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)
client = yield websocket.websocket_connect(request)
self.assertIsNotNone(client)

Expand Down Expand Up @@ -709,7 +709,7 @@ def get_test_handlers(self):
return []

@testing.gen_test
def test_diagnostic_handler_unwhitelisted_cross_domain_origin(self):
def test_diagnostic_handler_disallowed_cross_domain_origin(self):
request = self.get_ws_connection_request('http_over_websocket/diagnose')
request.headers.add('Origin', 'http://www.example.com')
with self.assertRaises(httpclient.HTTPError) as e:
Expand All @@ -721,7 +721,7 @@ def test_diagnostic_handler_unwhitelisted_cross_domain_origin(self):
def test_diagnostic_handler_no_problems_request(self):
request = self.get_ws_connection_request('http_over_websocket/diagnose')
request.url += '?min_version=0.0.7'
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)
request.headers.add('Cookie', '_xsrf=' + FAKE_XSRF_VALUE)

client = yield websocket.websocket_connect(request)
Expand All @@ -742,7 +742,7 @@ def test_diagnostic_handler_no_problems_request(self):
@testing.gen_test
def test_diagnostic_handler_missing_xsrf_cookie(self):
request = self.get_ws_connection_request('http_over_websocket/diagnose')
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)

client = yield websocket.websocket_connect(request)
client.write_message('1')
Expand All @@ -762,7 +762,7 @@ def test_diagnostic_handler_missing_xsrf_cookie(self):
def test_diagnostic_handler_newer_protocol_version_requested(self):
request = self.get_ws_connection_request('http_over_websocket/diagnose')
request.url += '?min_version=0.0.8'
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)
request.headers.add('Cookie', '_xsrf=' + FAKE_XSRF_VALUE)

client = yield websocket.websocket_connect(request)
Expand Down Expand Up @@ -871,7 +871,7 @@ def get_test_handlers(self):
]

@testing.gen_test
def test_unwhitelisted_cross_domain_origin(self):
def test_disallowed_cross_domain_origin(self):
request = self.get_ws_connection_request(
'http_over_websocket/proxied_ws/echoing-ws')
request.headers.add('Origin', 'http://www.example.com')
Expand All @@ -889,7 +889,7 @@ def test_auth_url_provided_forwards_cookies(self):
request = self.get_ws_connection_request(
'http_over_websocket/proxied_ws/requires-cookies-from-fake-auth-ws?' +
encoded_query_args)
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)

client = yield websocket.websocket_connect(request)
self.assertIsNotNone(client)
Expand All @@ -909,7 +909,7 @@ def test_auth_url_provided_fails(self):
request = self.get_ws_connection_request(
'http_over_websocket/proxied_ws/requires-cookies-from-fake-auth-ws?' +
encoded_query_args)
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)

client = yield websocket.websocket_connect(request)
self.assertIsNotNone(client)
Expand All @@ -926,7 +926,7 @@ def _assertCrossDomainRequestFails(self, auth_url):
request = self.get_ws_connection_request(
'http_over_websocket/proxied_ws/requires-cookies-from-fake-auth-ws?' +
encoded_query_args)
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)

with testing.ExpectLog(
'tornado.application',
Expand Down Expand Up @@ -958,7 +958,7 @@ def test_auth_url_cross_domain_fails(self):
def test_proxied_connection_io(self):
request = self.get_ws_connection_request(
'http_over_websocket/proxied_ws/echoing-ws?someparam=1')
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)
request.headers.add('X-Echo-Header', 'example')

client = yield websocket.websocket_connect(request)
Expand All @@ -983,7 +983,7 @@ def test_proxied_connection_io(self):
def test_proxied_connection_closed(self):
request = self.get_ws_connection_request(
'http_over_websocket/proxied_ws/close-on-first-message-ws')
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)

client = yield websocket.websocket_connect(request)
self.assertIsNotNone(client)
Expand All @@ -1000,7 +1000,7 @@ def test_proxied_connection_closed(self):
def test_unknown_path(self):
request = self.get_ws_connection_request(
'http_over_websocket/proxied_ws/unknown-path')
request.headers.add('Origin', WHITELISTED_ORIGIN)
request.headers.add('Origin', ALLOWED_ORIGIN)

client = yield websocket.websocket_connect(request)
self.assertIsNotNone(client)
Expand Down

0 comments on commit 355b157

Please sign in to comment.