Skip to content
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 Auth0: Migrate Python CDK to Low-code CDK #28972

Merged
merged 44 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4849f75
Migrate to low code
btkcodedev Aug 2, 2023
523eeb8
Cleanse
btkcodedev Aug 2, 2023
b8301f1
Merge branch 'master' into auth0lowcode
btkcodedev Aug 2, 2023
ff5b487
Merge branch 'master' of https://github.com/btkcodedev/airbyte into a…
btkcodedev Aug 3, 2023
4581db9
Temp commit
btkcodedev Aug 3, 2023
eaffcfb
Add streams
btkcodedev Aug 3, 2023
b568aa0
Merge branch 'master' into auth0lowcode
btkcodedev Aug 3, 2023
eb04b1b
Fix manifest
btkcodedev Aug 5, 2023
273800b
Merge branch 'auth0lowcode' of https://github.com/btkcodedev/airbyte …
btkcodedev Aug 5, 2023
749ad4c
Revert unwanted changes
btkcodedev Aug 5, 2023
521e918
Revert unwanted changes
btkcodedev Aug 5, 2023
b0a2339
Revert incremental sync
btkcodedev Aug 5, 2023
1443884
Fix Incremental Sync
btkcodedev Aug 5, 2023
022392b
Merge branch 'master' into auth0lowcode
btkcodedev Aug 5, 2023
e09f88d
Merge branch 'master' into auth0lowcode
sajarin Aug 7, 2023
8343d00
Merge branch 'master' into auth0lowcode
btkcodedev Aug 7, 2023
1bc0513
Gradle Format
btkcodedev Aug 7, 2023
345214b
Merge branch 'master' into auth0lowcode
btkcodedev Aug 7, 2023
a875c07
Resolve comments
btkcodedev Aug 8, 2023
df9d3e0
Resolve comments
btkcodedev Aug 8, 2023
6980440
Merge branch 'master' into auth0lowcode
btkcodedev Aug 8, 2023
fdc0c73
Merge branch 'master' into auth0lowcode
btkcodedev Aug 10, 2023
5468adb
fix: add release date to metadata.yaml
sajarin Aug 10, 2023
d477633
Merge branch 'master' into auth0lowcode
sajarin Aug 11, 2023
99a4499
Merge branch 'master' into auth0lowcode
sajarin Aug 11, 2023
e6a9d92
Merge branch 'master' into auth0lowcode
btkcodedev Aug 12, 2023
ab17b88
RollBack needed requirements
btkcodedev Aug 12, 2023
433fe00
Update expected records
btkcodedev Aug 12, 2023
1f0dab8
Merge branch 'master' into auth0lowcode
sajarin Aug 14, 2023
c54026c
Merge branch 'master' into auth0lowcode
sajarin Aug 14, 2023
a7bcdbe
add pagination
btkcodedev Aug 14, 2023
6c4df2c
Update Expected Records
btkcodedev Aug 14, 2023
ed9765d
Merge branch 'master' into auth0lowcode
btkcodedev Aug 15, 2023
aa2c0fa
Merge branch 'auth0lowcode' of https://github.com/btkcodedev/airbyte …
btkcodedev Aug 14, 2023
e74adb2
Merge branch 'master' into auth0lowcode
btkcodedev Aug 15, 2023
823cce1
Merge branch 'master' into auth0lowcode
btkcodedev Aug 20, 2023
5849023
update expected records
btkcodedev Aug 20, 2023
0cf1218
Merge branch 'master' into auth0lowcode
sajarin Aug 21, 2023
58729f1
Update expected records
btkcodedev Aug 22, 2023
ab056b1
Merge branch 'auth0lowcode' of https://github.com/btkcodedev/airbyte …
btkcodedev Aug 22, 2023
11e9245
Merge branch 'master' into auth0lowcode
btkcodedev Aug 22, 2023
ed7f092
update expecte records
btkcodedev Aug 23, 2023
b7717b1
Merge branch 'auth0lowcode' of https://github.com/btkcodedev/airbyte …
btkcodedev Aug 23, 2023
6761872
Merge branch 'master' into auth0lowcode
sajarin Aug 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions airbyte-integrations/connectors/source-auth0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.13-alpine3.15 as base
FROM python:3.9.11-alpine3.15 as base

# build and load all requirements
FROM base as builder
Expand Down Expand Up @@ -34,5 +34,5 @@ COPY source_auth0 ./source_auth0
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.3.0
LABEL io.airbyte.version=1.0.0
LABEL io.airbyte.name=airbyte/source-auth0
btkcodedev marked this conversation as resolved.
Show resolved Hide resolved
66 changes: 8 additions & 58 deletions airbyte-integrations/connectors/source-auth0/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
# Auth0 Source

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

## Local development

### Prerequisites
**To iterate on this connector, make sure to complete this prerequisites section.**

#### Minimum Python version required `= 3.9.0`

#### Build & Activate Virtual Environment and install dependencies
From this connector directory, create a virtual environment:
```
python -m venv .venv
```

This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
development environment of choice. To activate it from the terminal, run:
```
source .venv/bin/activate
pip install -r requirements.txt
pip install '.[tests]'
```
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.

Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
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
should work as you expect.

#### Building via Gradle
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.

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

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

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

### Locally running the connector
```
python main.py spec
python main.py check --config secrets/config.json
python main.py discover --config secrets/config.json
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
```

### Locally running the connector docker image

#### Build
Expand All @@ -79,32 +46,15 @@ docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-auth0:dev discover --c
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
```
## Testing
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.
First install test dependencies into your virtual environment:
```
pip install .[tests]
```
### Unit Tests
To run unit tests locally, from the connector directory run:
```
python -m pytest unit_tests
```

### Integration Tests
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).
#### Custom Integration tests
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
```
python -m pytest integration_tests
```
#### Acceptance Tests
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.
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.
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.
To run your integration tests with acceptance tests, from the connector root, run

To run your integration tests with Docker, run:
```
python -m pytest integration_tests -p integration_tests.acceptance
./acceptance-test-docker.sh
```
To run your integration tests with docker

### Using gradle to run tests
All commands should be run from airbyte project root.
Expand Down
3 changes: 3 additions & 0 deletions airbyte-integrations/connectors/source-auth0/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ acceptance_tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
fail_on_extra_columns: false
expect_records:
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: yes
incremental:
tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state:
future_state_path: "integration_tests/abnormal_state.json"
bypass_reason: "Connection check getting lost"
# tests:
# - config_path: "secrets/config.json"
# configured_catalog_path: "integration_tests/configured_catalog.json"
# future_state:
# future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
tests:
- config_path: "secrets/config.json"
Expand Down
1 change: 1 addition & 0 deletions airbyte-integrations/connectors/source-auth0/acceptance-test-docker.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env sh

source "$(git rev-parse --show-toplevel)/airbyte-integrations/bases/connector-acceptance-test/acceptance-test-docker.sh"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type": "STREAM",
"stream": {
"stream_state": { "updated_at": "5000-08-02T16:18:47.824Z" },
"stream_state": { "updated_at": "3021-09-08T07:04:28.000Z" },
"stream_descriptor": { "name": "users" }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"supported_sync_modes": ["full_refresh", "incremental"]
},
"sync_mode": "incremental",
"destination_sync_mode": "overwrite",
"cursor_field": ["updated_at"],
"primary_key": [["user_id"]]
"destination_sync_mode": "append"
btkcodedev marked this conversation as resolved.
Show resolved Hide resolved
},
{
"stream": {
Expand Down Expand Up @@ -38,8 +36,7 @@
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite",
"primary_key": [["id"]]
sajarin marked this conversation as resolved.
Show resolved Hide resolved
"destination_sync_mode": "overwrite"
},
{
"stream": {
Expand All @@ -48,8 +45,7 @@
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite",
"primary_key": [["id"]]
sajarin marked this conversation as resolved.
Show resolved Hide resolved
"destination_sync_mode": "overwrite"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"stream": "users", "data": {"created_at":"2023-08-03T14:47:51.713Z","email":"[email protected]","email_verified":false,"identities":[{"connection":"Username-Password-Authentication","user_id":"64cbbe17741f518beae16346","provider":"auth0","isSocial":false}],"name":"[email protected]","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-03T14:47:51.713Z","user_id":"auth0|64cbbe17741f518beae16346"}, "emitted_at": 1691072031178}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"credentials": {
"auth_type": "oauth2_access_token",
"access_token": "Invalid-token"
}
},
"start_date": "2099-08-02T04:20:02Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"credentials": {
"auth_type": "oauth2_access_token",
"access_token": "api-key-just-for-testing"
}
},
"start_date": "2023-08-02T04:20:02Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"client_secret": "top-secret",
"client_id": "click-copy-icon-from-applications-page",
"audience": "https://dev-your-org.us.auth0.com/api/v2/"
}
},
"start_date": "2099-08-02T04:20:02Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type": "STREAM",
"stream": {
"stream_state": { "updated_at": "2000-08-02T16:18:47.824Z" },
"stream_state": { "updated_at": "2023-09-08T07:04:28.000Z" },
"stream_descriptor": { "name": "users" }
}
}
Expand Down
22 changes: 11 additions & 11 deletions airbyte-integrations/connectors/source-auth0/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
data:
allowedHosts:
hosts:
- "*.auth0.com"
registries:
oss:
enabled: false
cloud:
enabled: false
connectorSubtype: api
connectorType: source
definitionId: 6c504e48-14aa-4221-9a72-19cf5ff1ae78
dockerImageTag: 0.3.0
dockerImageTag: 1.0.0
btkcodedev marked this conversation as resolved.
Show resolved Hide resolved
dockerRepository: airbyte/source-auth0
githubIssueLabel: source-auth0
icon: auth0.svg
license: MIT
name: Auth0
registries:
cloud:
enabled: true
oss:
enabled: true
releaseDate: TODO
releaseStage: alpha
documentationUrl: https://docs.airbyte.com/integrations/sources/auth0
tags:
- language:python
ab_internal:
sl: 100
ql: 200
sajarin marked this conversation as resolved.
Show resolved Hide resolved
supportLevel: community
- language:lowcode
sajarin marked this conversation as resolved.
Show resolved Hide resolved
metadataSpecVersion: "1.0"
4 changes: 2 additions & 2 deletions airbyte-integrations/connectors/source-auth0/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from setuptools import find_packages, setup

MAIN_REQUIREMENTS = [
"airbyte-cdk~=0.2",
"airbyte-cdk~=0.1",
]

TEST_REQUIREMENTS = [
"pytest~=6.1",
"pytest~=6.2",
"pytest-mock~=3.6.1",
"connector-acceptance-test",
]
Expand Down

This file was deleted.

Loading
Loading