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

Cleanup service accounts tests #1717

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2023-10-12 21:14:48.669425",
"spec_repo_commit": "d4c17bf0"
"regenerated": "2023-10-13 08:13:36.289198",
"spec_repo_commit": "30a99088"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2023-10-12 21:14:48.718184",
"spec_repo_commit": "d4c17bf0"
"regenerated": "2023-10-13 08:13:36.303071",
"spec_repo_commit": "30a99088"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
Create an application key for this service account returns "Created" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.service_accounts_api import ServiceAccountsApi
from datadog_api_client.v2.model.application_key_create_attributes import ApplicationKeyCreateAttributes
from datadog_api_client.v2.model.application_key_create_data import ApplicationKeyCreateData
from datadog_api_client.v2.model.application_key_create_request import ApplicationKeyCreateRequest
from datadog_api_client.v2.model.application_keys_type import ApplicationKeysType

# there is a valid "service_account_user" in the system
SERVICE_ACCOUNT_USER_DATA_ID = environ["SERVICE_ACCOUNT_USER_DATA_ID"]

body = ApplicationKeyCreateRequest(
data=ApplicationKeyCreateData(
attributes=ApplicationKeyCreateAttributes(
name="Application Key for managing dashboards",
scopes=[
"dashboards_read",
"dashboards_write",
"dashboards_public_share",
],
name="Example-Service-Account",
),
type=ApplicationKeysType.APPLICATION_KEYS,
),
Expand All @@ -27,7 +26,7 @@
with ApiClient(configuration) as api_client:
api_instance = ServiceAccountsApi(api_client)
response = api_instance.create_service_account_application_key(
service_account_id="00000000-0000-1234-0000-000000000000", body=body
service_account_id=SERVICE_ACCOUNT_USER_DATA_ID, body=body
)

print(response)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
Delete an application key for this service account returns "No Content" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.service_accounts_api import ServiceAccountsApi

# there is a valid "service_account_user" in the system
SERVICE_ACCOUNT_USER_DATA_ID = environ["SERVICE_ACCOUNT_USER_DATA_ID"]

# there is a valid "service_account_application_key" for "service_account_user"
SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID = environ["SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceAccountsApi(api_client)
api_instance.delete_service_account_application_key(
service_account_id="00000000-0000-1234-0000-000000000000",
app_key_id="app_key_id",
service_account_id=SERVICE_ACCOUNT_USER_DATA_ID,
app_key_id=SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID,
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
Get one application key for this service account returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.service_accounts_api import ServiceAccountsApi

# there is a valid "service_account_user" in the system
SERVICE_ACCOUNT_USER_DATA_ID = environ["SERVICE_ACCOUNT_USER_DATA_ID"]

# there is a valid "service_account_application_key" for "service_account_user"
SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID = environ["SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceAccountsApi(api_client)
response = api_instance.get_service_account_application_key(
service_account_id="00000000-0000-1234-0000-000000000000",
app_key_id="app_key_id",
service_account_id=SERVICE_ACCOUNT_USER_DATA_ID,
app_key_id=SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID,
)

print(response)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
List application keys for this service account returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.service_accounts_api import ServiceAccountsApi

# there is a valid "service_account_user" in the system
SERVICE_ACCOUNT_USER_DATA_ID = environ["SERVICE_ACCOUNT_USER_DATA_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceAccountsApi(api_client)
response = api_instance.list_service_account_application_keys(
service_account_id="00000000-0000-1234-0000-000000000000",
service_account_id=SERVICE_ACCOUNT_USER_DATA_ID,
)

print(response)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,36 @@
Edit an application key for this service account returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.service_accounts_api import ServiceAccountsApi
from datadog_api_client.v2.model.application_key_update_attributes import ApplicationKeyUpdateAttributes
from datadog_api_client.v2.model.application_key_update_data import ApplicationKeyUpdateData
from datadog_api_client.v2.model.application_key_update_request import ApplicationKeyUpdateRequest
from datadog_api_client.v2.model.application_keys_type import ApplicationKeysType

# there is a valid "service_account_user" in the system
SERVICE_ACCOUNT_USER_DATA_ID = environ["SERVICE_ACCOUNT_USER_DATA_ID"]

# there is a valid "service_account_application_key" for "service_account_user"
SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ATTRIBUTES_NAME = environ["SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ATTRIBUTES_NAME"]
SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID = environ["SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID"]

body = ApplicationKeyUpdateRequest(
data=ApplicationKeyUpdateData(
id=SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID,
type=ApplicationKeysType.APPLICATION_KEYS,
attributes=ApplicationKeyUpdateAttributes(
name="Application Key for managing dashboards",
scopes=[
"dashboards_read",
"dashboards_write",
"dashboards_public_share",
],
name="Application Key for managing dashboards-updated",
),
id="00112233-4455-6677-8899-aabbccddeeff",
type=ApplicationKeysType.APPLICATION_KEYS,
),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceAccountsApi(api_client)
response = api_instance.update_service_account_application_key(
service_account_id="00000000-0000-1234-0000-000000000000", app_key_id="app_key_id", body=body
service_account_id=SERVICE_ACCOUNT_USER_DATA_ID, app_key_id=SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID, body=body
)

print(response)

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-10-12T10:11:47.418Z
Loading