Ejemplo n.º 1
0
    def test_create_container_w_duplicate_secret_refs(self):
        """Covers creating a container with a duplicated secret ref."""

        secret_resp = self.secret_behaviors.create_secret_from_config()
        secret_refs = [SecretRef(name='1', ref=secret_resp.ref),
                       SecretRef(name='2', ref=secret_resp.ref)]

        container_resp = self.behaviors.create_container(
            'name', 'generic', secret_refs)

        self.assertEqual(container_resp.status_code, 400)
Ejemplo n.º 2
0
    def test_create_rsa_container_w_no_private_key(self):
        """Creating an rsa container without a private key should fail. RSA
        containers must have at least a public key and private key.
        """
        secret_urls = self.secret_behaviors.create_n_secrets(1)
        secret_refs = [SecretRef(name='private_key', ref=secret_urls[0])]

        container_resp = self.behaviors.create_rsa_container(
            'name', 'rsa', secret_refs)
        self.assertEqual(container_resp.status_code, 400)
Ejemplo n.º 3
0
 def test_create_container_w_order_ref(self):
     """Checks that creating a container with an order ref fails. Containers
     are only allowed to contain references to secrets.
     """
     order_resp = self.order_behaviors.create_order_from_config()
     order_ref = order_resp.ref
     secret_refs = [SecretRef(name='order', ref=order_ref)]
     container_resp = self.behaviors.create_container(
         'name', 'generic', secret_refs)
     self.assertEqual(container_resp.status_code, 404)
Ejemplo n.º 4
0
 def test_create_rsa_container_w_invalid_key_names(self):
     """Covers creating an rsa container with three secrets that have the
     wrong names.
     """
     secret_urls = self.secret_behaviors.create_n_secrets(3)
     secret_refs = [SecretRef(name='secret{0}'.format(i), ref=url)
                    for i, url in enumerate(secret_urls)]
     container_resp = self.behaviors.create_container(
         'name', 'rsa', secret_refs)
     self.assertEqual(container_resp.status_code, 400)
Ejemplo n.º 5
0
    def create_container_with_secret(self, name="test_container",
                                     secret_name="test_secret"):
        """Create a secret and a generic container with that secret inside.

        :param name: The name of the container
        :param secret_name: The name of the secret in the container
        :returns: A tuple containing the responses from the secret creation and
            the container creation, in that order
        """
        secret_resp = self.secret_behaviors.create_secret_from_config()
        secret_refs = [SecretRef(name=secret_name, ref=secret_resp.ref)]
        container_resp = self.create_container(name, "generic", secret_refs)
        return (secret_resp, container_resp)
Ejemplo n.º 6
0
    def create_rsa_container(self, name, priv_key_ref, pub_key_ref,
                             priv_pass_ref=None):
        """ Creates an RSA container based on pre-created HATOAS secret
        reference urls.

        :param name: Container name
        :param priv_key_ref: HATOAS reference to a secret containing
            a private key.
        :param priv_pass_ref: HATOAS reference to a secret containing
            a private key passphrase.
        :param pub_key_ref: HATOAS reference to a secret containing
            a public key.
        """
        priv_pass = SecretRef(name='private_key_passphrase', ref=priv_pass_ref)
        priv = SecretRef(name='private_key', ref=priv_key_ref)
        pub = SecretRef(name='public_key', ref=pub_key_ref)

        refs = [pub, priv]
        if priv_pass_ref:
            refs.append(priv_pass)

        return self.create_container(name=name,
                                     container_type='rsa',
                                     secret_refs=refs)
Ejemplo n.º 7
0
    def ddtest_create_container_of_size(self, num_secrets=None):
        """Covers creating containers of various sizes."""
        # create the given number of secrets
        secret_urls = self.secret_behaviors.create_n_secrets(num_secrets)
        secret_refs = [SecretRef(name='secret{0}'.format(i), ref=url)
                       for i, url in enumerate(secret_urls)]

        # create the container and check the response
        container_resp = self.behaviors.create_container('name', 'generic',
                                                         secret_refs)
        self._check_container_create_response(container_resp)

        # get the container and verify its contents
        get_resp = self.container_client.get_container(container_resp.ref)
        self._check_container_get_resp(get_resp, ref=container_resp.ref,
                                       name='name', type='generic',
                                       num_secrets=num_secrets)