@@ -331,7 +331,7 @@ def test_cors():
331
331
def with_cors () -> Response :
332
332
return Response (200 , content_types .TEXT_HTML , "test" )
333
333
334
- @app .get ("/without-cors" )
334
+ @app .get ("/without-cors" , cors = False )
335
335
def without_cors () -> Response :
336
336
return Response (200 , content_types .TEXT_HTML , "test" )
337
337
@@ -350,17 +350,17 @@ def handler(event, context):
350
350
assert headers ["Access-Control-Allow-Headers" ] == ["," .join (sorted (CORSConfig ._REQUIRED_HEADERS ))]
351
351
352
352
# THEN for routes without cors flag return no cors headers
353
- mock_event = {"path" : "/my/request " , "httpMethod" : "GET" }
353
+ mock_event = {"path" : "/without-cors " , "httpMethod" : "GET" }
354
354
result = handler (mock_event , None )
355
355
assert "Access-Control-Allow-Origin" not in result ["multiValueHeaders" ]
356
356
357
357
358
358
def test_cors_no_request_origin ():
359
- # GIVEN a function with cors=True
359
+ # GIVEN a function
360
360
# AND http method set to GET
361
- app = ApiGatewayResolver ()
361
+ app = ApiGatewayResolver (cors = CORSConfig () )
362
362
363
- @app .get ("/my/path" , cors = True )
363
+ @app .get ("/my/path" )
364
364
def with_cors () -> Response :
365
365
return Response (200 , content_types .TEXT_HTML , "test" )
366
366
@@ -381,7 +381,7 @@ def handler(event, context):
381
381
382
382
383
383
def test_cors_allow_all_request_origins ():
384
- # GIVEN a function with cors=True
384
+ # GIVEN a function
385
385
# AND http method set to GET
386
386
app = ApiGatewayResolver (
387
387
cors = CORSConfig (
@@ -390,11 +390,11 @@ def test_cors_allow_all_request_origins():
390
390
),
391
391
)
392
392
393
- @app .get ("/my/path" , cors = True )
393
+ @app .get ("/my/path" )
394
394
def with_cors () -> Response :
395
395
return Response (200 , content_types .TEXT_HTML , "test" )
396
396
397
- @app .get ("/without-cors" )
397
+ @app .get ("/without-cors" , cors = False )
398
398
def without_cors () -> Response :
399
399
return Response (200 , content_types .TEXT_HTML , "test" )
400
400
@@ -413,7 +413,7 @@ def handler(event, context):
413
413
assert headers ["Access-Control-Allow-Headers" ] == ["," .join (sorted (CORSConfig ._REQUIRED_HEADERS ))]
414
414
415
415
# THEN for routes without cors flag return no cors headers
416
- mock_event = {"path" : "/my/request " , "httpMethod" : "GET" }
416
+ mock_event = {"path" : "/without-cors " , "httpMethod" : "GET" }
417
417
result = handler (mock_event , None )
418
418
assert "Access-Control-Allow-Origin" not in result ["multiValueHeaders" ]
419
419
0 commit comments