def test_cors_policy_setters_force_case(): policy = CORSPolicy() policy.allow_methods = ["get", "delete"] assert policy.allow_methods == {"GET", "DELETE"} policy.allow_headers = ["X-Foo", "Authorization"] assert policy.allow_headers == {"x-foo", "authorization"} policy.allow_origins = ["http://Example.com", "https://Bezkitu.ORG"] assert policy.allow_origins == { "http://example.com", "https://bezkitu.org" }
def test_cors_policy_setters_strings(): policy = CORSPolicy() policy.allow_methods = "get delete" assert policy.allow_methods == {"GET", "DELETE"} policy.allow_methods = "GET POST PATCH" assert policy.allow_methods == {"GET", "POST", "PATCH"} policy.allow_methods = "GET, POST, PATCH" assert policy.allow_methods == {"GET", "POST", "PATCH"} policy.allow_methods = "GET,POST,PATCH" assert policy.allow_methods == {"GET", "POST", "PATCH"} policy.allow_methods = "GET;POST;PATCH" assert policy.allow_methods == {"GET", "POST", "PATCH"} for value in { "X-Foo Authorization", "X-Foo, Authorization", "X-Foo,Authorization" }: policy.allow_headers = value assert policy.allow_headers == {"x-foo", "authorization"} policy.allow_origins = "http://Example.com https://Bezkitu.ORG" assert policy.allow_origins == { "http://example.com", "https://bezkitu.org" } policy.allow_headers = None assert policy.allow_headers == frozenset() policy.allow_methods = None assert policy.allow_methods == frozenset() policy.allow_origins = None assert policy.allow_origins == frozenset()