🎉 Source Github: Add MultipleTokenAuthenticator (#5223)
* Add multiple token authenticator * Add MultipleTokenAuthenticator * Upd docs * Refactor * Upd docs * Fix merge typo * Upd multiple token support: switch to list of tokens * Upd multiple token support: refactoring * Update airbyte-integrations/connectors/source-github/source_github/spec.json Co-authored-by: Sherif A. Nada <snadalive@gmail.com> * Update airbyte-integrations/connectors/source-github/source_github/spec.json Co-authored-by: Sherif A. Nada <snadalive@gmail.com> * Cleanup, switch to MultipleTokenAuthenticator completely * Upd changelog Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
import logging
|
||||
|
||||
import requests
|
||||
from airbyte_cdk.sources.streams.http.auth import NoAuth, Oauth2Authenticator, TokenAuthenticator
|
||||
from airbyte_cdk.sources.streams.http.auth import MultipleTokenAuthenticator, NoAuth, Oauth2Authenticator, TokenAuthenticator
|
||||
from requests import Response
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
@@ -43,6 +43,16 @@ def test_token_authenticator():
|
||||
assert {"Authorization": "Bearer test-token"} == header
|
||||
|
||||
|
||||
def test_multiple_token_authenticator():
|
||||
token = MultipleTokenAuthenticator(["token1", "token2"])
|
||||
header1 = token.get_auth_header()
|
||||
assert {"Authorization": "Bearer token1"} == header1
|
||||
header2 = token.get_auth_header()
|
||||
assert {"Authorization": "Bearer token2"} == header2
|
||||
header3 = token.get_auth_header()
|
||||
assert {"Authorization": "Bearer token1"} == header3
|
||||
|
||||
|
||||
def test_no_auth():
|
||||
"""
|
||||
Should always return empty body, no matter how many times token is retrieved.
|
||||
|
||||
Reference in New Issue
Block a user