Skip to content

Commit de5fdfc

Browse files
Merge pull request #1033 from VWS-Python/faster-tests-split
Attempt to speed up tests by splitting some tests up
2 parents e187f1f + 33ea86d commit de5fdfc

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ jobs:
4141
- test_query.py::TestInactiveProject
4242
- test_add_target.py
4343
- test_authorization_header.py::TestAuthorizationHeader
44-
- test_authorization_header.py::TestMalformed::test_one_part
44+
- test_authorization_header.py::TestMalformed::test_one_part_no_space
45+
- test_authorization_header.py::TestMalformed::test_one_part_with_space
4546
- test_authorization_header.py::TestMalformed::test_missing_signature
4647
- test_authorization_header.py::TestBadKey
4748
- test_content_length.py::TestIncorrect::test_not_integer

tests/mock_vws/test_authorization_header.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ class TestMalformed:
8282

8383
@pytest.mark.parametrize(
8484
'authorization_string',
85-
['gibberish', 'VWS', 'VWS '],
85+
['gibberish', 'VWS'],
8686
)
87-
def test_one_part(
87+
def test_one_part_no_space(
8888
self,
8989
endpoint: Endpoint,
9090
authorization_string: str,
@@ -126,6 +126,45 @@ def test_one_part(
126126
result_code=ResultCodes.FAIL,
127127
)
128128

129+
def test_one_part_with_space(self, endpoint: Endpoint) -> None:
130+
"""
131+
A valid authorization string is two "parts" when split on a space. When
132+
a string is given which is one "part", a ``BAD_REQUEST`` or
133+
``UNAUTHORIZED`` response is returned.
134+
"""
135+
authorization_string = 'VWS '
136+
date = rfc_1123_date()
137+
138+
headers: Dict[str, str] = {
139+
**endpoint.prepared_request.headers,
140+
'Authorization': authorization_string,
141+
'Date': date,
142+
}
143+
144+
endpoint.prepared_request.headers = CaseInsensitiveDict(data=headers)
145+
session = requests.Session()
146+
response = session.send(request=endpoint.prepared_request)
147+
148+
url = str(endpoint.prepared_request.url)
149+
netloc = urlparse(url).netloc
150+
if netloc == 'cloudreco.vuforia.com':
151+
assert_vwq_failure(
152+
response=response,
153+
status_code=HTTPStatus.UNAUTHORIZED,
154+
content_type='text/plain;charset=iso-8859-1',
155+
cache_control=None,
156+
www_authenticate='VWS',
157+
connection='keep-alive',
158+
)
159+
assert response.text == 'Malformed authorization header.'
160+
return
161+
162+
assert_vws_failure(
163+
response=response,
164+
status_code=HTTPStatus.BAD_REQUEST,
165+
result_code=ResultCodes.FAIL,
166+
)
167+
129168
@pytest.mark.parametrize(
130169
'authorization_string',
131170
[

0 commit comments

Comments
 (0)