-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source 3PL Central: add a check for HTTP URLs in config #18763
Source 3PL Central: add a check for HTTP URLs in config #18763
Conversation
/test connector=connectors/source-tplcentral
Build FailedTest summary info:
|
/test connector=connectors/source-tplcentral
Build FailedTest summary info:
|
/test connector=connectors/source-tplcentral
Build FailedTest summary info:
|
local unit test results: ============================= test session starts ==============================
platform linux -- Python 3.9.11, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /home/arsenlosenko/.pyenv/versions/3.9.11/envs/source-tplcentral/bin/python3.9
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/arsenlosenko/projects/airbyteio/airbyte/airbyte-integrations/connectors/source-tplcentral/.hypothesis/examples')
rootdir: /home/arsenlosenko/projects/airbyteio/airbyte, configfile: pytest.ini
plugins: hypothesis-6.54.6, mock-3.6.1, timeout-1.4.2, cov-3.0.0, requests-mock-1.9.3, sugar-0.9.5
collecting ... collected 22 items
unit_tests/test_incremental_streams.py::test_cursor_field PASSED
unit_tests/test_incremental_streams.py::test_get_updated_state PASSED
unit_tests/test_incremental_streams.py::test_stream_slices PASSED
unit_tests/test_incremental_streams.py::test_supports_incremental PASSED
unit_tests/test_incremental_streams.py::test_source_defined_cursor PASSED
unit_tests/test_incremental_streams.py::test_stream_checkpoint_interval PASSED
unit_tests/test_source.py::test_check_connection PASSED
unit_tests/test_source.py::test_auth_raises_configuration_error {"type": "LOG", "log": {"level": "ERROR", "message": "'url_base' parameter should be a HTTPS URL"}}
PASSED
unit_tests/test_source.py::test_streams PASSED
unit_tests/test_streams.py::test_request_params PASSED
unit_tests/test_streams.py::test_next_page_token PASSED
unit_tests/test_streams.py::test_next_page_token_with_page_size PASSED
unit_tests/test_streams.py::test_parse_response PASSED
unit_tests/test_streams.py::test_parse_response_with_primary_key PASSED
unit_tests/test_streams.py::test_parse_response_with_cursor_field PASSED
unit_tests/test_streams.py::test_request_headers PASSED
unit_tests/test_streams.py::test_http_method PASSED
unit_tests/test_streams.py::test_should_retry[HTTPStatus.OK-False] PASSED
unit_tests/test_streams.py::test_should_retry[HTTPStatus.BAD_REQUEST-False] PASSED
unit_tests/test_streams.py::test_should_retry[HTTPStatus.TOO_MANY_REQUESTS-True] PASSED
unit_tests/test_streams.py::test_should_retry[HTTPStatus.INTERNAL_SERVER_ERROR-True] PASSED
unit_tests/test_streams.py::test_backoff_time PASSED
=============================== warnings summary ===============================
airbyte-integrations/connectors/source-tplcentral/unit_tests/test_incremental_streams.py: 6 warnings
airbyte-integrations/connectors/source-tplcentral/unit_tests/test_source.py: 6 warnings
airbyte-integrations/connectors/source-tplcentral/unit_tests/test_streams.py: 13 warnings
/home/arsenlosenko/.pyenv/versions/3.9.11/envs/source-tplcentral/lib/python3.9/site-packages/airbyte_cdk/sources/streams/http/http.py:43: DeprecationWarning: Call to deprecated class NoAuth. (Set `authenticator=None` instead) -- Deprecated since version 0.1.20.
self._authenticator: HttpAuthenticator = NoAuth()
airbyte-integrations/connectors/source-tplcentral/unit_tests/test_incremental_streams.py: 6 warnings
airbyte-integrations/connectors/source-tplcentral/unit_tests/test_source.py: 6 warnings
airbyte-integrations/connectors/source-tplcentral/unit_tests/test_streams.py: 13 warnings
/home/arsenlosenko/.pyenv/versions/3.9.11/envs/source-tplcentral/lib/python3.9/site-packages/deprecated/classic.py:173: DeprecationWarning: Call to deprecated class HttpAuthenticator. (Use requests.auth.AuthBase instead) -- Deprecated since version 0.1.20.
return old_new1(cls, *args, **kwargs)
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================= 22 passed, 50 warnings in 0.39s ========================
|
as stated in this #16521 (comment), we cannot run integration tests for this connector as of now, so we can only rely on unit tests. Results of local test suite run is in the previous comment. |
@@ -63,6 +75,11 @@ def refresh_access_token(self) -> Tuple[str, int]: | |||
|
|||
class SourceTplcentral(AbstractSource): | |||
def _auth(self, config): | |||
url_base = config.get("url_base") | |||
if url_base.startswith("http://"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if I enter "url_base" like "HtTp://" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arsenlosenko I suggest you'd better restrict this using regexp in a spec like here and add a SAT test instead of a unit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davydov-d yep, it should be a better solution, I'll do that then, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grubberr can you check again please, I've made the changes that were suggested
* Source TPI Central: add a check for HTTP URLs in config * Update changelog * Fix tests * Add missing attributes to fix the test that wasn't working * Add HTTPS URL check to SAT tests * Remove previously added changes
What
Resolving:
#16521
How
url_base
parameter in config, so in case of HTTP base URL theConfigurationError
would be raised. And added a test to cover this caseRecommended reading order
x.java
y.python
🚨 User Impact 🚨
Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.
Pre-merge Checklist
Expand the relevant checklist and delete the others.
New Connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampledocs/integrations/README.md
airbyte-integrations/builds.md
Airbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereUpdating a connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampleAirbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereConnector Generator
-scaffold
in their name) have been updated with the latest scaffold by running./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates
then checking in your changesTests
Unit
Put your unit tests output here.
Integration
Put your integration tests output here.
Acceptance
Put your acceptance tests output here.