Beispiel #1
0
    def _auth_required(self, auth, msg):
        if not auth:
            auth = self.auth

        if not auth:
            msg_fmt = 'An auth plugin is required to %s'
            raise exceptions.MissingAuthPlugin(msg_fmt % msg)

        return auth
Beispiel #2
0
 def test_authorize_no_authplugin(self):
     fake_session = mock.Mock()
     ex_auth = ksa_exc.MissingAuthPlugin("missing auth plugin")
     fake_session.get_auth_headers.side_effect = ex_auth
     sot = connection.Connection(session=fake_session,
                                 authenticator=mock.Mock())
     ex = self.assertRaises(exceptions.HttpException, sot.authorize)
     self.assertEqual(400, ex.status_code)
     self.assertEqual('HttpException: Bad Request, missing auth plugin',
                      six.text_type(ex))
Beispiel #3
0
    def test_no_auth(self, auth):
        """Test failure when no credentials are specified.

        Replicate in devstack: start devstack with or without
        placement engine, remove the auth section from the [placement]
        block in nova.conf.
        """
        auth.side_effect = ks_exc.MissingAuthPlugin()
        res = self.cmd._check_placement()
        self.assertEqual(status.UpgradeCheckCode.FAILURE, res.code)
        self.assertIn('No credentials specified', res.details)
Beispiel #4
0
 def test_power_update_failed_no_nova_auth_url(self, mock_adapter,
                                               mock_log):
     server = 'server-id-1'
     emsg = 'An auth plugin is required to determine endpoint URL'
     side_effect = kaexception.MissingAuthPlugin(emsg)
     mock_nova = mock.Mock()
     mock_adapter.return_value = mock_nova
     mock_nova.post.side_effect = side_effect
     result = self.api.power_update(self.ctx, server, 'power off')
     msg = ('Could not connect to Nova to send a power notification, '
            'please check configuration. %s', side_effect)
     self.assertFalse(result)
     mock_log.warning.assert_called_once_with(*msg)
     mock_adapter.assert_called_once_with()
Beispiel #5
0
    def test_missing_auth(self, req):
        """Test Missing Auth handled correctly.

        A missing auth configuration should permanently disable the
        client. And make future calls to it not happen.

        """
        req.side_effect = ks_exc.MissingAuthPlugin()
        self.client._get_resource_provider("fake")
        self.assertTrue(self.client._disabled)

        # reset the call count to demonstrate that future calls don't
        # work
        req.reset_mock()
        self.client._get_resource_provider("fake")
        req.assert_not_called()