Пример #1
0
 def test_auth_call():
     plugin = auth_plugin.DeprecatedAuthPlugin("fakewithauthurl")
     cs = client.Client("username", "password", "project_id",
                        auth_system="fakewithauthurl",
                        auth_plugin=plugin)
     cs.client.authenticate()
     self.assertEqual(cs.client.auth_url, "http://faked/v2.0")
Пример #2
0
 def test_auth_call():
     auth_plugin.discover_auth_systems()
     plugin = auth_plugin.DeprecatedAuthPlugin("notexists")
     cs = client.Client("username", "password", "project_id",
                        "auth_url/v2.0", auth_system="notexists",
                        auth_plugin=plugin)
     self.assertRaises(exceptions.AuthSystemNotFound,
                       cs.client.authenticate)
Пример #3
0
        def test_auth_call():
            plugin = auth_plugin.DeprecatedAuthPlugin("fake")
            cs = client.Client("username", "password", "project_id",
                               "auth_url/v2.0", auth_system="fake",
                               auth_plugin=plugin)
            cs.client.authenticate()

            headers = requested_headers(cs)
            token_url = cs.client.auth_url + "/tokens"

            mock_request.assert_called_with(
                "POST",
                token_url,
                headers=headers,
                data='{"fake": "me"}',
                allow_redirects=True,
                **self.TEST_REQUEST_BASE)
Пример #4
0
    def test_client_raises_exc_without_auth_url(self, mock_iter_entry_points):
        class MockAuthUrlEntrypoint(pkg_resources.EntryPoint):
            def load(self):
                return self.auth_url

            def auth_url(self):
                return None

        mock_iter_entry_points.side_effect = lambda _t, name: [
            MockAuthUrlEntrypoint("fakewithauthurl",
                                  "fakewithauthurl",
                                  ["auth_url"])]

        plugin = auth_plugin.DeprecatedAuthPlugin("fakewithauthurl")
        self.assertRaises(
            exceptions.EndpointNotFound,
            client.Client, "username", "password", "project_id",
            auth_system="fakewithauthurl", auth_plugin=plugin)