def test_basic_and_api_key_authentication_can_be_combined(
        responses: RequestsMock):
    basic_auth = requests_auth.Basic("test_user", "test_pwd")
    api_key_auth = requests_auth.HeaderApiKey("my_provided_api_key")
    header = get_header(responses, basic_auth + api_key_auth)
    assert header.get("Authorization") == "Basic dGVzdF91c2VyOnRlc3RfcHdk"
    assert header.get("X-Api-Key") == "my_provided_api_key"
def test_basic_and_multiple_authentication_can_be_combined(
        token_cache, responses: RequestsMock):
    basic_auth = requests_auth.Basic("test_user", "test_pwd")
    api_key_auth2 = requests_auth.HeaderApiKey("my_provided_api_key2",
                                               header_name="X-Api-Key2")
    api_key_auth3 = requests_auth.HeaderApiKey("my_provided_api_key3",
                                               header_name="X-Api-Key3")
    header = get_header(responses,
                        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"
Exemple #3
0
def test_basic_authentication_send_authorization_header(responses: RequestsMock):
    auth = requests_auth.Basic("test_user", "test_pwd")
    assert (
        get_header(responses, auth).get("Authorization")
        == "Basic dGVzdF91c2VyOnRlc3RfcHdk"
    )
Exemple #4
0
 def test_basic_and_api_key_authentication_can_be_combined(self):
     basic_auth = requests_auth.Basic('test_user', 'test_pwd')
     api_key_auth = requests_auth.HeaderApiKey('my_provided_api_key')
     header = get_header(requests_auth.Auths(basic_auth, api_key_auth))
     self.assertEqual(header.get('Authorization'), 'Basic dGVzdF91c2VyOnRlc3RfcHdk')
     self.assertEqual(header.get('X-Api-Key'), 'my_provided_api_key')
Exemple #5
0
 def test_basic_authentication_send_authorization_header(self):
     auth = requests_auth.Basic('test_user', 'test_pwd')
     self.assertEqual(get_header(auth).get('Authorization'), 'Basic dGVzdF91c2VyOnRlc3RfcHdk')