Skip to content

Commit 0bc617f

Browse files
YiyangLisajarinoctavia-squidington-iii
authored
Source Okta: add permission stream under a custom role (#14739)
* Source Okta: add permission stream under a custom role - it supports full refresh only - add unit tests * bump connector version * bump connector version in Dockerfile * auto-bump connector version [ci skip] Co-authored-by: sajarin <[email protected]> Co-authored-by: Octavia Squidington III <[email protected]>
1 parent a7a1847 commit 0bc617f

File tree

14 files changed

+236
-18
lines changed

14 files changed

+236
-18
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@
628628
- name: Okta
629629
sourceDefinitionId: 1d4fdb25-64fc-4569-92da-fcdca79a8372
630630
dockerRepository: airbyte/source-okta
631-
dockerImageTag: 0.1.10
631+
dockerImageTag: 0.1.11
632632
documentationUrl: https://docs.airbyte.io/integrations/sources/okta
633633
icon: okta.svg
634634
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6033,7 +6033,7 @@
60336033
- - "client_secret"
60346034
oauthFlowOutputParameters:
60356035
- - "access_token"
6036-
- dockerImage: "airbyte/source-okta:0.1.10"
6036+
- dockerImage: "airbyte/source-okta:0.1.11"
60376037
spec:
60386038
documentationUrl: "https://docs.airbyte.io/integrations/sources/okta"
60396039
connectionSpecification:

airbyte-integrations/bases/source-acceptance-test/setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"dpath~=2.0.1",
2121
"jsonschema~=3.2.0",
2222
"jsonref==0.2",
23+
"requests-mock",
24+
"pytest-mock~=3.6.1",
2325
]
2426

2527
setuptools.setup(

airbyte-integrations/connectors/source-okta/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.1.10
15+
LABEL io.airbyte.version=0.1.11
1616
LABEL io.airbyte.name=airbyte/source-okta

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

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,25 @@ For information about how to use this connector within Airbyte, see [the documen
66
## Local development
77

88
### Prerequisites
9+
910
**To iterate on this connector, make sure to complete this prerequisites section.**
1011

1112
#### Build & Activate Virtual Environment and install dependencies
13+
1214
From this connector directory, create a virtual environment:
13-
```
15+
16+
```shell
1417
python -m venv .venv
1518
```
1619

1720
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
1821
development environment of choice. To activate it from the terminal, run:
19-
```
22+
23+
```shell
2024
source .venv/bin/activate
2125
pip install -r requirements.txt
2226
```
27+
2328
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
2429

2530
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
@@ -28,14 +33,17 @@ If this is mumbo jumbo to you, don't worry about it, just put your deps in `setu
2833
should work as you expect.
2934

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

3339
To build using Gradle, from the Airbyte repository root, run:
34-
```
40+
41+
```shell
3542
./gradlew :airbyte-integrations:connectors:source-okta:build
3643
```
3744

3845
#### Create credentials
46+
3947
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/okta)
4048
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_okta/spec.json` file.
4149
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,7 +53,8 @@ See `integration_tests/sample_config.json` for a sample config file.
4553
and place them into `secrets/config.json`.
4654

4755
### Locally running the connector
48-
```
56+
57+
```shell
4958
python main.py spec
5059
python main.py check --config secrets/config.json
5160
python main.py discover --config secrets/config.json
@@ -55,76 +64,104 @@ python main.py read --config secrets/config.json --catalog integration_tests/con
5564
### Locally running the connector docker image
5665

5766
#### Build
67+
5868
First, make sure you build the latest Docker image:
59-
```
69+
70+
```shell
6071
docker build . -t airbyte/source-okta:dev
6172
```
6273

6374
You can also build the connector image via Gradle:
64-
```
75+
76+
```shell
6577
./gradlew :airbyte-integrations:connectors:source-okta:airbyteDocker
6678
```
79+
6780
When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in
6881
the Dockerfile.
6982

7083
#### Run
84+
7185
Then run any of the connector commands as follows:
72-
```
86+
87+
```shell
7388
docker run --rm airbyte/source-okta:dev spec
7489
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-okta:dev check --config /secrets/config.json
7590
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-okta:dev discover --config /secrets/config.json
7691
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-okta:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
7792
```
93+
7894
## Testing
95+
7996
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.
8097
First install test dependencies into your virtual environment:
81-
```
98+
99+
```shell
82100
pip install .[tests]
83101
```
102+
84103
### Unit Tests
104+
85105
To run unit tests locally, from the connector directory run:
86-
```
106+
107+
```shell
87108
python -m pytest unit_tests
88109
```
89110

90111
### Integration Tests
112+
91113
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).
114+
92115
#### Custom Integration tests
93-
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
116+
117+
Place custom tests inside the `integration_tests``/` folder, then, from the connector root, run
118+
94119
```
95120
python -m pytest integration_tests
96121
```
122+
97123
#### Acceptance Tests
124+
98125
Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) for more information.
99126
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.
100127
To run your integration tests with acceptance tests, from the connector root, run
128+
101129
```
102130
docker build . --no-cache -t airbyte/source-okta:dev \
103131
&& python -m pytest -p source_acceptance_test.plugin
104132
```
133+
105134
To run your integration tests with docker
106135

107136
### Using gradle to run tests
137+
108138
All commands should be run from airbyte project root.
109139
To run unit tests:
140+
110141
```
111142
./gradlew :airbyte-integrations:connectors:source-okta:unitTest
112143
```
144+
113145
To run acceptance and custom integration tests:
146+
114147
```
115148
./gradlew :airbyte-integrations:connectors:source-okta:integrationTest
116149
```
117150

118151
## Dependency Management
152+
119153
All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development.
120154
We split dependencies between two groups, dependencies that are:
155+
121156
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
122157
* required for the testing need to go to `TEST_REQUIREMENTS` list
123158

124159
### Publishing a new version of the connector
160+
125161
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
162+
126163
1. Make sure your changes are passing unit and integration tests.
127-
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
128-
1. Create a Pull Request.
129-
1. Pat yourself on the back for being an awesome contributor.
130-
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
164+
2. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
165+
3. Create a Pull Request.
166+
4. Pat yourself on the back for being an awesome contributor.
167+
5. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@
6666
"sync_mode": "full_refresh",
6767
"destination_sync_mode": "overwrite",
6868
"primary_key": [["id"]]
69+
},
70+
{
71+
"stream": {
72+
"name": "permissions",
73+
"json_schema": {}
74+
},
75+
"sync_mode": "full_refresh",
76+
"destination_sync_mode": "overwrite",
77+
"primary_key": [["label"]]
6978
}
7079
]
7180
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@
7070
},
7171
"sync_mode": "full_refresh",
7272
"destination_sync_mode": "overwrite"
73+
},
74+
{
75+
"stream": {
76+
"name": "permissions",
77+
"json_schema": {},
78+
"supported_sync_modes": ["full_refresh"]
79+
},
80+
"sync_mode": "full_refresh",
81+
"destination_sync_mode": "overwrite",
82+
"primary_key": [["label"]]
7383
}
7484
]
7585
}

airbyte-integrations/connectors/source-okta/sample_files/catalog.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@
6060
"sync_mode": "full_refresh",
6161
"destination_sync_mode": "overwrite",
6262
"primary_key": [["id"]]
63+
},
64+
{
65+
"stream": {
66+
"name": "custom_roles",
67+
"json_schema": {}
68+
},
69+
"sync_mode": "full_refresh",
70+
"destination_sync_mode": "overwrite",
71+
"primary_key": [["id"]]
72+
},
73+
{
74+
"stream": {
75+
"name": "permissions",
76+
"json_schema": {},
77+
"supported_sync_modes": ["full_refresh"]
78+
},
79+
"sync_mode": "full_refresh",
80+
"destination_sync_mode": "overwrite",
81+
"primary_key": [["label"]]
6382
}
6483
]
6584
}

airbyte-integrations/connectors/source-okta/source_okta/schemas/custom_roles.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"type": ["null", "object"],
33
"additionalProperties": true,
4+
"description": "Gets a paginated list of Custom Roles",
45
"properties": {
56
"id": {
67
"type": ["null", "string"]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"description": "Gets the list of permissions included in a Custom Role identified by its id",
3+
"properties": {
4+
"label": {
5+
"enum": [
6+
"okta.users.manage",
7+
"okta.users.create",
8+
"okta.users.read",
9+
"okta.users.credentials.manage",
10+
"okta.users.credentials.resetFactors",
11+
"okta.users.credentials.resetPassword",
12+
"okta.users.credentials.expirePassword",
13+
"okta.users.userprofile.manage",
14+
"okta.users.lifecycle.manage",
15+
"okta.users.lifecycle.activate",
16+
"okta.users.lifecycle.deactivate",
17+
"okta.users.lifecycle.suspend",
18+
"okta.users.lifecycle.unsuspend",
19+
"okta.users.lifecycle.delete",
20+
"okta.users.lifecycle.unlock",
21+
"okta.users.lifecycle.clearSessions",
22+
"okta.users.groupMembership.manage",
23+
"okta.users.appAssignment.manage",
24+
"okta.groups.manage",
25+
"okta.groups.create",
26+
"okta.groups.members.manage",
27+
"okta.groups.read",
28+
"okta.groups.appAssignment.manage",
29+
"okta.apps.read",
30+
"okta.apps.manage",
31+
"okta.apps.assignment.manage",
32+
"okta.profilesources.import.run",
33+
"okta.authzServers.read",
34+
"okta.authzServers.manage",
35+
"okta.customizations.read",
36+
"okta.customizations.manage",
37+
"okta.workflows.invoke"
38+
],
39+
"type": "string",
40+
"description": "Type of permissions"
41+
},
42+
"created": {
43+
"format": "date-time",
44+
"type": "string"
45+
},
46+
"lastUpdated": {
47+
"format": "date-time",
48+
"type": "string"
49+
},
50+
"_links": {
51+
"properties": {
52+
"assignee": {
53+
"properties": {
54+
"self": {
55+
"type": ["null", "object"],
56+
"additionalProperties": true,
57+
"properties": {
58+
"href": {
59+
"type": ["null", "string"]
60+
}
61+
}
62+
},
63+
"role": {
64+
"type": ["null", "object"],
65+
"additionalProperties": true,
66+
"properties": {
67+
"href": {
68+
"type": ["null", "string"]
69+
}
70+
}
71+
}
72+
}
73+
}
74+
},
75+
"type": ["object", "null"]
76+
}
77+
},
78+
"type": "object"
79+
}

0 commit comments

Comments
 (0)