From 77ac316e7c2628c1148898cd4e75a01cb30c2c5a Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Fri, 14 Oct 2022 15:32:44 +0200 Subject: [PATCH 01/17] add basic auth for Lever --- .../integration_tests/sample_config.json | 4 ++++ .../source_lever_hiring/source.py | 15 ++++++++------ .../source_lever_hiring/spec.json | 20 +++++++++++++++++++ .../unit_tests/test_source.py | 3 ++- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json index 2730c7b0ee81..8e766e3bc602 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json +++ b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json @@ -4,4 +4,8 @@ "refresh_token": "refresh_token", "environment": "Sandbox", "start_date": "2021-07-12T00:00:00Z" +}, +{ + "api_key": "c1adBeHUJKqyPM0X01tshKl4Pwh1LyPdmlorXjfmoDE0lVxZl", + "start_date": "2021-07-12T00:00:00Z" } diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py index d70ef1c2abef..0e4c7125511d 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py @@ -6,17 +6,20 @@ from airbyte_cdk.sources import AbstractSource from airbyte_cdk.sources.streams import Stream -from airbyte_cdk.sources.streams.http.auth import Oauth2Authenticator +from airbyte_cdk.sources.streams.http.auth import Oauth2Authenticator, BasicHttpAuthenticator from .streams import Applications, Interviews, Notes, Offers, Opportunities, Referrals, Users def _auth_from_config(config): - return Oauth2Authenticator( - client_id=config["credentials"]["client_id"], - client_secret=config["credentials"]["client_secret"], - refresh_token=config["credentials"]["refresh_token"], - token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token", + if config and config["credentials"] and 'api_key' in config["credentials"]: + return BasicHttpAuthenticator(username=config["credentials"]["api_key"], password = None, auth_method="Basic") + else: + return Oauth2Authenticator( + client_id=config["credentials"]["client_id"], + client_secret=config["credentials"]["client_secret"], + refresh_token=config["credentials"]["refresh_token"], + token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token", ) diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json index 751b39c470f9..b504e01daf8e 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json @@ -14,6 +14,26 @@ "description": "Choose how to authenticate to Lever Hiring.", "type": "object", "oneOf": [ + { + "type": "object", + "title": "Authenticate via Lever (Api Key)", + "required": ["api_key"], + "properties": { + "auth_type": { + "type": "string", + "const": "Api Key", + "enum": ["Api Key"], + "default": "Api Key", + "order": 0 + }, + "api_key": { + "title": "Api key", + "type": "string", + "description": "The Api Key of your Lever Hiring account.", + "airbyte_secret": true, + "order":1} + } + }, { "type": "object", "title": "Authenticate via Lever (OAuth)", diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py index 942c2ac8e6c3..3acc3f0c43b7 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py @@ -10,7 +10,8 @@ def setup_responses(): responses.add( - responses.POST, "https://sandbox-lever.auth0.com/oauth/token", json={"access_token": "fake_access_token", "expires_in": 3600} + responses.POST, "https://sandbox-lever.auth0.com/oauth/token", json={"access_token": "fake_access_token", "expires_in": 3600}, + responses.GET, "https://api.lever.co/v1/opportunities", json={"api_key": "fake_api_key", "expires_in": 3600} ) From 48c76d2c0422bdf35f99256433698c9d8169ede9 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Fri, 14 Oct 2022 16:04:58 +0200 Subject: [PATCH 02/17] Update lever-hiring.md --- docs/integrations/sources/lever-hiring.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/integrations/sources/lever-hiring.md b/docs/integrations/sources/lever-hiring.md index 5c881dcec3ac..7c645ef51a74 100644 --- a/docs/integrations/sources/lever-hiring.md +++ b/docs/integrations/sources/lever-hiring.md @@ -43,6 +43,7 @@ The Lever Hiring connector should not run into Lever Hiring API limitations unde | Version | Date | Pull Request | Subject | | :--- | :--- | :--- | :--- | +| 0.1.3 | 2022-10-14 | [17996](https://github.com/airbytehq/airbyte/pull/17996) | Add Basic Auth management | | 0.1.2 | 2021-12-30 | [9214](https://github.com/airbytehq/airbyte/pull/9214) | Update title and descriptions | | 0.1.1 | 2021-12-16 | [7677](https://github.com/airbytehq/airbyte/pull/7677) | OAuth Automated Authentication | | 0.1.0 | 2021-09-22 | [6141](https://github.com/airbytehq/airbyte/pull/6141) | Add Lever Hiring Source Connector | From 77b10a653b1056c959664416a6c89eafb6f49e07 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Tue, 18 Oct 2022 17:39:31 +0200 Subject: [PATCH 03/17] Update spec.json --- .../integration_tests/spec.json | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json index 751b39c470f9..b504e01daf8e 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json @@ -14,6 +14,26 @@ "description": "Choose how to authenticate to Lever Hiring.", "type": "object", "oneOf": [ + { + "type": "object", + "title": "Authenticate via Lever (Api Key)", + "required": ["api_key"], + "properties": { + "auth_type": { + "type": "string", + "const": "Api Key", + "enum": ["Api Key"], + "default": "Api Key", + "order": 0 + }, + "api_key": { + "title": "Api key", + "type": "string", + "description": "The Api Key of your Lever Hiring account.", + "airbyte_secret": true, + "order":1} + } + }, { "type": "object", "title": "Authenticate via Lever (OAuth)", From 3d6d83c6c63597d0b8ed46038d17989b38ba9712 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Tue, 18 Oct 2022 17:39:37 +0200 Subject: [PATCH 04/17] Update source.py --- .../source-lever-hiring/source_lever_hiring/source.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py index 0e4c7125511d..056bb5158bc8 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py @@ -12,16 +12,17 @@ def _auth_from_config(config): - if config and config["credentials"] and 'api_key' in config["credentials"]: + if config["auth_type"] == 'Api Key': return BasicHttpAuthenticator(username=config["credentials"]["api_key"], password = None, auth_method="Basic") - else: + elif config["auth_type"] == 'Client': return Oauth2Authenticator( client_id=config["credentials"]["client_id"], client_secret=config["credentials"]["client_secret"], refresh_token=config["credentials"]["refresh_token"], - token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token", - ) - + token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token") + else: + print("Auth type was not configured properly") + return None class SourceLeverHiring(AbstractSource): URL_MAP_ACCORDING_ENVIRONMENT = { From 62c7732ded20c4e172f85fe69fab578f8c918347 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Tue, 18 Oct 2022 18:49:43 +0200 Subject: [PATCH 05/17] Revert "Update spec.json" This reverts commit 77b10a653b1056c959664416a6c89eafb6f49e07. --- .../integration_tests/spec.json | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json index b504e01daf8e..751b39c470f9 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json @@ -14,26 +14,6 @@ "description": "Choose how to authenticate to Lever Hiring.", "type": "object", "oneOf": [ - { - "type": "object", - "title": "Authenticate via Lever (Api Key)", - "required": ["api_key"], - "properties": { - "auth_type": { - "type": "string", - "const": "Api Key", - "enum": ["Api Key"], - "default": "Api Key", - "order": 0 - }, - "api_key": { - "title": "Api key", - "type": "string", - "description": "The Api Key of your Lever Hiring account.", - "airbyte_secret": true, - "order":1} - } - }, { "type": "object", "title": "Authenticate via Lever (OAuth)", From 24cc0327e41d7f0ffec9764fb4122c690d1809f3 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Tue, 18 Oct 2022 18:56:19 +0200 Subject: [PATCH 06/17] Revert "Update source.py" This reverts commit 3d6d83c6c63597d0b8ed46038d17989b38ba9712. --- .../source-lever-hiring/source_lever_hiring/source.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py index 056bb5158bc8..0e4c7125511d 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py @@ -12,17 +12,16 @@ def _auth_from_config(config): - if config["auth_type"] == 'Api Key': + if config and config["credentials"] and 'api_key' in config["credentials"]: return BasicHttpAuthenticator(username=config["credentials"]["api_key"], password = None, auth_method="Basic") - elif config["auth_type"] == 'Client': + else: return Oauth2Authenticator( client_id=config["credentials"]["client_id"], client_secret=config["credentials"]["client_secret"], refresh_token=config["credentials"]["refresh_token"], - token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token") - else: - print("Auth type was not configured properly") - return None + token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token", + ) + class SourceLeverHiring(AbstractSource): URL_MAP_ACCORDING_ENVIRONMENT = { From e1506cfb5b163a56ffaac069c96f1c670cd874f0 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Wed, 19 Oct 2022 14:24:11 +0200 Subject: [PATCH 07/17] Update spec.json --- .../source-lever-hiring/source_lever_hiring/spec.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json index b504e01daf8e..ef3fe08d0c74 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json @@ -31,7 +31,8 @@ "type": "string", "description": "The Api Key of your Lever Hiring account.", "airbyte_secret": true, - "order":1} + "order":1 + } } }, { From ddadfe1d068c57fc1b8a51b7253ccd0023dfe488 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Wed, 19 Oct 2022 14:27:49 +0200 Subject: [PATCH 08/17] update spec.json, replace sample config, change check to auth_type --- .../integration_tests/sample_config.json | 14 ++++------- .../integration_tests/spec.json | 21 ++++++++++++++++ .../source_lever_hiring/source.py | 24 ++++++++++++------- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json index 8e766e3bc602..a14faaa96e2e 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json +++ b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json @@ -1,11 +1,7 @@ -{ - "client_id": "client_id", - "client_secret": "client_secret", - "refresh_token": "refresh_token", - "environment": "Sandbox", - "start_date": "2021-07-12T00:00:00Z" -}, -{ +{ "credentials" : { "api_key": "c1adBeHUJKqyPM0X01tshKl4Pwh1LyPdmlorXjfmoDE0lVxZl", - "start_date": "2021-07-12T00:00:00Z" + "auth_type": "Api Key" +}, + "start_date": "2021-07-12T00:00:00Z", + "environment": "Sandbox" } diff --git a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json index 751b39c470f9..ef3fe08d0c74 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json @@ -14,6 +14,27 @@ "description": "Choose how to authenticate to Lever Hiring.", "type": "object", "oneOf": [ + { + "type": "object", + "title": "Authenticate via Lever (Api Key)", + "required": ["api_key"], + "properties": { + "auth_type": { + "type": "string", + "const": "Api Key", + "enum": ["Api Key"], + "default": "Api Key", + "order": 0 + }, + "api_key": { + "title": "Api key", + "type": "string", + "description": "The Api Key of your Lever Hiring account.", + "airbyte_secret": true, + "order":1 + } + } + }, { "type": "object", "title": "Authenticate via Lever (OAuth)", diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py index 0e4c7125511d..4aa941941901 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py @@ -12,15 +12,21 @@ def _auth_from_config(config): - if config and config["credentials"] and 'api_key' in config["credentials"]: - return BasicHttpAuthenticator(username=config["credentials"]["api_key"], password = None, auth_method="Basic") - else: - return Oauth2Authenticator( - client_id=config["credentials"]["client_id"], - client_secret=config["credentials"]["client_secret"], - refresh_token=config["credentials"]["refresh_token"], - token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token", - ) + try: + if config["credentials"]["auth_type"] == "Api Key": + return BasicHttpAuthenticator(username=config["credentials"]["api_key"], password = None, auth_method="Basic") + elif config["credentials"]["auth_type"] == "Client": + return Oauth2Authenticator( + client_id=config["credentials"]["client_id"], + client_secret=config["credentials"]["client_secret"], + refresh_token=config["credentials"]["refresh_token"], + token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token") + else: + print("Auth type was not configured properly") + return None + except Exception as e: + print(f"{e.__class__} occurred, there's an issue with credentials in your config") + raise e class SourceLeverHiring(AbstractSource): From 3701f076ebd332926daaff88a786230e25e387bd Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Wed, 19 Oct 2022 15:25:00 +0200 Subject: [PATCH 09/17] unit tests with parametrize --- .../unit_tests/conftest.py | 13 +++++++++-- .../unit_tests/test_source.py | 23 ++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py index 75250b480fbf..0b44f5304d83 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py @@ -4,9 +4,8 @@ from pytest import fixture - @fixture -def test_config(): +def test_config_client(): return { "credentials": { "client_id": "test_client_id", @@ -18,6 +17,16 @@ def test_config(): "environment": "Sandbox", "start_date": "2021-05-07T00:00:00Z", } + +@fixture +def test_config_key(): + return { + "credentials": { + "api_key": "test_api_key", + }, + "environment": "Sandbox", + "start_date": "2021-05-07T00:00:00Z", + } @fixture diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py index 3acc3f0c43b7..f36ed970983d 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py @@ -3,29 +3,30 @@ # from unittest.mock import MagicMock - +import pytest import responses from source_lever_hiring.source import SourceLeverHiring -def setup_responses(): - responses.add( - responses.POST, "https://sandbox-lever.auth0.com/oauth/token", json={"access_token": "fake_access_token", "expires_in": 3600}, - responses.GET, "https://api.lever.co/v1/opportunities", json={"api_key": "fake_api_key", "expires_in": 3600} - ) - +@pytest.mark.parametrize( + ("response, url, payload, test_config"), + [ + (responses.POST, "https://sandbox-lever.auth0.com/oauth/token", json={"access_token": "fake_access_token", "expires_in": 3600}), test_config_client() + (responses.GET, "https://api.lever.co/v1/opportunities", json={"api_key": "fake_api_key", "expires_in": 3600}), test_config_key(), + ], +) @responses.activate -def test_check_connection(test_config): - setup_responses() +def test_check_connection(response, url, payload, test_config): + responses.add(response, url, payload) source = SourceLeverHiring() logger_mock = MagicMock() assert source.check_connection(logger_mock, test_config) == (True, None) @responses.activate -def test_streams(test_config): - setup_responses() +def test_streams(response, url, payload, test_config): + responses.add(response, url, payload) source = SourceLeverHiring() streams = source.streams(test_config) expected_streams_number = 7 From b8fae740995801f366b340bc786fc25029e23c29 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Mon, 24 Oct 2022 11:07:23 +0200 Subject: [PATCH 10/17] gradlew formatting python + fixing bugs to ensure it works --- .../integration_tests/sample_config.json | 8 ++-- .../source_lever_hiring/source.py | 7 +-- .../unit_tests/conftest.py | 46 ++++++++++--------- .../unit_tests/test_source.py | 18 ++++++-- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json index a14faaa96e2e..e5ac0a8d0b19 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json +++ b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/sample_config.json @@ -1,7 +1,7 @@ { "credentials" : { - "api_key": "c1adBeHUJKqyPM0X01tshKl4Pwh1LyPdmlorXjfmoDE0lVxZl", - "auth_type": "Api Key" -}, + "api_key": "c1adBeHUJKqyPM0X01tshKl4Pwh1LyPdmlorXjfmoDE0lVxZl", + "auth_type": "Api Key" + }, "start_date": "2021-07-12T00:00:00Z", "environment": "Sandbox" -} +} \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py index 4aa941941901..0ec31c366fd8 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/source.py @@ -6,7 +6,7 @@ from airbyte_cdk.sources import AbstractSource from airbyte_cdk.sources.streams import Stream -from airbyte_cdk.sources.streams.http.auth import Oauth2Authenticator, BasicHttpAuthenticator +from airbyte_cdk.sources.streams.http.auth import BasicHttpAuthenticator, Oauth2Authenticator from .streams import Applications, Interviews, Notes, Offers, Opportunities, Referrals, Users @@ -14,13 +14,14 @@ def _auth_from_config(config): try: if config["credentials"]["auth_type"] == "Api Key": - return BasicHttpAuthenticator(username=config["credentials"]["api_key"], password = None, auth_method="Basic") + return BasicHttpAuthenticator(username=config["credentials"]["api_key"], password=None, auth_method="Basic") elif config["credentials"]["auth_type"] == "Client": return Oauth2Authenticator( client_id=config["credentials"]["client_id"], client_secret=config["credentials"]["client_secret"], refresh_token=config["credentials"]["refresh_token"], - token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token") + token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token", + ) else: print("Auth type was not configured properly") return None diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py index 0b44f5304d83..7404478006cf 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py @@ -4,29 +4,31 @@ from pytest import fixture + @fixture -def test_config_client(): - return { - "credentials": { - "client_id": "test_client_id", - "client_secret": "test_client_secret", - "refresh_token": "test_refresh_token", - "access_token": "test_access_token", - "expires_in": 3600, - }, - "environment": "Sandbox", - "start_date": "2021-05-07T00:00:00Z", - } - -@fixture -def test_config_key(): - return { - "credentials": { - "api_key": "test_api_key", - }, - "environment": "Sandbox", - "start_date": "2021-05-07T00:00:00Z", - } +def test_config(auth_type): + if auth_type == "Client": + return { + "credentials": { + "client_id": "test_client_id", + "client_secret": "test_client_secret", + "refresh_token": "test_refresh_token", + "access_token": "test_access_token", + "expires_in": 3600, + }, + "environment": "Sandbox", + "start_date": "2021-05-07T00:00:00Z", + } + elif auth_type == "Api Key": + return { + "credentials": { + "api_key": "test_api_key", + }, + "environment": "Sandbox", + "start_date": "2021-05-07T00:00:00Z", + } + else: + return None @fixture diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py index f36ed970983d..8d48c544f84b 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py @@ -3,19 +3,29 @@ # from unittest.mock import MagicMock + import pytest import responses +from conftest import test_config from source_lever_hiring.source import SourceLeverHiring @pytest.mark.parametrize( - ("response, url, payload, test_config"), + ("response", "url", "payload", "test_config"), [ - (responses.POST, "https://sandbox-lever.auth0.com/oauth/token", json={"access_token": "fake_access_token", "expires_in": 3600}), test_config_client() - (responses.GET, "https://api.lever.co/v1/opportunities", json={"api_key": "fake_api_key", "expires_in": 3600}), test_config_key(), + ( + responses.POST, + "https://sandbox-lever.auth0.com/oauth/token", + {"access_token": "fake_access_token", "expires_in": 3600}, + test_config(auth_type="Client"), + )( + responses.GET, + "https://api.lever.co/v1/opportunities", + {"api_key": "fake_api_key", "expires_in": 3600}, + test_config(auth_type="Api Key"), + ), ], ) - @responses.activate def test_check_connection(response, url, payload, test_config): responses.add(response, url, payload) From 088460d6bea824937ac4e14ca99ea3ee2b1b6783 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Mon, 24 Oct 2022 14:51:27 +0200 Subject: [PATCH 11/17] modifs as suggested by reviewer --- .../unit_tests/conftest.py | 26 ---------- .../unit_tests/test_source.py | 49 ++++++++++++------- 2 files changed, 30 insertions(+), 45 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py index 7404478006cf..a02ce7a2939f 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/conftest.py @@ -5,32 +5,6 @@ from pytest import fixture -@fixture -def test_config(auth_type): - if auth_type == "Client": - return { - "credentials": { - "client_id": "test_client_id", - "client_secret": "test_client_secret", - "refresh_token": "test_refresh_token", - "access_token": "test_access_token", - "expires_in": 3600, - }, - "environment": "Sandbox", - "start_date": "2021-05-07T00:00:00Z", - } - elif auth_type == "Api Key": - return { - "credentials": { - "api_key": "test_api_key", - }, - "environment": "Sandbox", - "start_date": "2021-05-07T00:00:00Z", - } - else: - return None - - @fixture def test_full_refresh_config(): return {"base_url": "test_base_url"} diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py index 8d48c544f84b..c032b84aba35 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py @@ -6,7 +6,6 @@ import pytest import responses -from conftest import test_config from source_lever_hiring.source import SourceLeverHiring @@ -16,28 +15,40 @@ ( responses.POST, "https://sandbox-lever.auth0.com/oauth/token", - {"access_token": "fake_access_token", "expires_in": 3600}, - test_config(auth_type="Client"), - )( - responses.GET, - "https://api.lever.co/v1/opportunities", - {"api_key": "fake_api_key", "expires_in": 3600}, - test_config(auth_type="Api Key"), + {"access_token": "test_access_token", "expires_in": 3600}, + { + "credentials": { + "auth_type": "Client", + "client_id": "test_client_id", + "client_secret": "test_client_secret", + "refresh_token": "test_refresh_token", + "access_token": "test_access_token", + "expires_in": 3600, + }, + "environment": "Sandbox", + "start_date": "2021-05-07T00:00:00Z", + }, + ), + ( + None, + None, + None, + { + "credentials": { + "auth_type": "Api Key", + "api_key": "test_api_key", + }, + "environment": "Sandbox", + "start_date": "2021-05-07T00:00:00Z", + }, ), ], ) @responses.activate -def test_check_connection(response, url, payload, test_config): - responses.add(response, url, payload) +def test_source(response, url, payload, test_config): + if response: + responses.add(response, url, payload) source = SourceLeverHiring() logger_mock = MagicMock() assert source.check_connection(logger_mock, test_config) == (True, None) - - -@responses.activate -def test_streams(response, url, payload, test_config): - responses.add(response, url, payload) - source = SourceLeverHiring() - streams = source.streams(test_config) - expected_streams_number = 7 - assert len(streams) == expected_streams_number + assert len(source.streams(test_config)) == 7 From 12fcc7e42232e2fb7bb22d56026f0020e7fdce6a Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Mon, 24 Oct 2022 15:13:26 +0200 Subject: [PATCH 12/17] Update test_source.py --- .../connectors/source-lever-hiring/unit_tests/test_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py index c032b84aba35..222a41b42083 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py @@ -47,7 +47,7 @@ @responses.activate def test_source(response, url, payload, test_config): if response: - responses.add(response, url, payload) + responses.add(response, url, json = payload) source = SourceLeverHiring() logger_mock = MagicMock() assert source.check_connection(logger_mock, test_config) == (True, None) From c9ee8cf9c7a72e8f9919b9f612ae0a073e489f9e Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Mon, 24 Oct 2022 15:13:59 +0200 Subject: [PATCH 13/17] Update test_source.py --- .../connectors/source-lever-hiring/unit_tests/test_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py index 222a41b42083..edbe8d50634e 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py +++ b/airbyte-integrations/connectors/source-lever-hiring/unit_tests/test_source.py @@ -47,7 +47,7 @@ @responses.activate def test_source(response, url, payload, test_config): if response: - responses.add(response, url, json = payload) + responses.add(response, url, json=payload) source = SourceLeverHiring() logger_mock = MagicMock() assert source.check_connection(logger_mock, test_config) == (True, None) From 57251e1989c4f4b8748089d4ae04159e8ea88ea3 Mon Sep 17 00:00:00 2001 From: alexchouraki Date: Tue, 25 Oct 2022 11:15:32 +0200 Subject: [PATCH 14/17] fixing specs in order for integration tests to pass --- .../source-lever-hiring/integration_tests/spec.json | 10 ---------- .../source-lever-hiring/source_lever_hiring/spec.json | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json index ef3fe08d0c74..df774967f08b 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json @@ -22,8 +22,6 @@ "auth_type": { "type": "string", "const": "Api Key", - "enum": ["Api Key"], - "default": "Api Key", "order": 0 }, "api_key": { @@ -43,8 +41,6 @@ "auth_type": { "type": "string", "const": "Client", - "enum": ["Client"], - "default": "Client", "order": 0 }, "client_id": { @@ -58,12 +54,6 @@ "description": "The Client Secret of your Lever Hiring developer application.", "airbyte_secret": true }, - "option_title": { - "type": "string", - "title": "Credentials Title", - "description": "OAuth Credentials", - "const": "OAuth Credentials" - }, "refresh_token": { "type": "string", "title": "Refresh Token", diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json index ef3fe08d0c74..df774967f08b 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json @@ -22,8 +22,6 @@ "auth_type": { "type": "string", "const": "Api Key", - "enum": ["Api Key"], - "default": "Api Key", "order": 0 }, "api_key": { @@ -43,8 +41,6 @@ "auth_type": { "type": "string", "const": "Client", - "enum": ["Client"], - "default": "Client", "order": 0 }, "client_id": { @@ -58,12 +54,6 @@ "description": "The Client Secret of your Lever Hiring developer application.", "airbyte_secret": true }, - "option_title": { - "type": "string", - "title": "Credentials Title", - "description": "OAuth Credentials", - "const": "OAuth Credentials" - }, "refresh_token": { "type": "string", "title": "Refresh Token", From 007c45913616b2754b6a58951fad8868c02dca79 Mon Sep 17 00:00:00 2001 From: Yiyang Li Date: Tue, 25 Oct 2022 11:45:07 -0700 Subject: [PATCH 15/17] fix acceptance test TestSpec.test_oauth_flow_parameters --- .../integration_tests/spec.json | 38 +++++++++---------- .../source_lever_hiring/spec.json | 38 +++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json index df774967f08b..59b326343ee4 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/integration_tests/spec.json @@ -14,25 +14,6 @@ "description": "Choose how to authenticate to Lever Hiring.", "type": "object", "oneOf": [ - { - "type": "object", - "title": "Authenticate via Lever (Api Key)", - "required": ["api_key"], - "properties": { - "auth_type": { - "type": "string", - "const": "Api Key", - "order": 0 - }, - "api_key": { - "title": "Api key", - "type": "string", - "description": "The Api Key of your Lever Hiring account.", - "airbyte_secret": true, - "order":1 - } - } - }, { "type": "object", "title": "Authenticate via Lever (OAuth)", @@ -61,6 +42,25 @@ "airbyte_secret": true } } + }, + { + "type": "object", + "title": "Authenticate via Lever (Api Key)", + "required": ["api_key"], + "properties": { + "auth_type": { + "type": "string", + "const": "Api Key", + "order": 0 + }, + "api_key": { + "title": "Api key", + "type": "string", + "description": "The Api Key of your Lever Hiring account.", + "airbyte_secret": true, + "order":1 + } + } } ] }, diff --git a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json index df774967f08b..59b326343ee4 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json +++ b/airbyte-integrations/connectors/source-lever-hiring/source_lever_hiring/spec.json @@ -14,25 +14,6 @@ "description": "Choose how to authenticate to Lever Hiring.", "type": "object", "oneOf": [ - { - "type": "object", - "title": "Authenticate via Lever (Api Key)", - "required": ["api_key"], - "properties": { - "auth_type": { - "type": "string", - "const": "Api Key", - "order": 0 - }, - "api_key": { - "title": "Api key", - "type": "string", - "description": "The Api Key of your Lever Hiring account.", - "airbyte_secret": true, - "order":1 - } - } - }, { "type": "object", "title": "Authenticate via Lever (OAuth)", @@ -61,6 +42,25 @@ "airbyte_secret": true } } + }, + { + "type": "object", + "title": "Authenticate via Lever (Api Key)", + "required": ["api_key"], + "properties": { + "auth_type": { + "type": "string", + "const": "Api Key", + "order": 0 + }, + "api_key": { + "title": "Api key", + "type": "string", + "description": "The Api Key of your Lever Hiring account.", + "airbyte_secret": true, + "order":1 + } + } } ] }, From 69aead2e2990f1574e2f41209b5dbfdd157167b9 Mon Sep 17 00:00:00 2001 From: Yiyang Li Date: Wed, 26 Oct 2022 08:16:08 -0700 Subject: [PATCH 16/17] bump the docker image version to 0.1.3 --- airbyte-integrations/connectors/source-lever-hiring/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-lever-hiring/Dockerfile b/airbyte-integrations/connectors/source-lever-hiring/Dockerfile index f76384f30350..55095a551839 100644 --- a/airbyte-integrations/connectors/source-lever-hiring/Dockerfile +++ b/airbyte-integrations/connectors/source-lever-hiring/Dockerfile @@ -34,5 +34,5 @@ COPY source_lever_hiring ./source_lever_hiring ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] -LABEL io.airbyte.version=0.1.2 +LABEL io.airbyte.version=0.1.3 LABEL io.airbyte.name=airbyte/source-lever-hiring From 4d52c6e4ad84d09de87c585a7b3181926c131f98 Mon Sep 17 00:00:00 2001 From: Octavia Squidington III Date: Wed, 26 Oct 2022 15:40:21 +0000 Subject: [PATCH 17/17] auto-bump connector version --- .../resources/seed/source_definitions.yaml | 2 +- .../src/main/resources/seed/source_specs.yaml | 25 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml index 46a0fe2a1498..a35031c20096 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -586,7 +586,7 @@ - name: Lever Hiring sourceDefinitionId: 3981c999-bd7d-4afc-849b-e53dea90c948 dockerRepository: airbyte/source-lever-hiring - dockerImageTag: 0.1.2 + dockerImageTag: 0.1.3 documentationUrl: https://docs.airbyte.com/integrations/sources/lever-hiring icon: leverhiring.svg sourceType: api diff --git a/airbyte-config/init/src/main/resources/seed/source_specs.yaml b/airbyte-config/init/src/main/resources/seed/source_specs.yaml index 3706bf8b0fa5..b46847a054ea 100644 --- a/airbyte-config/init/src/main/resources/seed/source_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_specs.yaml @@ -5741,7 +5741,7 @@ supportsNormalization: false supportsDBT: false supported_destination_sync_modes: [] -- dockerImage: "airbyte/source-lever-hiring:0.1.2" +- dockerImage: "airbyte/source-lever-hiring:0.1.3" spec: documentationUrl: "https://docs.airbyte.com/integrations/sources/lever-hiring" changelogUrl: "https://docs.airbyte.com/integrations/sources/lever-hiring#changelog" @@ -5767,9 +5767,6 @@ auth_type: type: "string" const: "Client" - enum: - - "Client" - default: "Client" order: 0 client_id: title: "Client ID" @@ -5780,16 +5777,26 @@ type: "string" description: "The Client Secret of your Lever Hiring developer application." airbyte_secret: true - option_title: - type: "string" - title: "Credentials Title" - description: "OAuth Credentials" - const: "OAuth Credentials" refresh_token: type: "string" title: "Refresh Token" description: "The token for obtaining new access token." airbyte_secret: true + - type: "object" + title: "Authenticate via Lever (Api Key)" + required: + - "api_key" + properties: + auth_type: + type: "string" + const: "Api Key" + order: 0 + api_key: + title: "Api key" + type: "string" + description: "The Api Key of your Lever Hiring account." + airbyte_secret: true + order: 1 start_date: order: 0 type: "string"