From 97d1f6ec4f86d0a1e08845397ddea9cf811514f9 Mon Sep 17 00:00:00 2001 From: Daryna Ishchenko <80129833+darynaishchenko@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:56:48 +0200 Subject: [PATCH] CAT: fixed TestSpec.test_oauth_is_default_method to skip connector spec without predicate key (#34559) --- .../connector-acceptance-test/CHANGELOG.md | 3 + .../tests/test_core.py | 2 + .../connector-acceptance-test/pyproject.toml | 2 +- .../unit_tests/test_spec.py | 55 +++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md b/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md index 1ef8a0b8017dd..4aa3ba5ea0228 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md +++ b/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.3.1 +Fix TestSpec.test_oauth_is_default_method to skip connectors that doesn't have predicate_key object. + ## 3.3.0 Add `test_certified_connector_has_allowed_hosts` and `test_certified_connector_has_suggested_streams` tests to the `connector_attribute` test suite diff --git a/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py b/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py index 3dbac190bc8cd..dab1ba148b9c9 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py +++ b/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py @@ -539,6 +539,8 @@ def test_oauth_is_default_method(self, skip_oauth_default_method_test: bool, act advanced_auth = actual_connector_spec.advanced_auth if not advanced_auth: pytest.skip("Source does not have OAuth method.") + if not advanced_auth.predicate_key: + pytest.skip("Advanced Auth object does not have predicate_key, only one option to authenticate.") spec_schema = actual_connector_spec.connectionSpecification credentials = advanced_auth.predicate_key[0] diff --git a/airbyte-integrations/bases/connector-acceptance-test/pyproject.toml b/airbyte-integrations/bases/connector-acceptance-test/pyproject.toml index 7be03c21d32dc..728c9112ceffc 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/pyproject.toml +++ b/airbyte-integrations/bases/connector-acceptance-test/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "connector-acceptance-test" -version = "3.2.0" +version = "3.3.1" description = "Contains acceptance tests for connectors." authors = ["Airbyte "] license = "MIT" diff --git a/airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py b/airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py index e4651b2004043..4b4b1d456e756 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py +++ b/airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py @@ -990,6 +990,61 @@ def test_validate_oauth_flow(connector_spec, expected_error): ), "Credentials object does not have oneOf option.", ), + # SUCCESS: Skipped: no predicate key. + ( + ConnectorSpecification( + connectionSpecification={ + "type": "object", + "properties": { + "api_url": {"type": "object"}, + "credentials": { + "type": "object", + "properties": { + "auth_type": {"type": "string", "const": "oauth2.0"}, + "client_id": {"type": "string"}, + "client_secret": {"type": "string"}, + "access_token": {"type": "string"}, + "refresh_token": {"type": "string"}, + "token_expiry_date": {"type": "string", "format": "date-time"}, + }, + }, + }, + }, + advanced_auth={ + "auth_flow_type": "oauth2.0", + "oauth_config_specification": { + "oauth_user_input_from_connector_config_specification": { + "type": "object", + "properties": {"domain": {"type": "string", "path_in_connector_config": ["api_url"]}}, + }, + "complete_oauth_output_specification": { + "type": "object", + "properties": { + "access_token": {"type": "string", "path_in_connector_config": ["credentials", "access_token"]}, + "refresh_token": {"type": "string", "path_in_connector_config": ["credentials", "refresh_token"]}, + "token_expiry_date": { + "type": "string", + "format": "date-time", + "path_in_connector_config": ["credentials", "token_expiry_date"], + }, + }, + }, + "complete_oauth_server_input_specification": { + "type": "object", + "properties": {"client_id": {"type": "string"}, "client_secret": {"type": "string"}}, + }, + "complete_oauth_server_output_specification": { + "type": "object", + "properties": { + "client_id": {"type": "string", "path_in_connector_config": ["credentials", "client_id"]}, + "client_secret": {"type": "string", "path_in_connector_config": ["credentials", "client_secret"]}, + }, + }, + }, + }, + ), + "Advanced Auth object does not have predicate_key, only one option to authenticate.", + ) ] ) def test_validate_auth_default_method(connector_spec, expected_error):