mirror of
https://github.com/thousandeyes/thousandeyes-sdk-python.git
synced 2025-12-06 06:26:51 +00:00
238 lines
11 KiB
Python
238 lines
11 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Credentials API
|
|
|
|
Manage credentials for transaction tests using the Credentials API. The following permissions are required to access Credentials API endpoints: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. * `View sensitive data in web transaction scripts` to view the encrypted value property of credentials. * `Settings Tests Create Transaction (Tx) Tests` to create credentials. For more information about credentials, see [Working With Secure Credentials](https://docs.thousandeyes.com/product-documentation/browser-synthetics/transaction-tests/getting-started/working-with-secure-credentials).
|
|
|
|
The version of the OpenAPI document: 7.0.4
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
|
|
import json
|
|
import unittest
|
|
import credentials.models
|
|
|
|
from credentials.api.credentials_api import CredentialsApi
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class TestCredentialsApi(unittest.TestCase):
|
|
"""CredentialsApi unit test stubs"""
|
|
|
|
def setUp(self) -> None:
|
|
self.api = CredentialsApi()
|
|
|
|
def tearDown(self) -> None:
|
|
pass
|
|
|
|
def test_create_transaction_tests_credential_models_validation(self) -> None:
|
|
"""Test case for create_transaction_tests_credential request a nd response models"""
|
|
request_body_json = """
|
|
{
|
|
"name" : "Example Credential 1",
|
|
"value" : "Example Credential 1 Password"
|
|
}"""
|
|
|
|
request_loaded_json = json.loads(request_body_json)
|
|
request_from_constructor = credentials.models.CredentialRequest(**request_loaded_json)
|
|
self.recursive_assert_no_extra_fields(request_from_constructor)
|
|
|
|
request_from_json = credentials.models.CredentialRequest.from_json(request_body_json)
|
|
self.assertIsNotNone(request_from_json)
|
|
self.assertCountEqual(request_from_constructor.model_fields_set,
|
|
request_from_json.model_fields_set,
|
|
"Request model from constructor fields do not match model from json fields")
|
|
|
|
response_body_json = """
|
|
{
|
|
"_links" : {
|
|
"self" : {
|
|
"extra" : "unexpected",
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"name" : "Example Credential",
|
|
"id" : "3247"
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_constructor = credentials.models.CredentialWithoutValue(**response_loaded_json)
|
|
self.recursive_assert_no_extra_fields(response_from_constructor)
|
|
|
|
response_from_json = credentials.models.CredentialWithoutValue.from_json(response_body_json)
|
|
self.assertIsNotNone(response_from_json)
|
|
self.assertCountEqual(response_from_constructor.model_fields_set,
|
|
response_from_json.model_fields_set,
|
|
"Response model from constructor fields do not match model from json fields")
|
|
|
|
def test_delete_transaction_tests_credential_models_validation(self) -> None:
|
|
"""Test case for delete_transaction_tests_credential request a nd response models"""
|
|
|
|
|
|
def test_get_transaction_tests_credential_details_models_validation(self) -> None:
|
|
"""Test case for get_transaction_tests_credential_details request a nd response models"""
|
|
|
|
response_body_json = """
|
|
{
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"name" : "Example Credential",
|
|
"id" : "3247",
|
|
"value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt"
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_constructor = credentials.models.Credential(**response_loaded_json)
|
|
self.recursive_assert_no_extra_fields(response_from_constructor)
|
|
|
|
response_from_json = credentials.models.Credential.from_json(response_body_json)
|
|
self.assertIsNotNone(response_from_json)
|
|
self.assertCountEqual(response_from_constructor.model_fields_set,
|
|
response_from_json.model_fields_set,
|
|
"Response model from constructor fields do not match model from json fields")
|
|
|
|
def test_get_transaction_tests_credentials_list_models_validation(self) -> None:
|
|
"""Test case for get_transaction_tests_credentials_list request a nd response models"""
|
|
|
|
response_body_json = """
|
|
{
|
|
"credentials" : [ {
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"name" : "Example Credential",
|
|
"id" : "3247",
|
|
"value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt"
|
|
}, {
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"name" : "Example Credential",
|
|
"id" : "3247",
|
|
"value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt"
|
|
} ],
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
}
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_constructor = credentials.models.Credentials(**response_loaded_json)
|
|
self.recursive_assert_no_extra_fields(response_from_constructor)
|
|
|
|
response_from_json = credentials.models.Credentials.from_json(response_body_json)
|
|
self.assertIsNotNone(response_from_json)
|
|
self.assertCountEqual(response_from_constructor.model_fields_set,
|
|
response_from_json.model_fields_set,
|
|
"Response model from constructor fields do not match model from json fields")
|
|
|
|
def test_update_transaction_tests_credential_models_validation(self) -> None:
|
|
"""Test case for update_transaction_tests_credential request a nd response models"""
|
|
request_body_json = """
|
|
{
|
|
"name" : "Example Credential 1",
|
|
"value" : "Example Credential 1 Password"
|
|
}"""
|
|
|
|
request_loaded_json = json.loads(request_body_json)
|
|
request_from_constructor = credentials.models.CredentialRequest(**request_loaded_json)
|
|
self.recursive_assert_no_extra_fields(request_from_constructor)
|
|
|
|
request_from_json = credentials.models.CredentialRequest.from_json(request_body_json)
|
|
self.assertIsNotNone(request_from_json)
|
|
self.assertCountEqual(request_from_constructor.model_fields_set,
|
|
request_from_json.model_fields_set,
|
|
"Request model from constructor fields do not match model from json fields")
|
|
|
|
response_body_json = """
|
|
{
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"name" : "Example Credential",
|
|
"id" : "3247"
|
|
}"""
|
|
|
|
response_loaded_json = json.loads(response_body_json)
|
|
response_from_constructor = credentials.models.CredentialWithoutValue(**response_loaded_json)
|
|
self.recursive_assert_no_extra_fields(response_from_constructor)
|
|
|
|
response_from_json = credentials.models.CredentialWithoutValue.from_json(response_body_json)
|
|
self.assertIsNotNone(response_from_json)
|
|
self.assertCountEqual(response_from_constructor.model_fields_set,
|
|
response_from_json.model_fields_set,
|
|
"Response model from constructor fields do not match model from json fields")
|
|
|
|
def recursive_assert_no_extra_fields(self, model: BaseModel):
|
|
self.assertIsNotNone(model)
|
|
self.assertGreater(model.model_fields_set.__len__(), 0)
|
|
self.assertEquals(model.model_extra.__len__(), 0,
|
|
'model {0}.{1} has unmapped extra fields {2}'
|
|
.format(model.__class__.__module__, model.__class__.__name__,
|
|
model.model_extra))
|
|
for f in model.model_fields_set:
|
|
field = model.__dict__.get(f)
|
|
if isinstance(field, BaseModel):
|
|
self.recursive_assert_no_extra_fields(field)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|