How to use get_storage_credential method in lisa

Best Python code snippet using lisa_python

api.py

Source:api.py Github

copy

Full Screen

...71 def create_storage_credential(self, cred_spec, skip_validation):72 return self.client.create_storage_credential(cred_spec, skip_validation)73 def list_storage_credentials(self, name_pattern):74 return self.client.list_storage_credentials(name_pattern)75 def get_storage_credential(self, name):76 return self.client.get_storage_credential(name)77 def update_storage_credential(self, name, cred_spec, skip_validation):78 return self.client.update_storage_credential(name, cred_spec, skip_validation)79 def delete_storage_credential(self, name, force):80 return self.client.delete_storage_credential(name, force)81 # Catalog APIs82 def create_catalog(self, catalog_name, comment, provider, share):83 return self.client.create_catalog(catalog_name, comment, provider, share)84 def list_catalogs(self):85 return self.client.list_catalogs()86 def get_catalog(self, name):87 return self.client.get_catalog(name)88 def update_catalog(self, name, catalog_spec):89 return self.client.update_catalog(name, catalog_spec)90 def delete_catalog(self, catalog_name):...

Full Screen

Full Screen

test_cred_cli.py

Source:test_cred_cli.py Github

copy

Full Screen

1# Databricks CLI2# Copyright 2017 Databricks, Inc.3#4# Licensed under the Apache License, Version 2.0 (the "License"), except5# that the use of services to which certain application programming6# interfaces (each, an "API") connect requires that the user first obtain7# a license for the use of the APIs from Databricks, Inc. ("Databricks"),8# by creating an account at www.databricks.com and agreeing to either (a)9# the Community Edition Terms of Service, (b) the Databricks Terms of10# Service, or (c) another written agreement between Licensee and Databricks11# for the use of the APIs.12#13# You may not use this file except in compliance with the License.14# You may obtain a copy of the License at15#16# http://www.apache.org/licenses/LICENSE-2.017#18# Unless required by applicable law or agreed to in writing, software19# distributed under the License is distributed on an "AS IS" BASIS,20# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.21# See the License for the specific language governing permissions and22# limitations under the License.23# pylint:disable=redefined-outer-name24import mock25import pytest26from click.testing import CliRunner27from databricks_cli.unity_catalog.utils import mc_pretty_format28from databricks_cli.unity_catalog import cred_cli29from tests.utils import provide_conf30STORAGE_CREDENTIAL_NAME = 'test_storage_credential_name'31AWS_IAM_ROLE_ARN = 'test_aws_iam_role_arn'32AZ_SP_DIRECTORY_ID = 'test_az_sp_directory_id'33AZ_SP_APPLICATION_ID = 'test_az_sp_application_id'34AZ_SP_CLIENT_SEC = 'test_az_sp_client_secret' # Named as such to suppress dodgy lint warnings35AZ_MI_ACCESS_CONNECTOR_ID = 'test_mi_access_connector_id'36AZ_MI_ID = 'test_mi_mid'37GCP_SAK_EMAIL = 'test_sak_email'38GCP_SAK_PRIVATE_KEY_ID = 'test_sak_private_key_id'39GCP_SAK_PRIVATE_KEY = 'test_sak_private_key'40COMMENT = 'some_comment'41STORAGE_CREDENTIALS = {42 'storage_credentials': [43 {44 'name': STORAGE_CREDENTIAL_NAME45 }46 ]47}48STORAGE_CREDENTIAL = {49 'name': STORAGE_CREDENTIAL_NAME,50 'aws_iam_role': {51 'role_arn': AWS_IAM_ROLE_ARN52 },53 'azure_service_principal': {54 'directory_id': AZ_SP_DIRECTORY_ID,55 'application_id': AZ_SP_APPLICATION_ID,56 'client_secret': AZ_SP_CLIENT_SEC57 },58 'azure_managed_identity': {59 'access_connector_id': AZ_MI_ACCESS_CONNECTOR_ID,60 'managed_identity_id': AZ_MI_ID61 },62 'gcp_service_account_key': {63 'email': GCP_SAK_EMAIL,64 'private_key_id': GCP_SAK_PRIVATE_KEY_ID,65 'private_key': GCP_SAK_PRIVATE_KEY66 },67 'comment': COMMENT68}69@pytest.fixture()70def api_mock():71 with mock.patch(72 'databricks_cli.unity_catalog.cred_cli.UnityCatalogApi') as uc_api_mock:73 _cred_api_mock = mock.MagicMock()74 uc_api_mock.return_value = _cred_api_mock75 yield _cred_api_mock76@pytest.fixture()77def echo_mock():78 with mock.patch('databricks_cli.unity_catalog.cred_cli.click.echo') as echo_mock:79 yield echo_mock80@provide_conf81def test_create_credential_cli(api_mock, echo_mock):82 api_mock.create_storage_credential.return_value = STORAGE_CREDENTIAL83 runner = CliRunner()84 runner.invoke(85 cred_cli.create_credential_cli,86 args=[87 '--name', STORAGE_CREDENTIAL_NAME,88 '--aws-iam-role-arn', AWS_IAM_ROLE_ARN,89 '--az-sp-directory-id', AZ_SP_DIRECTORY_ID,90 '--az-sp-application-id', AZ_SP_APPLICATION_ID,91 '--az-sp-client-secret', AZ_SP_CLIENT_SEC,92 '--az-mi-access-connector-id', AZ_MI_ACCESS_CONNECTOR_ID,93 '--az-mi-id', AZ_MI_ID,94 '--gcp-sak-email', GCP_SAK_EMAIL,95 '--gcp-sak-private-key-id', GCP_SAK_PRIVATE_KEY_ID,96 '--gcp-sak-private-key', GCP_SAK_PRIVATE_KEY,97 '--comment', COMMENT,98 '--skip-validation'99 ])100 api_mock.create_storage_credential.assert_called_once_with(STORAGE_CREDENTIAL, True)101 echo_mock.assert_called_once_with(mc_pretty_format(STORAGE_CREDENTIAL))102@provide_conf103def test_create_credential_cli_with_json(api_mock, echo_mock):104 api_mock.create_storage_credential.return_value = STORAGE_CREDENTIAL105 runner = CliRunner()106 runner.invoke(107 cred_cli.create_credential_cli,108 args=[109 '--json', '{ "name": "test_credential_name" }'110 ])111 api_mock.create_storage_credential.assert_called_once_with(112 {113 'name': 'test_credential_name'114 },115 False)116 echo_mock.assert_called_once_with(mc_pretty_format(STORAGE_CREDENTIAL))117@provide_conf118def test_list_credentials_cli(api_mock, echo_mock):119 api_mock.list_storage_credentials.return_value = STORAGE_CREDENTIALS120 runner = CliRunner()121 runner.invoke(cred_cli.list_credentials_cli)122 api_mock.list_storage_credentials.assert_called_once()123 echo_mock.assert_called_once_with(mc_pretty_format(STORAGE_CREDENTIALS))124@provide_conf125def test_get_credential_cli(api_mock, echo_mock):126 api_mock.get_storage_credential.return_value = STORAGE_CREDENTIAL127 runner = CliRunner()128 runner.invoke(129 cred_cli.get_credential_cli,130 args=['--name', STORAGE_CREDENTIAL_NAME])131 api_mock.get_storage_credential.assert_called_once_with(STORAGE_CREDENTIAL_NAME)132 echo_mock.assert_called_once_with(mc_pretty_format(STORAGE_CREDENTIAL))133@provide_conf134def test_update_credential_cli(api_mock, echo_mock):135 api_mock.update_storage_credential.return_value = STORAGE_CREDENTIAL136 runner = CliRunner()137 runner.invoke(138 cred_cli.update_credential_cli,139 args=[140 '--name', STORAGE_CREDENTIAL_NAME,141 '--new-name', 'new_credential_name',142 '--aws-iam-role-arn', AWS_IAM_ROLE_ARN,143 '--az-sp-directory-id', AZ_SP_DIRECTORY_ID,144 '--az-sp-application-id', AZ_SP_APPLICATION_ID,145 '--az-sp-client-secret', AZ_SP_CLIENT_SEC,146 '--az-mi-access-connector-id', AZ_MI_ACCESS_CONNECTOR_ID,147 '--az-mi-id', AZ_MI_ID,148 '--gcp-sak-email', GCP_SAK_EMAIL,149 '--gcp-sak-private-key-id', GCP_SAK_PRIVATE_KEY_ID,150 '--gcp-sak-private-key', GCP_SAK_PRIVATE_KEY,151 '--comment', COMMENT,152 '--owner', 'owner',153 '--skip-validation'154 ])155 expected_data = {156 'name': 'new_credential_name',157 'aws_iam_role': {158 'role_arn': AWS_IAM_ROLE_ARN159 },160 'azure_service_principal': {161 'directory_id': AZ_SP_DIRECTORY_ID,162 'application_id': AZ_SP_APPLICATION_ID,163 'client_secret': AZ_SP_CLIENT_SEC164 },165 'azure_managed_identity': {166 'access_connector_id': AZ_MI_ACCESS_CONNECTOR_ID,167 'managed_identity_id': AZ_MI_ID168 },169 'gcp_service_account_key': {170 'email': GCP_SAK_EMAIL,171 'private_key_id': GCP_SAK_PRIVATE_KEY_ID,172 'private_key': GCP_SAK_PRIVATE_KEY173 },174 'comment': COMMENT,175 'owner': 'owner'176 }177 api_mock.update_storage_credential.assert_called_once_with(178 STORAGE_CREDENTIAL_NAME, expected_data, True)179 echo_mock.assert_called_once_with(mc_pretty_format(STORAGE_CREDENTIAL))180@provide_conf181def test_update_credential_cli_with_json(api_mock, echo_mock):182 api_mock.update_storage_credential.return_value = STORAGE_CREDENTIAL183 runner = CliRunner()184 runner.invoke(185 cred_cli.update_credential_cli,186 args=[187 '--name', STORAGE_CREDENTIAL_NAME,188 '--json', '{ "name": "new_credential_name" }'189 ])190 api_mock.update_storage_credential.assert_called_once_with(191 STORAGE_CREDENTIAL_NAME,192 {193 'name': 'new_credential_name'194 },195 False)196 echo_mock.assert_called_once_with(mc_pretty_format(STORAGE_CREDENTIAL))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful