Skip to content

Commit 51dddf4

Browse files
committed
verify header in basic auth
1 parent 9c59d67 commit 51dddf4

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/catalog/test_rest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
# pylint: disable=redefined-outer-name,unused-argument
18+
import base64
1819
import os
1920
from typing import Any, Callable, Dict, cast
2021
from unittest import mock
@@ -1540,6 +1541,10 @@ def test_rest_catalog_with_basic_auth_type(rest_mock: Mocker) -> None:
15401541
catalog = RestCatalog("rest", **catalog_properties) # type: ignore
15411542
assert catalog.uri == TEST_URI
15421543

1544+
encoded_user_pass = base64.b64encode(b"one:two").decode()
1545+
expected_auth_header = f"Basic {encoded_user_pass}"
1546+
assert rest_mock.last_request.headers["Authorization"] == expected_auth_header
1547+
15431548

15441549
def test_rest_catalog_with_custom_auth_type() -> None:
15451550
# Given
@@ -1581,6 +1586,10 @@ def test_rest_catalog_with_custom_basic_auth_type(rest_mock: Mocker) -> None:
15811586
catalog = RestCatalog("rest", **catalog_properties) # type: ignore
15821587
assert catalog.uri == TEST_URI
15831588

1589+
encoded_user_pass = base64.b64encode(b"one:two").decode()
1590+
expected_auth_header = f"Basic {encoded_user_pass}"
1591+
assert rest_mock.last_request.headers["Authorization"] == expected_auth_header
1592+
15841593

15851594
def test_rest_catalog_with_custom_auth_type_no_impl() -> None:
15861595
# Given

0 commit comments

Comments
 (0)