How to use delete_secret method in localstack

Best Python code snippet using localstack_python

test_utils.py

Source:test_utils.py Github

copy

Full Screen

1# Copyright (c) 2014 Mirantis Inc.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or12# implied.13# See the License for the specific language governing permissions and14# limitations under the License.15import mock16from sahara.plugins.vanilla.hadoop2 import utils as u17from sahara.tests.unit import base18from sahara.utils import files19class UtilsTestCase(base.SaharaTestCase):20 @mock.patch('sahara.plugins.vanilla.utils.get_namenode')21 def test_datanodes_status(self, nn):22 report = files.get_file_text(23 'tests/unit/plugins/vanilla/hadoop2/resources/dfs-report.txt')24 nn.return_value = self._get_instance(report)25 statuses = u.get_datanodes_status(None)26 expected = {27 'cluster-worker-001.novalocal': 'normal',28 'cluster-worker-002.novalocal': 'normal',29 'cluster-worker-003.novalocal': 'normal',30 'cluster-worker-004.novalocal': 'decommissioned'31 }32 self.assertEqual(expected, statuses)33 @mock.patch('sahara.plugins.vanilla.utils.get_resourcemanager')34 def test_nodemanagers_status(self, rm):35 report = files.get_file_text(36 'tests/unit/plugins/vanilla/hadoop2/resources/yarn-report.txt')37 rm.return_value = self._get_instance(report)38 statuses = u.get_nodemanagers_status(None)39 expected = {40 'cluster-worker-001.novalocal': 'running',41 'cluster-worker-002.novalocal': 'running',42 'cluster-worker-003.novalocal': 'running',43 'cluster-worker-004.novalocal': 'decommissioned'44 }45 self.assertEqual(expected, statuses)46 def _get_instance(self, out):47 inst_remote = mock.MagicMock()48 inst_remote.execute_command.return_value = 0, out49 inst_remote.__enter__.return_value = inst_remote50 inst = mock.MagicMock()51 inst.remote.return_value = inst_remote52 return inst53 @mock.patch('sahara.conductor.API.cluster_get')54 @mock.patch('sahara.service.castellan.utils.get_secret')55 @mock.patch('sahara.service.castellan.utils.store_secret')56 @mock.patch('sahara.plugins.vanilla.utils')57 @mock.patch('sahara.conductor.API.cluster_update')58 def test_oozie_password(self, cluster_update, vu,59 store_secret, get_secret, conductor):60 cluster = mock.MagicMock()61 cluster.extra = mock.MagicMock()62 cluster.extra.to_dict.return_value = {"oozie_pass_id": "31415926"}63 conductor.return_value = cluster64 get_secret.return_value = "oozie_pass"65 result = u.get_oozie_password(cluster)66 get_secret.assert_called_once_with("31415926")67 vu.generate_random_password.assert_not_called()68 self.assertEqual('oozie_pass', result)69 cluster.extra.to_dict.return_value = {}70 store_secret.return_value = 'oozie_pass'71 result = u.get_oozie_password(cluster)72 self.assertEqual('oozie_pass', result)73 @mock.patch('sahara.service.castellan.utils.delete_secret')74 def test_delete_oozie_password(self, delete_secret):75 cluster = mock.MagicMock()76 cluster.extra.to_dict = mock.MagicMock()77 cluster.extra.to_dict.return_value = {}78 u.delete_oozie_password(cluster)79 delete_secret.assert_not_called()80 cluster.extra.to_dict.return_value = {"oozie_pass_id": "31415926"}81 u.delete_oozie_password(cluster)82 delete_secret.assert_called_once_with("31415926")83 @mock.patch('sahara.conductor.API.cluster_get')84 @mock.patch('sahara.service.castellan.utils.get_secret')85 @mock.patch('sahara.service.castellan.utils.store_secret')86 @mock.patch('sahara.conductor.API.cluster_update')87 def test_get_hive_password(self, cluster_update,88 store_secret, get_secret, conductor):89 cluster = mock.MagicMock()90 cluster.extra.to_dict.return_value = {"hive_pass_id": "31415926"}91 conductor.return_value = cluster92 get_secret.return_value = "hive_pass"93 result = u.get_hive_password(cluster)94 get_secret.assert_called_once_with("31415926")95 self.assertEqual('hive_pass', result)96 cluster.extra.to_dict.return_value = {}97 store_secret.return_value = 'hive_pass'98 result = u.get_hive_password(cluster)99 self.assertEqual('hive_pass', result)100 @mock.patch('sahara.service.castellan.utils.delete_secret')101 def test_delete_hive_password(self, delete_secret):102 cluster = mock.MagicMock()103 cluster.extra.to_dict.return_value = {}104 u.delete_hive_password(cluster)105 delete_secret.assert_not_called()106 cluster.extra.to_dict.return_value = {"hive_pass_id": "31415926"}107 u.delete_hive_password(cluster)...

Full Screen

Full Screen

delete_tenant.py

Source:delete_tenant.py Github

copy

Full Screen

...23 if lrs['lrsName'] == tenant:24 lrs_id = lrs['_id']25 requests.delete(lrs_url + 'lrs/' + lrs_id, headers = {"Content-Type": "application/json", "x-veracity-api-key": lrs_api_key })26 stack = cf_client.describe_stacks(StackName=tenant)27 secrets_client.delete_secret(SecretId=tenant + "_db_password")28 secrets_client.delete_secret(SecretId=tenant + "_user_password")29 secrets_client.delete_secret(SecretId=tenant + "_lrs_key_password")30 secrets_client.delete_secret(SecretId=tenant + "_cron_key")31 secrets_client.delete_secret(SecretId=tenant + "_smtp_password")32 # Remove files in EFS33 if(not (tenant and not tenant.isspace())):34 print('Tenant is empty. Please remove files from EFS.')35 else:36 dest = "/mnt/efs/" + tenant37 shutil.rmtree(dest)38 parameters = stack['Stacks'][0]['Parameters']39 for parameter in parameters:40 if 'BRAND' in parameter['ParameterKey']:41 brand = parameter['ParameterValue']42 db_name = tenant + "_" + brand43 cf_client.delete_stack(StackName=tenant)44 mydb = mysql.connector.connect(45 host=rds_host,...

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 localstack 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