99
1010from mock_vws ._database_matchers import get_database_matching_client_keys
1111from mock_vws ._query_validators .exceptions import (
12- AuthenticationFailure ,
13- AuthHeaderMissing ,
14- MalformedAuthHeader ,
12+ AuthenticationFailureError ,
13+ AuthHeaderMissingError ,
14+ MalformedAuthHeaderError ,
1515)
1616
1717_LOGGER = logging .getLogger (__name__ )
@@ -28,13 +28,13 @@ def validate_auth_header_exists(request_headers: dict[str, str]) -> None:
2828 request_headers: The headers sent with the request.
2929
3030 Raises:
31- AuthHeaderMissing : There is no "Authorization" header.
31+ AuthHeaderMissingError : There is no "Authorization" header.
3232 """
3333 if "Authorization" in request_headers :
3434 return
3535
3636 _LOGGER .warning (msg = "There is no authorization header." )
37- raise AuthHeaderMissing
37+ raise AuthHeaderMissingError
3838
3939
4040def validate_auth_header_number_of_parts (
@@ -47,7 +47,8 @@ def validate_auth_header_number_of_parts(
4747 request_headers: The headers sent with the request.
4848
4949 Raises:
50- MalformedAuthHeader: The "Authorization" header is not as expected.
50+ MalformedAuthHeaderError: The "Authorization" header is not as
51+ expected.
5152 """
5253 header = request_headers ["Authorization" ]
5354 parts = header .split (" " )
@@ -56,7 +57,7 @@ def validate_auth_header_number_of_parts(
5657 return
5758
5859 _LOGGER .warning (msg = "The authorization header is malformed." )
59- raise MalformedAuthHeader
60+ raise MalformedAuthHeaderError
6061
6162
6263def validate_client_key_exists (
@@ -71,7 +72,7 @@ def validate_client_key_exists(
7172 databases: All Vuforia databases.
7273
7374 Raises:
74- AuthenticationFailure : The client key is unknown.
75+ AuthenticationFailureError : The client key is unknown.
7576 """
7677 header = request_headers ["Authorization" ]
7778 first_part , _ = header .split (":" )
@@ -81,7 +82,7 @@ def validate_client_key_exists(
8182 return
8283
8384 _LOGGER .warning (msg = "The client key is unknown." )
84- raise AuthenticationFailure
85+ raise AuthenticationFailureError
8586
8687
8788def validate_auth_header_has_signature (
@@ -94,14 +95,14 @@ def validate_auth_header_has_signature(
9495 request_headers: The headers sent with the request.
9596
9697 Raises:
97- MalformedAuthHeader : The "Authorization" header has no signature.
98+ MalformedAuthHeaderError : The "Authorization" header has no signature.
9899 """
99100 header = request_headers ["Authorization" ]
100101 if header .count (":" ) == 1 and header .split (":" )[1 ]:
101102 return
102103
103104 _LOGGER .warning (msg = "The authorization header has no signature." )
104- raise MalformedAuthHeader
105+ raise MalformedAuthHeaderError
105106
106107
107108def validate_authorization (
@@ -122,7 +123,8 @@ def validate_authorization(
122123 databases: All Vuforia databases.
123124
124125 Raises:
125- AuthenticationFailure: The "Authorization" header is not as expected.
126+ AuthenticationFailureError: The "Authorization" header is not as
127+ expected.
126128 """
127129 try :
128130 get_database_matching_client_keys (
@@ -136,4 +138,4 @@ def validate_authorization(
136138 _LOGGER .warning (
137139 msg = "The authorization header does not match any databases." ,
138140 )
139- raise AuthenticationFailure from ValueError
141+ raise AuthenticationFailureError from ValueError
0 commit comments