|
3 | 3 |
|
4 | 4 | from starlette.datastructures import Headers |
5 | 5 |
|
6 | | -from middleware.request_context import RequestContext, get_request_context, _request_context, is_user_email_restricted |
| 6 | +from middleware.request_context import RequestContext, get_request_context, _request_context |
7 | 7 |
|
8 | 8 |
|
9 | 9 | class TestRequestContext(unittest.TestCase): |
@@ -54,45 +54,3 @@ def test_get_request_context(self): |
54 | 54 | request_context = RequestContext(MagicMock()) |
55 | 55 | _request_context.set(request_context) |
56 | 56 | self.assertEqual(request_context, get_request_context()) |
57 | | - |
58 | | - def test_is_user_email_restricted(self): |
59 | | - self.assertTrue(is_user_email_restricted()) |
60 | | - scope_instance = { |
61 | | - "type": "http", |
62 | | - "asgi": {"version": "3.0"}, |
63 | | - "http_version": "1.1", |
64 | | - "method": "GET", |
65 | | - "headers": [ |
66 | | - (b"host", b"localhost"), |
67 | | - (b"x-forwarded-proto", b"https"), |
68 | | - (b"x-forwarded-for", b"client, proxy1"), |
69 | | - (b"server", b"server"), |
70 | | - (b"user-agent", b"user-agent"), |
71 | | - (b"x-goog-iap-jwt-assertion", b"jwt"), |
72 | | - (b"x-cloud-trace-context", b"TRACE_ID/SPAN_ID;o=1"), |
73 | | - (b"x-goog-authenticated-user-id", b"user_id"), |
74 | | - (b"x-goog-authenticated-user-email", b"email"), |
75 | | - ], |
76 | | - "path": "/", |
77 | | - "raw_path": b"/", |
78 | | - "query_string": b"", |
79 | | - "client": ("127.0.0.1", 32767), |
80 | | - "server": ("127.0.0.1", 80), |
81 | | - } |
82 | | - request_context = RequestContext(scope=scope_instance) |
83 | | - _request_context.set(request_context) |
84 | | - self.assertTrue(is_user_email_restricted()) |
85 | | - scope_instance["headers"] = [ |
86 | | - (b"host", b"localhost"), |
87 | | - (b"x-forwarded-proto", b"https"), |
88 | | - (b"x-forwarded-for", b"client, proxy1"), |
89 | | - (b"server", b"server"), |
90 | | - (b"user-agent", b"user-agent"), |
91 | | - (b"x-goog-iap-jwt-assertion", b"jwt"), |
92 | | - (b"x-cloud-trace-context", b"TRACE_ID/SPAN_ID;o=1"), |
93 | | - (b"x-goog-authenticated-user-id", b"user_id"), |
94 | | - ( b"x-goog-authenticated-user-email", b"[email protected]"), |
95 | | - ] |
96 | | - request_context = RequestContext(scope=scope_instance) |
97 | | - _request_context.set(request_context) |
98 | | - self.assertTrue(is_user_email_restricted()) |
0 commit comments