1
0
mirror of synced 2026-01-06 15:03:36 -05:00

🎉 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:
Arthur Galuza
2021-08-19 08:41:14 +03:00
committed by GitHub
parent 11bddd1119
commit 51d406d6f2
11 changed files with 69 additions and 19 deletions

View File

@@ -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.