Skip to content

Commit 291e91e

Browse files
🎉 Source Okta: return deprovisioned users (#15001)
* add statuses to user filtering * bump version * upd * add comment * auto-bump connector version [ci skip] * format Co-authored-by: Octavia Squidington III <[email protected]>
1 parent c2a5f1c commit 291e91e

File tree

12 files changed

+47
-35
lines changed

12 files changed

+47
-35
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.8
631+
dockerImageTag: 0.1.9
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
@@ -6027,7 +6027,7 @@
60276027
- - "client_secret"
60286028
oauthFlowOutputParameters:
60296029
- - "access_token"
6030-
- dockerImage: "airbyte/source-okta:0.1.8"
6030+
- dockerImage: "airbyte/source-okta:0.1.9"
60316031
spec:
60326032
documentationUrl: "https://docs.airbyte.io/integrations/sources/okta"
60336033
connectionSpecification:

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.8
15+
LABEL io.airbyte.version=0.1.9
1616
LABEL io.airbyte.name=airbyte/source-okta

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ tests:
1616
basic_read:
1717
- config_path: "secrets/config.json"
1818
configured_catalog_path: "integration_tests/configured_catalog.json"
19+
expect_records:
20+
path: "integration_tests/expected_records.txt"
1921
- config_path: "secrets/config_api_token.json"
2022
configured_catalog_path: "integration_tests/configured_catalog.json"
2123
full_refresh:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"stream": "users", "data": {"id": "00u5vhynsalJZ2eMg5d7", "status": "DEPROVISIONED", "created":"2022-07-21T20:46:27.000Z", "activated":"2022-07-21T20:47:13.000Z", "statusChanged": "2022-07-21T20:49:13.000Z", "lastLogin": null, "lastUpdated": "2022-07-21T20:49:13.000Z", "passwordChanged": "2022-07-21T20:47:35.000Z", "type": {"id": "otymj7cw2AJFAHvOO5d6"}, "profile": {"firstName": "Test", "lastName": "DEPROVISIONED", "mobilePhone": null, "secondEmail": null, "login": "[email protected]", "email": "[email protected]"}, "credentials": {"emails": [{"value": "[email protected]", "status": "VERIFIED", "type": "PRIMARY"}], "provider": {"type": "OKTA", "name": "OKTA"}}, "_links": {"self": {"href": "https://dev-01177082.okta.com/api/v1/users/00u5vhynsalJZ2eMg5d7"}}}, "emitted_at": 1655800476224}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"properties": {
33
"_links": {
4-
"additionalProperties": {
5-
"type": ["array", "object", "null"]
6-
},
74
"type": ["object", "null"]
85
},
96
"created": {

airbyte-integrations/connectors/source-okta/source_okta/schemas/shared/shared-user.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
"$id": "shared-users.json",
33
"properties": {
44
"_links": {
5-
"additionalProperties": {
6-
"type": ["object", "null"]
7-
},
85
"type": ["object", "null"]
96
},
107
"activated": {

airbyte-integrations/connectors/source-okta/source_okta/source.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,28 @@ def request_params(
199199
class Users(IncrementalOktaStream):
200200
cursor_field = "lastUpdated"
201201
primary_key = "id"
202+
# Should add all statuses to filter. Considering Okta documentation https://developer.okta.com/docs/reference/api/users/#list-all-users,
203+
# users with "DEPROVISIONED" status are not returned by default.
204+
statuses = ["ACTIVE", "DEPROVISIONED", "LOCKED_OUT", "PASSWORD_EXPIRED", "PROVISIONED", "RECOVERY", "STAGED", "SUSPENDED"]
202205

203206
def path(self, **kwargs) -> str:
204207
return "users"
205208

209+
def request_params(
210+
self,
211+
stream_state: Mapping[str, Any],
212+
stream_slice: Mapping[str, any] = None,
213+
next_page_token: Mapping[str, Any] = None,
214+
) -> MutableMapping[str, Any]:
215+
params = super().request_params(stream_state, stream_slice, next_page_token)
216+
status_filters = " or ".join([f'status eq "{status}"' for status in self.statuses])
217+
if "filter" in params:
218+
# add status_filters to existing filters
219+
params["filter"] = f'{params["filter"]} and ({status_filters})'
220+
else:
221+
params["filter"] = status_filters
222+
return params
223+
206224

207225
class CustomRoles(OktaStream):
208226
primary_key = "id"

airbyte-integrations/connectors/source-okta/unit_tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ def auth_token_config():
8686
return {"credentials": {"auth_type": "api_token", "api_token": "test_token"}}
8787

8888

89+
@pytest.fixture()
90+
def user_status_filter():
91+
statuses = ["ACTIVE", "DEPROVISIONED", "LOCKED_OUT", "PASSWORD_EXPIRED", "PROVISIONED", "RECOVERY", "STAGED", "SUSPENDED"]
92+
return " or ".join([f'status eq "{status}"' for status in statuses])
93+
94+
8995
@pytest.fixture()
9096
def users_instance(api_url):
9197
"""

airbyte-integrations/connectors/source-okta/unit_tests/test_source.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020

2121
class TestAuthentication:
22-
2322
def test_init_token_authentication_init(self, token_config, auth_token_config):
2423
source_okta = SourceOkta()
2524
token_authenticator_instance = source_okta.initialize_authenticator(config=token_config)

0 commit comments

Comments
 (0)