How to use the testtools.testcase function in testtools

To help you get started, we’ve selected a few testtools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / python-barbicanclient / functionaltests / cli / v1 / smoke / test_acl.py View on Github external
    @testcase.attr('positive')
    def test_acl_get(self):
        secret_ref = self.secret_behaviors.store_secret()
        container_ref = self.container_behaviors.create_container(
            secret_hrefs=[secret_ref])

        data = self.acl_behaviors.acl_submit(entity_ref=secret_ref,
                                             users=['u1', 'u2'])
        self.assertIsNotNone(data)

        data = self.acl_behaviors.acl_get(entity_ref=secret_ref)

        self.assertIn('u2', data['Users'])
        self.assertEqual('True', data['Project Access'])
        self.assertEqual(secret_ref + "/acl", data['Secret ACL Ref'])

        data = self.acl_behaviors.acl_get(entity_ref=secret_ref + "///")
github openstack / python-barbicanclient / functionaltests / client / v1 / functional / test_containers.py View on Github external
    @testcase.attr('negative')
    def test_create_rsa_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.
        """
        no_private_key_rsa_container = {
            "name": "no_pub_key",
            "public_key": self.secret_1,
            "private_key_passphrase": self.secret_2}

        container = self.barbicanclient.containers.create_rsa(
            **no_private_key_rsa_container)

        e = self.assertRaises(
            exceptions.HTTPClientError,
            container.store
github openstack / python-barbicanclient / functionaltests / cli / v1 / smoke / test_secret.py View on Github external
    @testcase.attr('positive')
    def test_secret_update(self):
        secret_href = self.secret_behaviors.store_secret(
            payload=None)

        payload = 'time for an ice cold!!!'
        self.assertIsNotNone(secret_href)
        self.secret_behaviors.update_secret(secret_href,
                                            payload)

        payload_update = self.secret_behaviors.get_secret_payload(secret_href)
        self.assertEqual(payload, payload_update)
github openstack / barbican / functionaltests / api / v1 / functional / test_orders.py View on Github external
    @testcase.attr('negative', 'security')
    def test_order_create_unauthed_no_proj_id(self):
        """Attempt to create an order without a token or project id

        Should return 401
        """

        model = order_models.OrderModel(self.create_default_data)
        resp, order_ref = self.behaviors.create_order(model, use_auth=False)
        self.assertEqual(401, resp.status_code)
github openstack / barbican / functionaltests / api / v1 / functional / test_containers.py View on Github external
    @testcase.attr('positive')
    def test_create_defaults_none_secret_name(self):
        """Covers creating a container with None as a secret name."""
        test_model = container_models.ContainerModel(**self.default_data)
        test_model.name = None

        resp, container_ref = self.behaviors.create_container(test_model)
        self.assertEqual(201, resp.status_code)
github openstack / barbican / functionaltests / api / v1 / functional / test_secretstores.py View on Github external
    @testcase.skipUnless(base.conf_multiple_backends_enabled, 'executed only '
                         'when multiple backends support is enabled in '
                         'barbican server side')
    @utils.parameterized_dataset(test_user_data_when_enabled)
    def test_get_all_secret_stores_multiple_enabled(self, user,
                                                    expected_return):

        resp, json_data = self.ss_behaviors.get_all_secret_stores(
            user_name=user)

        self.assertEqual(expected_return, resp.status_code)
        if expected_return == 200:
            self.assertIsNotNone(json_data.get('secret_stores'))
            stores = json_data['secret_stores']
            for secret_store in stores:
                self._validate_secret_store_fields(secret_store)
github openstack / barbican / functionaltests / api / v1 / functional / test_rsa.py View on Github external
    @testcase.attr('positive')
    def test_rsa_check_input_keys(self):
        """Verify the input keys for test cases"""

        # prove pyOpenSSL can parse the original private key
        pem = keys.get_private_key_pem()
        crypto.load_privatekey(crypto.FILETYPE_PEM, pem)

        # prove cryptography can parse the original public key
        serialization.load_pem_public_key(
            keys.get_public_key_pem(),
            backend=default_backend()
        )

        # prove pyOpenSSL can parse the original encrypted private key
        pem = keys.get_encrypted_private_key_pem()
        passphrase = keys.get_passphrase_txt()
github openstack / barbican / barbican / cmd / functionaltests / test_db_manage.py View on Github external
    @testcase.attr('positive')
    def test_expired_secrets_are_not_removed_from_db(self):
        """Test expired secrests are left in soft deleted state.

        Currently this clean will set the threshold at the start
        of the test. Expired secrets will be deleted and the
        deleted at date will now be later then the threshold
        date.
        """

        current_time = utils.create_timestamp_w_tz_and_offset(seconds=10)
        project_a_secrets = self._create_secret_list(user=admin_a,
                                                     expiration=current_time)
        project_b_secrets = self._create_secret_list(user=admin_b,
                                                     expiration=current_time)

        time.sleep(10)
github openstack / python-barbicanclient / functionaltests / client / v1 / smoke / test_secrets.py View on Github external
    @testcase.attr('positive')
    def test_secret_delete_defaults(self):
        """Covers deleting a secret."""
        secret = self.barbicanclient.secrets.create(
            **secret_create_defaults_data)

        secret_ref = secret.store()

        del_response = self.barbicanclient.secrets.delete(secret_ref)
        self.assertIsNone(del_response)
github openstack / barbican / functionaltests / api / v1 / functional / test_secretmeta.py View on Github external
    @testcase.attr('positive')
    def test_secret_metadata_create(self):
        test_model = secret_models.SecretModel(
            **self.default_secret_create_all_none_data)

        resp, secret_ref = self.secret_behaviors.create_secret(test_model)
        self.assertEqual(201, resp.status_code)

        meta_resp, metadata_ref = self.behaviors.create_or_update_metadata(
            secret_ref, self.valid_metadata)

        self.assertEqual(201, meta_resp.status_code)
        self.assertEqual(secret_ref + '/metadata', metadata_ref)