Ejemplo n.º 1
0
 def setUp(self):
     super(WhenTestingClientGet, self).setUp()
     self.httpclient = client._HTTPClient(session=self.session,
                                          endpoint=self.endpoint)
     self.headers = dict()
     self.href = 'http://test_href/'
     self.get_mock = self.responses.get(self.href, json={})
Ejemplo n.º 2
0
 def setUp(self):
     super(WhenTestingClientGet, self).setUp()
     self.httpclient = client._HTTPClient(session=self.session,
                                          endpoint=self.endpoint)
     self.headers = dict()
     self.href = 'http://test_href/'
     self.get_mock = self.responses.get(self.href, json={})
Ejemplo n.º 3
0
 def setUp(self):
     super(TestClient, self).setUp()
     self.responses = self.useFixture(fixture.Fixture())
     self.endpoint = "http://localhost:9311"
     self.project_id = "project_id"
     self.session = session.Session()
     self.httpclient = client._HTTPClient(session=self.session, endpoint=self.endpoint, project_id=self.project_id)
Ejemplo n.º 4
0
 def setUp(self):
     super(TestClient, self).setUp()
     self.responses = self.useFixture(fixture.Fixture())
     self.endpoint = 'http://localhost:9311'
     self.project_id = 'project_id'
     self.session = session.Session()
     self.httpclient = client._HTTPClient(session=self.session,
                                          endpoint=self.endpoint,
                                          project_id=self.project_id)
Ejemplo n.º 5
0
    def __init__(self, session=None, *args, **kwargs):
        """Barbican client object used to interact with barbican service.

        :param session: An instance of keystoneauth1.session.Session that
            can be either authenticated, or not authenticated.  When using
            a non-authenticated Session, you must provide some additional
            parameters.  When no session is provided it will default to a
            non-authenticated Session.
        :param endpoint: Barbican endpoint url. Required when a session is not
            given, or when using a non-authenticated session.
            When using an authenticated session, the client will attempt
            to get an endpoint from the session.
        :param project_id: The project ID used for context in Barbican.
            Required when a session is not given, or when using a
            non-authenticated session.
            When using an authenticated session, the project ID will be
            provided by the authentication mechanism.
        :param verify: When a session is not given, the client will create
            a non-authenticated session.  This parameter is passed to the
            session that is created.  If set to False, it allows
            barbicanclient to perform "insecure" TLS (https) requests.
            The server's certificate will not be verified against any
            certificate authorities.
            WARNING: This option should be used with caution.
        :param service_type: Used as an endpoint filter when using an
            authenticated keystone session. Defaults to 'key-management'.
        :param service_name: Used as an endpoint filter when using an
            authenticated keystone session.
        :param interface: Used as an endpoint filter when using an
            authenticated keystone session. Defaults to 'public'.
        :param region_name: Used as an endpoint filter when using an
            authenticated keystone session.
        """
        self.client = base_client._HTTPClient(session=session, *args, **kwargs)

        self.secrets = secrets.SecretManager(self.client)
        self.orders = orders.OrderManager(self.client)
        self.containers = containers.ContainerManager(self.client)
        self.cas = cas.CAManager(self.client)
        self.acls = acls.ACLManager(self.client)
Ejemplo n.º 6
0
 def setUp(self):
     super(WhenTestingClientDelete, self).setUp()
     self.httpclient = client._HTTPClient(session=self.session,
                                          endpoint=self.endpoint)
     self.href = 'http://test_href/'
     self.del_mock = self.responses.delete(self.href, status_code=204)
Ejemplo n.º 7
0
 def setUp(self):
     super(WhenTestingClientPost, self).setUp()
     self.httpclient = client._HTTPClient(session=self.session,
                                          endpoint=self.endpoint)
     self.href = self.endpoint + '/v1/secrets/'
     self.post_mock = self.responses.post(self.href, json={})
Ejemplo n.º 8
0
 def test_endpoint_override_ends_with_default_api_version(self):
     c = client._HTTPClient(session=self.session,
                            endpoint=self.endpoint,
                            project_id=self.project_id)
     self.assertTrue(
         c.endpoint_override.endswith(client._DEFAULT_API_VERSION))
Ejemplo n.º 9
0
 def test_can_be_used_without_a_session(self):
     c = client._HTTPClient(session=self.session, endpoint=self.endpoint, project_id=self.project_id)
     self.assertIsNotNone(c._session)
Ejemplo n.º 10
0
 def test_base_url_ends_with_default_api_version(self):
     c = client._HTTPClient(session=self.session,
                            endpoint=self.endpoint,
                            project_id=self.project_id)
     self.assertTrue(c._base_url.endswith(client._DEFAULT_API_VERSION))
Ejemplo n.º 11
0
 def test_project_id_is_added_to_default_headers(self):
     c = client._HTTPClient(session=self.session,
                            endpoint=self.endpoint,
                            project_id=self.project_id)
     self.assertIn('X-Project-Id', c._default_headers.keys())
     self.assertEqual(c._default_headers['X-Project-Id'], self.project_id)
Ejemplo n.º 12
0
 def test_api_version_is_appended_to_endpoint(self):
     c = client._HTTPClient(session=self.session,
                            endpoint=self.endpoint,
                            project_id=self.project_id)
     self.assertEqual('http://localhost:9311/v1', c.endpoint_override)
Ejemplo n.º 13
0
 def setUp(self):
     super(WhenTestingClientDelete, self).setUp()
     self.httpclient = client._HTTPClient(session=self.session,
                                          endpoint=self.endpoint)
     self.href = 'http://test_href/'
     self.del_mock = self.responses.delete(self.href, status_code=204)
Ejemplo n.º 14
0
 def test_gets_endpoint_from_keystone_session(self):
     c = client._HTTPClient(session=self.session, endpoint=self.endpoint)
     self.assertEqual(c._barbican_endpoint, self.endpoint)
Ejemplo n.º 15
0
 def test_client_strips_trailing_slash_from_endpoint(self):
     c = client._HTTPClient(session=self.session, endpoint=self.endpoint + "/", project_id=self.project_id)
     self.assertEqual(c._barbican_endpoint, self.endpoint)
Ejemplo n.º 16
0
 def test_api_version_is_appended_to_endpoint(self):
     c = client._HTTPClient(session=self.session,
                            endpoint=self.endpoint,
                            project_id=self.project_id)
     self.assertEqual(c._base_url, 'http://localhost:9311/v1')
Ejemplo n.º 17
0
 def test_default_headers_are_empty(self):
     c = client._HTTPClient(session=self.session, endpoint=self.endpoint)
     self.assertIsInstance(c._default_headers, dict)
     self.assertFalse(bool(c._default_headers))
Ejemplo n.º 18
0
 def test_default_headers_are_empty(self):
     c = client._HTTPClient(session=self.session, endpoint=self.endpoint)
     self.assertIsInstance(c._default_headers, dict)
     self.assertFalse(bool(c._default_headers))
Ejemplo n.º 19
0
 def test_base_url_starts_with_endpoint_url(self):
     c = client._HTTPClient(session=self.session,
                            endpoint=self.endpoint,
                            project_id=self.project_id)
     self.assertTrue(c._base_url.startswith(self.endpoint))
Ejemplo n.º 20
0
 def test_project_id_is_added_to_default_headers(self):
     c = client._HTTPClient(session=self.session,
                            endpoint=self.endpoint,
                            project_id=self.project_id)
     self.assertIn('X-Project-Id', c._default_headers.keys())
     self.assertEqual(self.project_id, c._default_headers['X-Project-Id'])
Ejemplo n.º 21
0
 def setUp(self):
     super(WhenTestingClientPost, self).setUp()
     self.httpclient = client._HTTPClient(session=self.session,
                                          endpoint=self.endpoint)
     self.href = self.endpoint + '/v1/secrets/'
     self.post_mock = self.responses.post(self.href, json={})
Ejemplo n.º 22
0
 def test_endpoint_override_starts_with_endpoint_url(self):
     c = client._HTTPClient(session=self.session,
                            endpoint=self.endpoint,
                            project_id=self.project_id)
     self.assertTrue(c.endpoint_override.startswith(self.endpoint))