Skip to content

Commit 5fbe08c

Browse files
btkcodedevsajarin
andauthored
✨Source Auth0: Migrate Python CDK to Low-code CDK (#28972)
Co-authored-by: Sajarin <sajarindider@gmail.com>
1 parent cef79bf commit 5fbe08c

28 files changed

+222
-1183
lines changed

airbyte-integrations/connectors/source-auth0/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9.13-alpine3.15 as base
1+
FROM python:3.9.11-alpine3.15 as base
22

33
# build and load all requirements
44
FROM base as builder
@@ -34,5 +34,5 @@ COPY source_auth0 ./source_auth0
3434
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
3535
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
3636

37-
LABEL io.airbyte.version=0.3.0
37+
LABEL io.airbyte.version=0.4.0
3838
LABEL io.airbyte.name=airbyte/source-auth0

airbyte-integrations/connectors/source-auth0/README.md

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,10 @@
11
# Auth0 Source
22

3-
This is the repository for the Auth0 source connector, written in Python.
4-
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/auth0).
3+
This is the repository for the Auth0 configuration based source connector.
4+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/auth0).
55

66
## Local development
77

8-
### Prerequisites
9-
**To iterate on this connector, make sure to complete this prerequisites section.**
10-
11-
#### Minimum Python version required `= 3.9.0`
12-
13-
#### Build & Activate Virtual Environment and install dependencies
14-
From this connector directory, create a virtual environment:
15-
```
16-
python -m venv .venv
17-
```
18-
19-
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
20-
development environment of choice. To activate it from the terminal, run:
21-
```
22-
source .venv/bin/activate
23-
pip install -r requirements.txt
24-
pip install '.[tests]'
25-
```
26-
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
27-
28-
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
29-
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
30-
If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything
31-
should work as you expect.
32-
338
#### Building via Gradle
349
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
3510

@@ -39,22 +14,14 @@ To build using Gradle, from the Airbyte repository root, run:
3914
```
4015

4116
#### Create credentials
42-
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/auth0)
17+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/auth0)
4318
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_auth0/spec.yaml` file.
4419
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
45-
See `integration_tests/sample_config_access-token.json` for a sample config file.
20+
See `integration_tests/sample_config.json` for a sample config file.
4621

4722
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source auth0 test creds`
4823
and place them into `secrets/config.json`.
4924

50-
### Locally running the connector
51-
```
52-
python main.py spec
53-
python main.py check --config secrets/config.json
54-
python main.py discover --config secrets/config.json
55-
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
56-
```
57-
5825
### Locally running the connector docker image
5926

6027
#### Build
@@ -79,32 +46,15 @@ docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-auth0:dev discover --c
7946
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-auth0:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
8047
```
8148
## Testing
82-
Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named.
83-
First install test dependencies into your virtual environment:
84-
```
85-
pip install .[tests]
86-
```
87-
### Unit Tests
88-
To run unit tests locally, from the connector directory run:
89-
```
90-
python -m pytest unit_tests
91-
```
9249

93-
### Integration Tests
94-
There are two types of integration tests: Acceptance Tests (Airbyte's test suite for all source connectors) and custom integration tests (which are specific to this connector).
95-
#### Custom Integration tests
96-
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
97-
```
98-
python -m pytest integration_tests
99-
```
10050
#### Acceptance Tests
101-
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
51+
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
10252
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
103-
To run your integration tests with acceptance tests, from the connector root, run
53+
54+
To run your integration tests with Docker, run:
10455
```
105-
python -m pytest integration_tests -p integration_tests.acceptance
56+
./acceptance-test-docker.sh
10657
```
107-
To run your integration tests with docker
10858

10959
### Using gradle to run tests
11060
All commands should be run from airbyte project root.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3+
#

airbyte-integrations/connectors/source-auth0/acceptance-test-config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ acceptance_tests:
1717
- config_path: "secrets/config.json"
1818
configured_catalog_path: "integration_tests/configured_catalog.json"
1919
empty_streams: []
20-
fail_on_extra_columns: false
20+
expect_records:
21+
path: "integration_tests/expected_records.jsonl"
22+
extra_fields: no
23+
exact_order: no
24+
extra_records: yes
2125
incremental:
26+
# bypass_reason: "Connection check getting lost"
2227
tests:
2328
- config_path: "secrets/config.json"
2429
configured_catalog_path: "integration_tests/configured_catalog.json"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/usr/bin/env sh
2+
23
source "$(git rev-parse --show-toplevel)/airbyte-integrations/bases/connector-acceptance-test/acceptance-test-docker.sh"

airbyte-integrations/connectors/source-auth0/integration_tests/abnormal_state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"type": "STREAM",
44
"stream": {
5-
"stream_state": { "updated_at": "5000-08-02T16:18:47.824Z" },
5+
"stream_state": { "updated_at": "3021-09-08T07:04:28.000Z" },
66
"stream_descriptor": { "name": "users" }
77
}
88
}

airbyte-integrations/connectors/source-auth0/integration_tests/acceptance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@
1010

1111
@pytest.fixture(scope="session", autouse=True)
1212
def connector_setup():
13-
"""This fixture is a placeholder for external resources that acceptance test might require."""
1413
yield

airbyte-integrations/connectors/source-auth0/integration_tests/catalog.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

airbyte-integrations/connectors/source-auth0/integration_tests/configured_catalog.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"supported_sync_modes": ["full_refresh", "incremental"]
88
},
99
"sync_mode": "incremental",
10-
"destination_sync_mode": "overwrite",
1110
"cursor_field": ["updated_at"],
12-
"primary_key": [["user_id"]]
11+
"primary_key": [["user_id"]],
12+
"destination_sync_mode": "overwrite"
1313
},
1414
{
1515
"stream": {
@@ -38,8 +38,8 @@
3838
"supported_sync_modes": ["full_refresh"]
3939
},
4040
"sync_mode": "full_refresh",
41-
"destination_sync_mode": "overwrite",
42-
"primary_key": [["id"]]
41+
"primary_key": [["user_id"]],
42+
"destination_sync_mode": "overwrite"
4343
},
4444
{
4545
"stream": {
@@ -48,8 +48,8 @@
4848
"supported_sync_modes": ["full_refresh"]
4949
},
5050
"sync_mode": "full_refresh",
51-
"destination_sync_mode": "overwrite",
52-
"primary_key": [["id"]]
51+
"primary_key": [["id"]],
52+
"destination_sync_mode": "overwrite"
5353
}
5454
]
5555
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"stream": "users", "data": {"created_at":"2023-08-03T14:47:51.713Z","email":"admin@medusa-test.com","email_verified":false,"identities":[{"connection":"Username-Password-Authentication","user_id":"64cbbe17741f518beae16346","provider":"auth0","isSocial":false}],"name":"admin@medusa-test.com","nickname":"admin","picture":"https://s.gravatar.com/avatar/36ded5b8b1df85ba3f21bd1382c92bbb?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fad.png","updated_at":"2023-08-23T01:40:56.928Z","user_id":"auth0|64cbbe17741f518beae16346","user_metadata":{"color":"blue"},"app_metadata":{}}, "emitted_at": 1691072031178}

0 commit comments

Comments
 (0)