Esempio n. 1
0
 def test__get_auth(self, legacy_mock, load_mock):
     auth1 = mock.Mock()
     load_mock.side_effect = [
         auth1, None,
         kaexc.MissingRequiredOptions([kaloading.Opt('spam')])
     ]
     auth2 = mock.Mock()
     legacy_mock.return_value = auth2
     self.assertEqual(auth1, keystone._get_auth(TESTGROUP))
     self.assertEqual(auth2, keystone._get_auth(TESTGROUP))
     self.assertEqual(auth2, keystone._get_auth(TESTGROUP))
Esempio n. 2
0
 def test_client_with_password_legacy(self, mock_v3, mock_loading, mock_ks):
     self.ctx.is_admin = True
     mock_loading.load_auth_from_conf_options.side_effect = \
         ka_exception.MissingRequiredOptions(mock.MagicMock())
     ks_client = keystone.KeystoneClientV3(self.ctx)
     ks_client.client
     session = ks_client.session
     self.assertWarnsRegex(Warning,
                           '[keystone_authtoken] section is deprecated')
     mock_v3.Password.assert_called_once_with(
         auth_url='http://server.test:5000/v3', password='******',
         project_domain_id='default', project_name='service',
         user_domain_id='default', username='******')
     mock_ks.assert_called_once_with(session=session, trust_id=None)
Esempio n. 3
0
    def load_from_options(self, **kwargs):
        """Create a plugin from the arguments retrieved from get_options.

        A client can override this function to do argument validation or to
        handle differences between the registered options and what is required
        to create the plugin.
        """
        missing_required = [
            o for o in self.get_options()
            if o.required and kwargs.get(o.dest) is None
        ]

        if missing_required:
            raise exceptions.MissingRequiredOptions(missing_required)

        return self.create_plugin(**kwargs)
Esempio n. 4
0
 def test___init__keystone_failure(self, connection_mock, load_mock,
                                   opts_mock, adapter_mock):
     adapter_mock.side_effect = ks_exc.MissingRequiredOptions([])
     self.assertRaisesRegex(utils.Error, 'Could not create an adapter',
                            swift.SwiftAPI)
     self.assertFalse(connection_mock.called)