def test_delete(self):
        arglist = ['vault', 'policy']
        verifylist = [
            ('vault', 'vault'),
            ('policy', 'policy'),
        ]
        # Verify cm is triggereg with default parameters
        parsed_args = self.check_parser(self.cmd, arglist, verifylist)

        # Set the response for find_vault
        self.client.find_vault.side_effect = [vaultSDK.Vault(id='vault')]

        # Set the response
        self.client.unbind_policy.side_effect = [{}]

        # Trigger the action
        self.cmd.take_action(parsed_args)

        unbind_calls = [
            mock.call(vault='vault', policy='policy'),
        ]

        find_calls = [
            mock.call(name_or_id='vault', ignore_missing=False),
        ]

        self.client.find_vault.assert_has_calls(find_calls)
        self.client.unbind_policy.assert_has_calls(unbind_calls)
        self.assertEqual(1, self.client.unbind_policy.call_count)
    def test_default(self):
        arglist = [
            'vault_id',
            'policy_id',
        ]
        verifylist = [
            ('vault', 'vault_id'),
            ('policy', 'policy_id'),
        ]

        # Verify cm is triggereg with default parameters
        parsed_args = self.check_parser(self.cmd, arglist, verifylist)

        # Set the response for find_vault
        self.client.find_vault.side_effect = [vaultSDK.Vault(id='vault_id')]

        # Set the response
        self.client.bind_policy.side_effect = [self.object]

        # Trigger the action
        columns, data = self.cmd.take_action(parsed_args)

        self.client.bind_policy.assert_called_with(vault='vault_id',
                                                   policy='policy_id')

        self.client.bind_policy.assert_called_once_with(vault='vault_id',
                                                        policy='policy_id')

        self.assertEqual(self.columns, columns)
        self.assertEqual(self.data, data)
    def test_delete(self):
        arglist = ['vault', '--resource', 'resource']
        verifylist = [
            ('vault', 'vault'),
            ('resource', ['resource']),
        ]
        # Verify cm is triggereg with default parameters
        parsed_args = self.check_parser(self.cmd, arglist, verifylist)

        # Set the response for find_vault
        self.client.find_vault.side_effect = [vaultSDK.Vault(id='vault')]

        # Set the response
        self.client.dissociate_resources.side_effect = [{}]

        # Trigger the action
        self.cmd.take_action(parsed_args)

        dissociate_calls = [
            mock.call(vault='vault', resources=['resource']),
        ]

        find_calls = [
            mock.call(name_or_id='vault', ignore_missing=False),
        ]

        self.client.find_vault.assert_has_calls(find_calls)
        self.client.dissociate_resources.assert_has_calls(dissociate_calls)
        self.assertEqual(1, self.client.dissociate_resources.call_count)
Example #4
0
 def test_unbind_policy(self):
     vault = _vault.Vault(id='vault')
     policy = _policy.Policy(id='policy')
     self._verify('otcextensions.sdk.cbr.v3.vault.Vault.unbind_policy',
                  self.proxy.unbind_policy,
                  method_args=[vault, policy],
                  expected_args=[self.proxy],
                  expected_kwargs={'policy_id': 'policy'})
 def test_dissociate_resources(self):
     vault = _vault.Vault(id='vault')
     resources = 'resources'
     self._verify2(
         'otcextensions.sdk.cbr.v3.vault.Vault.dissociate_resources',
         self.proxy.dissociate_resources,
         method_args=[vault, resources],
         expected_args=[self.proxy, resources],
     )
 def test_basic(self):
     sot = vault.Vault()
     self.assertEqual('vault', sot.resource_key)
     self.assertEqual('vaults', sot.resources_key)
     self.assertEqual('/vaults', sot.base_path)
     self.assertTrue(sot.allow_list)
     self.assertTrue(sot.allow_create)
     self.assertTrue(sot.allow_fetch)
     self.assertTrue(sot.allow_commit)
     self.assertTrue(sot.allow_delete)
 def setUp(self):
     super(TestVault, self).setUp()
     self.sess = mock.Mock(spec=adapter.Adapter)
     self.sess.default_microversion = None
     self.sess.get = mock.Mock()
     self.sess.post = mock.Mock()
     self.sess.delete = mock.Mock()
     self.sess.put = mock.Mock()
     self.sess.retriable_status_codes = ()
     self.sot = vault.Vault()
Example #8
0
 def test_update(self):
     backup = _backup.Backup(id='backup')
     member = _member.Member(id='member')
     status = 'accepted'
     vault = _vault.Vault(id='vault')
     self._verify('openstack.proxy.Proxy._update',
                  self.proxy.update_member,
                  method_args=[backup, member, status, vault],
                  method_kwargs={},
                  expected_args=[_member.Member, member],
                  expected_kwargs={
                      'backup_id': backup.id,
                      'status': status,
                      'vault_id': vault.id
                  })
    def test_default(self):
        arglist = [
            'vault_id', '--resource', 'id=resource_id type=resource_type'
        ]
        verifylist = [
            ('vault', 'vault_id'),
            ('resource', ['id=resource_id type=resource_type']),
        ]

        # Verify cm is triggereg with default parameters
        parsed_args = self.check_parser(self.cmd, arglist, verifylist)

        # Set the response for find_vault
        self.client.find_vault.side_effect = [vaultSDK.Vault(id='vault_id')]

        # Set the response
        self.client.associate_resources.side_effect = [self.object]

        # Trigger the action
        columns, data = self.cmd.take_action(parsed_args)

        self.client.associate_resources.assert_called_with(vault='vault_id',
                                                           resources=[{
                                                               'id':
                                                               'resource_id',
                                                               'type':
                                                               'resource_type'
                                                           }])

        self.client.associate_resources.assert_called_once_with(
            vault='vault_id',
            resources=[{
                'id': 'resource_id',
                'type': 'resource_type'
            }])

        self.assertEqual(self.columns, columns)
        self.assertEqual(self.data, data)