Add service principal resource #1809
GitHub Actions / JUnit Test Report
failed
Dec 18, 2024 in 0s
110 tests run, 0 skipped, 6 failed.
Annotations
Check failure on line 222 in aws-lambda/tests/resources/service_principals/test_service_principal.py
github-actions / JUnit Test Report
test_service_principal.test_delete_service_principal
botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the GetParameter operation: The security token included in the request is invalid.
Raw output
patched_get_workspace_client = <MagicMock name='get_workspace_client' id='140417806683872'>
workspace_client = <MagicMock name='get_workspace_client()' spec='WorkspaceClient' id='140417806098784'>
@patch("databricks_cdk.resources.service_principals.service_principal.get_workspace_client")
def test_delete_service_principal(patched_get_workspace_client, workspace_client):
patched_get_workspace_client.return_value = workspace_client
mock_properties = ServicePrincipalProperties(
workspace_url="https://test.cloud.databricks.com",
service_principal=ServicePrincipal(
active=True,
display_name="mock_name",
id="some_id",
),
)
> response = delete_service_principal(mock_properties, "some_id")
tests/resources/service_principals/test_service_principal.py:222:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/databricks_cdk/resources/service_principals/service_principal.py:107: in delete_service_principal
account_client = get_account_client()
src/databricks_cdk/utils.py:191: in get_account_client
client_id=get_client_id(),
src/databricks_cdk/utils.py:83: in get_client_id
return get_param(CLIENT_ID_PARAM, required=True)
src/databricks_cdk/utils.py:39: in get_param
response = ssm.get_parameter(
../../../../.cache/pypoetry/virtualenvs/databricks-cdk-B2166n-E-py3.8/lib/python3.8/site-packages/botocore/client.py:569: in _api_call
return self._make_api_call(operation_name, kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <botocore.client.SSM object at 0x7fb5917a7eb0>
operation_name = 'GetParameter'
api_params = {'Name': '/databricks/deploy/client-id', 'WithDecryption': True}
def _make_api_call(self, operation_name, api_params):
operation_model = self._service_model.operation_model(operation_name)
service_name = self._service_model.service_name
history_recorder.record(
'API_CALL',
{
'service': service_name,
'operation': operation_name,
'params': api_params,
},
)
if operation_model.deprecated:
logger.debug(
'Warning: %s.%s() is deprecated', service_name, operation_name
)
request_context = {
'client_region': self.meta.region_name,
'client_config': self.meta.config,
'has_streaming_input': operation_model.has_streaming_input,
'auth_type': operation_model.resolved_auth_type,
'unsigned_payload': operation_model.unsigned_payload,
}
api_params = self._emit_api_params(
api_params=api_params,
operation_model=operation_model,
context=request_context,
)
(
endpoint_url,
additional_headers,
properties,
) = self._resolve_endpoint_ruleset(
operation_model, api_params, request_context
)
if properties:
# Pass arbitrary endpoint info with the Request
# for use during construction.
request_context['endpoint_properties'] = properties
request_dict = self._convert_to_request_dict(
api_params=api_params,
operation_model=operation_model,
endpoint_url=endpoint_url,
context=request_context,
headers=additional_headers,
)
resolve_checksum_context(request_dict, operation_model, api_params)
service_id = self._service_model.service_id.hyphenize()
handler, event_response = self.meta.events.emit_until_response(
f'before-call.{service_id}.{operation_name}',
model=operation_model,
params=request_dict,
request_signer=self._request_signer,
context=request_context,
)
if event_response is not None:
http, parsed_response = event_response
else:
maybe_compress_request(
self.meta.config, request_dict, operation_model
)
apply_request_checksum(request_dict)
http, parsed_response = self._make_request(
operation_model, request_dict, request_context
)
self.meta.events.emit(
f'after-call.{service_id}.{operation_name}',
http_response=http,
parsed=parsed_response,
model=operation_model,
context=request_context,
)
if http.status_code >= 300:
error_info = parsed_response.get("Error", {})
error_code = error_info.get("QueryErrorCode") or error_info.get(
"Code"
)
error_class = self.exceptions.from_code(error_code)
> raise error_class(parsed_response, operation_name)
E botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the GetParameter operation: The security token included in the request is invalid.
../../../../.cache/pypoetry/virtualenvs/databricks-cdk-B2166n-E-py3.8/lib/python3.8/site-packages/botocore/client.py:1023: ClientError
github-actions / JUnit Test Report
test_service_principal_secrets.test_create_or_update_service_principal_secrets_create
ModuleNotFoundError: No module named 'databricks_cdk.resources.service_principals.secrets'
Raw output
thing = <module 'databricks_cdk.resources.service_principals' from '/home/runner/work/databricks-cdk/databricks-cdk/aws-lambda/src/databricks_cdk/resources/service_principals/__init__.py'>
comp = 'secrets'
import_path = 'databricks_cdk.resources.service_principals.secrets'
def _dot_lookup(thing, comp, import_path):
try:
> return getattr(thing, comp)
E AttributeError: module 'databricks_cdk.resources.service_principals' has no attribute 'secrets'
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1215: AttributeError
During handling of the above exception, another exception occurred:
args = ()
keywargs = {'account_client': <MagicMock spec='AccountClient' id='140417805797456'>}
@wraps(func)
def patched(*args, **keywargs):
> with self.decoration_helper(patched,
args,
keywargs) as (newargs, newkeywargs):
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1322:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py:113: in __enter__
return next(self.gen)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1304: in decoration_helper
arg = exit_stack.enter_context(patching)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py:425: in enter_context
result = _cm_type.__enter__(cm)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1377: in __enter__
self.target = self.getter()
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1552: in <lambda>
getter = lambda: _importer(target)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1228: in _importer
thing = _dot_lookup(thing, comp, import_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
thing = <module 'databricks_cdk.resources.service_principals' from '/home/runner/work/databricks-cdk/databricks-cdk/aws-lambda/src/databricks_cdk/resources/service_principals/__init__.py'>
comp = 'secrets'
import_path = 'databricks_cdk.resources.service_principals.secrets'
def _dot_lookup(thing, comp, import_path):
try:
return getattr(thing, comp)
except AttributeError:
> __import__(import_path)
E ModuleNotFoundError: No module named 'databricks_cdk.resources.service_principals.secrets'
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1217: ModuleNotFoundError
github-actions / JUnit Test Report
test_service_principal_secrets.test_create_or_update_service_principal_secrets_update
ModuleNotFoundError: No module named 'databricks_cdk.resources.service_principals.secrets'
Raw output
thing = <module 'databricks_cdk.resources.service_principals' from '/home/runner/work/databricks-cdk/databricks-cdk/aws-lambda/src/databricks_cdk/resources/service_principals/__init__.py'>
comp = 'secrets'
import_path = 'databricks_cdk.resources.service_principals.secrets'
def _dot_lookup(thing, comp, import_path):
try:
> return getattr(thing, comp)
E AttributeError: module 'databricks_cdk.resources.service_principals' has no attribute 'secrets'
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1215: AttributeError
During handling of the above exception, another exception occurred:
args = ()
keywargs = {'account_client': <MagicMock spec='AccountClient' id='140417790580768'>}
@wraps(func)
def patched(*args, **keywargs):
> with self.decoration_helper(patched,
args,
keywargs) as (newargs, newkeywargs):
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1322:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py:113: in __enter__
return next(self.gen)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1304: in decoration_helper
arg = exit_stack.enter_context(patching)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py:425: in enter_context
result = _cm_type.__enter__(cm)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1377: in __enter__
self.target = self.getter()
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1552: in <lambda>
getter = lambda: _importer(target)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1228: in _importer
thing = _dot_lookup(thing, comp, import_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
thing = <module 'databricks_cdk.resources.service_principals' from '/home/runner/work/databricks-cdk/databricks-cdk/aws-lambda/src/databricks_cdk/resources/service_principals/__init__.py'>
comp = 'secrets'
import_path = 'databricks_cdk.resources.service_principals.secrets'
def _dot_lookup(thing, comp, import_path):
try:
return getattr(thing, comp)
except AttributeError:
> __import__(import_path)
E ModuleNotFoundError: No module named 'databricks_cdk.resources.service_principals.secrets'
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1217: ModuleNotFoundError
github-actions / JUnit Test Report
test_service_principal_secrets.test_create_service_principal_secrets
AttributeError: Mock object has no attribute 'service_principals'
Raw output
account_client = <MagicMock spec='AccountClient' id='140417806116464'>
def test_create_service_principal_secrets(account_client):
mock_properties = ServicePrincipalSecretsProperties(service_principal_id=1)
account_client.service_principal_secrets.create.return_value = CreateServicePrincipalSecretResponse(id="some_id")
> response = create_service_principal_secrets(mock_properties, account_client)
tests/resources/service_principals/test_service_principal_secrets.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/databricks_cdk/resources/service_principals/service_principal_secrets.py:71: in create_service_principal_secrets
service_principal = get_service_principal(properties.service_principal_id, account_client)
src/databricks_cdk/resources/service_principals/service_principal.py:52: in get_service_principal
service_principal = workspace_client.service_principals.get(id=physical_resource_id)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock spec='AccountClient' id='140417806116464'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError
github-actions / JUnit Test Report
test_service_principal_secrets.test_create_service_principal_secrets_error
AttributeError: Mock object has no attribute 'service_principals'
Raw output
account_client = <MagicMock spec='AccountClient' id='140417805948864'>
def test_create_service_principal_secrets_error(account_client):
mock_properties = ServicePrincipalSecretsProperties(service_principal_id=1)
account_client.service_principal_secrets.create.return_value = CreateServicePrincipalSecretResponse(id=None)
with pytest.raises(ServicePrincipalSecretsCreationError):
> create_service_principal_secrets(mock_properties, account_client)
tests/resources/service_principals/test_service_principal_secrets.py:109:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/databricks_cdk/resources/service_principals/service_principal_secrets.py:71: in create_service_principal_secrets
service_principal = get_service_principal(properties.service_principal_id, account_client)
src/databricks_cdk/resources/service_principals/service_principal.py:52: in get_service_principal
service_principal = workspace_client.service_principals.get(id=physical_resource_id)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock spec='AccountClient' id='140417805948864'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError
github-actions / JUnit Test Report
test_service_principal_secrets.test_delete_service_principal
ModuleNotFoundError: No module named 'databricks_cdk.resources.service_principals.secrets'
Raw output
thing = <module 'databricks_cdk.resources.service_principals' from '/home/runner/work/databricks-cdk/databricks-cdk/aws-lambda/src/databricks_cdk/resources/service_principals/__init__.py'>
comp = 'secrets'
import_path = 'databricks_cdk.resources.service_principals.secrets'
def _dot_lookup(thing, comp, import_path):
try:
> return getattr(thing, comp)
E AttributeError: module 'databricks_cdk.resources.service_principals' has no attribute 'secrets'
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1215: AttributeError
During handling of the above exception, another exception occurred:
args = ()
keywargs = {'account_client': <MagicMock spec='AccountClient' id='140417805802896'>}
@wraps(func)
def patched(*args, **keywargs):
> with self.decoration_helper(patched,
args,
keywargs) as (newargs, newkeywargs):
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1322:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py:113: in __enter__
return next(self.gen)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1304: in decoration_helper
arg = exit_stack.enter_context(patching)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py:425: in enter_context
result = _cm_type.__enter__(cm)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1377: in __enter__
self.target = self.getter()
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1552: in <lambda>
getter = lambda: _importer(target)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1228: in _importer
thing = _dot_lookup(thing, comp, import_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
thing = <module 'databricks_cdk.resources.service_principals' from '/home/runner/work/databricks-cdk/databricks-cdk/aws-lambda/src/databricks_cdk/resources/service_principals/__init__.py'>
comp = 'secrets'
import_path = 'databricks_cdk.resources.service_principals.secrets'
def _dot_lookup(thing, comp, import_path):
try:
return getattr(thing, comp)
except AttributeError:
> __import__(import_path)
E ModuleNotFoundError: No module named 'databricks_cdk.resources.service_principals.secrets'
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1217: ModuleNotFoundError
Loading