コード例 #1
0
def test_basic_and_api_key_authentication_can_be_combined(
        httpx_mock: HTTPXMock):
    basic_auth = httpx_auth.Basic("test_user", "test_pwd")
    api_key_auth = httpx_auth.HeaderApiKey("my_provided_api_key")
    header = get_header(httpx_mock, basic_auth & api_key_auth)
    assert header.get("Authorization") == "Basic dGVzdF91c2VyOnRlc3RfcHdk"
    assert header.get("X-Api-Key") == "my_provided_api_key"
コード例 #2
0
def test_basic_and_multiple_authentication_can_be_combined(
        token_cache, httpx_mock: HTTPXMock):
    basic_auth = httpx_auth.Basic("test_user", "test_pwd")
    api_key_auth2 = httpx_auth.HeaderApiKey("my_provided_api_key2",
                                            header_name="X-Api-Key2")
    api_key_auth3 = httpx_auth.HeaderApiKey("my_provided_api_key3",
                                            header_name="X-Api-Key3")
    header = get_header(httpx_mock,
                        basic_auth & (api_key_auth2 & api_key_auth3))
    assert header.get("Authorization") == "Basic dGVzdF91c2VyOnRlc3RfcHdk"
    assert header.get("X-Api-Key2") == "my_provided_api_key2"
    assert header.get("X-Api-Key3") == "my_provided_api_key3"
コード例 #3
0
def test_basic_authentication_send_authorization_header(httpx_mock: HTTPXMock):
    auth = httpx_auth.Basic("test_user", "test_pwd")
    assert (get_header(
        httpx_mock,
        auth).get("Authorization") == "Basic dGVzdF91c2VyOnRlc3RfcHdk")