From 4b553b448a4edf3cd07f5dcba446895617e48f91 Mon Sep 17 00:00:00 2001 From: Gaudenz Steinlin Date: Mon, 24 Jul 2017 15:52:11 +0200 Subject: [PATCH] Fix CORS tests without Origin headers According to the CORS spec 6.1.1 [1] requests without an Origin header should not return any access-control-* headers. But the current test method expects these headers to be always present in the response. Fix this by defaulting to None if the header is not present. [1] https://www.w3.org/TR/cors/#resource-requests --- s3tests/functional/test_s3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 7abfe7a..f984011 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -5760,8 +5760,8 @@ def _cors_request_and_check(func, url, headers, expect_status, expect_allow_orig r = func(url, headers=headers) eq(r.status_code, expect_status) - assert r.headers['access-control-allow-origin'] == expect_allow_origin - assert r.headers['access-control-allow-methods'] == expect_allow_methods + assert r.headers.get('access-control-allow-origin', None) == expect_allow_origin + assert r.headers.get('access-control-allow-methods', None) == expect_allow_methods