Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@testcase.attr('positive')
def test_paging_next_option_start_in_middle(self):
"""Covers getting a list of resources and using the next reference."""
number_of_resources = 150
test_model = self.create_model()
filter = self._set_filter_field(test_model)
self.create_resources(count=number_of_resources, model=test_model)
# First set of resources
limit = number_of_resources // 10
offset = number_of_resources // 2
resp, resources, next_ref, prev_ref = self.get_resources(
limit=limit, offset=offset, filter=filter)
self.assertEqual(200, resp.status_code)
@testcase.attr('positive')
def test_paging_with_default_limit_and_large_offsets(self):
"""Covers resource paging limit and offset attributes."""
test_model = self.create_model()
number_of_resources = 25
# create a number of resources
filter = self._set_filter_field(test_model)
self.create_resources(count=number_of_resources, model=test_model)
large_offset = 265613988875874769338781322035779626829233452653394495
limit = 10
# pass in non-integer values for limit and offset
resp, resources, next_ref, prev_ref = self.get_resources(
limit=limit,
@testcase.attr('negative')
def test_consumer_create_fail_no_url(self):
"""Attempt to create invalid consumer (Missing URL)
Should return 400
"""
data = {
"name": "consumername"
}
model = consumer_model.ConsumerModel(**data)
resp, consumer_dat = self.consumer_behaviors.create_consumer(
model, self.generic_container_ref, use_auth=True
)
self.assertEqual(400, resp.status_code)
@testcase.attr('negative')
def test_create_rsa_invalid_key_names(self):
"""Covers creating an RSA container with incorrect names."""
incorrect_names_rsa_container = {
"name": "bad_container",
"secret1": self.secret_ref_1,
"secret2": self.secret_ref_2,
"secret3": self.secret_ref_3
}
e = self.assertRaises(TypeError,
self.barbicanclient.containers.create_rsa,
**incorrect_names_rsa_container)
self.assertIn('got an unexpected keyword argument', e.message)
@testcase.attr('positive')
def test_paging_with_non_integer_limits_and_offsets(self):
"""Covers resource paging limit and offset attributes."""
test_model = self.create_model()
number_of_resources = 25
# create a number of resources
filter = self._set_filter_field(test_model)
self.create_resources(count=number_of_resources, model=test_model)
# pass in non-integer values for limit and offset
resp, resources, next_ref, prev_ref = self.get_resources(
limit='not-an-int-limit',
offset='not-an-int-offset', filter=filter)
self.assertEqual(200, resp.status_code)
@testtools.testcase.attr('negative')
def test_create_stored_key_order_with_unauthorized_container_ref(self):
# TODO(alee) - Not sure how to do this
pass
@testcase.attr('negative', 'security')
def test_order_delete_unauthed_no_proj_id(self):
"""Attempt to delete an order without a token or project id
Should return 401
"""
resp = self.behaviors.delete_order(
self.dummy_order_ref, expected_fail=True, use_auth=False
)
self.assertEqual(401, resp.status_code)
@testcase.attr('positive')
def test_secret_list_with_sort(self, secret_1_dict, secret_2_dict, sort):
secret_1 = self.barbicanclient.secrets.create(**secret_1_dict)
secret_1_ref = self.cleanup.add_entity(secret_1)
self.assertIsNotNone(secret_1_ref)
secret_2 = self.barbicanclient.secrets.create(**secret_2_dict)
secret_2_ref = self.cleanup.add_entity(secret_2)
self.assertIsNotNone(secret_2_ref)
query_dict = {'sort': sort + ":asc"}
secret_list = self.barbicanclient.secrets.list(**query_dict)
self.assertEqual(2, len(secret_list))
self.assertEqual(secret_1_ref, secret_list[0].secret_ref)
query_dict = {'sort': sort + ":desc"}
secret_list = self.barbicanclient.secrets.list(**query_dict)
@testcase.attr('positive')
def test_rsa_order_container_with_passphrase(self):
"""Order an rsa container with asymmetric keys and a passphrase."""
# order an rsa container
test_model = order_models.OrderModel(
**get_order_create_rsa_container_with_passphrase())
create_resp, order_ref = self.order_behaviors.create_order(test_model)
self.assertEqual(create_resp.status_code, 202)
# get the order
order_resp = self.order_behaviors.get_order(order_ref)
self.assertEqual(order_resp.status_code, 200)
# get the container
container_resp = self.container_behaviors.get_container(
order_resp.model.container_ref)
@testcase.attr('negative')
def test_secret_create_with_invalid_content_type(self):
"""Create secret with an invalid content type in HTTP header.
Should return a 415.
"""
test_model = secret_models.SecretModel(
**self.default_secret_create_data)
headers = {"Content-Type": "crypto/boom"}
resp, secret_ref = self.behaviors.create_secret(test_model, headers)
self.assertEqual(415, resp.status_code)