summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-03-24 08:00:48 +0000
committerGerrit Code Review <review@openstack.org>2015-03-24 08:00:48 +0000
commite86b11bbe1146533f189f2b56a1e0638b92684bb (patch)
tree02b017f0d2dca1cd181ac031caa0409d734056b7
parent91cf1cef2e81f343327ad0af9318ffa7232c4f5b (diff)
parent4e651d310392a33366da19d2f5a08112a1947420 (diff)
downloadpython-barbicanclient-e86b11bbe1146533f189f2b56a1e0638b92684bb.tar.gz
Merge "Second set of negative secrets tests."
-rw-r--r--functionaltests/client/v1/functional/test_secrets.py177
1 files changed, 177 insertions, 0 deletions
diff --git a/functionaltests/client/v1/functional/test_secrets.py b/functionaltests/client/v1/functional/test_secrets.py
index 55c54c5..b144132 100644
--- a/functionaltests/client/v1/functional/test_secrets.py
+++ b/functionaltests/client/v1/functional/test_secrets.py
@@ -14,6 +14,7 @@
# limitations under the License.
import base64
+import sys
from functionaltests.client import base
from functionaltests.client.v1.behaviors import secret_behaviors
@@ -252,6 +253,24 @@ class SecretsTestCase(base.TestCase):
self.assertEqual(get_resp.name, test_model.name)
@utils.parameterized_dataset({
+ 'int': [400]
+ })
+ @testcase.attr('negative')
+ def test_secret_create_defaults_invalid_name(self, name):
+ """Create secrets with various invalid names.
+
+ Should return 400.
+ """
+ test_model = self.behaviors.create_secret(
+ secret_create_defaults_data)
+ test_model.name = name
+
+ e = self.assertRaises(Exception, self.behaviors.store_secret,
+ test_model)
+
+ self.assertEqual(e.http_status, 400)
+
+ @utils.parameterized_dataset({
'aes': ['aes']
})
@testcase.attr('positive')
@@ -268,6 +287,24 @@ class SecretsTestCase(base.TestCase):
self.assertEqual(get_resp.algorithm, test_model.algorithm)
@utils.parameterized_dataset({
+ 'int': [400]
+ })
+ @testcase.attr('negative')
+ def test_secret_create_defaults_invalid_algorithms(self, algorithm):
+ """Creates secrets with various invalid algorithms."""
+
+ test_model = self.behaviors.create_secret(
+ secret_create_defaults_data)
+ test_model.algorithm = algorithm
+
+ # We are currently testing for exception with http_code
+ # launchpad bug 1431514 will address the change to this functionality
+ e = self.assertRaises(Exception, self.behaviors.store_secret,
+ test_model)
+
+ self.assertEqual(e.http_status, 400)
+
+ @utils.parameterized_dataset({
'512': [512],
'sixteen': [16],
'fifteen': [15],
@@ -290,6 +327,26 @@ class SecretsTestCase(base.TestCase):
self.assertEqual(get_resp.bit_length, test_model.bit_length)
@utils.parameterized_dataset({
+ 'str_type': ['not-an-int'],
+ 'empty': [''],
+ 'blank': [' '],
+ 'negative_maxint': [-sys.maxint],
+ 'negative_one': [-1],
+ 'zero': [0]
+ })
+ @testcase.attr('negative')
+ def test_secret_create_defaults_invalid_bit_length(self, bit_length):
+ """Covers cases of creating secrets with invalid bit lengths."""
+ test_model = self.behaviors.create_secret(
+ secret_create_defaults_data)
+ test_model.bit_length = bit_length
+
+ e = self.assertRaises(Exception, self.behaviors.store_secret,
+ test_model)
+
+ self.assertEqual(e.http_status, 400)
+
+ @utils.parameterized_dataset({
'cbc': ['cbc']
})
@testcase.attr('positive')
@@ -306,6 +363,23 @@ class SecretsTestCase(base.TestCase):
self.assertEqual(get_resp.mode, test_model.mode)
@utils.parameterized_dataset({
+ 'zero': [0],
+ 'oversized_string': [base.TestCase.oversized_field],
+ 'int': [400]
+ })
+ @testcase.attr('negative')
+ def test_secret_create_defaults_invalid_mode(self, mode):
+ """Covers cases of creating secrets with invalid modes."""
+ test_model = self.behaviors.create_secret(
+ secret_create_defaults_data)
+ test_model.mode = mode
+
+ e = self.assertRaises(Exception, self.behaviors.store_secret,
+ test_model)
+
+ self.assertEqual(e.http_status, 400)
+
+ @utils.parameterized_dataset({
'text_content_type_none_encoding': {
'payload_content_type': 'text/plain',
'payload_content_encoding': None},
@@ -347,6 +421,91 @@ class SecretsTestCase(base.TestCase):
self.assertEqual(test_model.payload, str(get_resp.payload))
@utils.parameterized_dataset({
+ 'large_string_content_type_and_encoding': {
+ 'payload_content_type': base.TestCase.oversized_field,
+ 'payload_content_encoding': base.TestCase.oversized_field},
+
+ 'int_content_type_and_encoding': {
+ 'payload_content_type': 123,
+ 'payload_content_encoding': 123},
+
+ 'text_content_type_none_content_encoding': {
+ 'payload_content_type': 'text/plain',
+ 'payload_content_encoding': ''},
+
+ 'text_no_subtype_content_type_none_content_encoding': {
+ 'payload_content_type': 'text',
+ 'payload_content_encoding': None},
+
+ 'text_slash_no_subtype_content_type_none_content_encoding': {
+ 'payload_content_type': 'text/',
+ 'payload_content_encoding': None},
+
+ 'text_content_type_empty_content_encoding': {
+ 'payload_content_type': 'text/plain',
+ 'payload_content_encoding': ' '},
+
+ 'text_content_type_spaces_content_encoding': {
+ 'payload_content_type': 'text/plain',
+ 'payload_content_encoding': ' '},
+
+ 'text_content_type_base64_content_encoding': {
+ 'payload_content_type': 'text/plain',
+ 'payload_content_encoding': 'base64'},
+
+ 'text_and_utf88_content_type_none_content_encoding': {
+ 'payload_content_type': 'text/plain; charset=utf-88',
+ 'payload_content_encoding': None},
+
+ 'invalid_content_type_base64_content_encoding': {
+ 'payload_content_type': 'invalid',
+ 'payload_content_encoding': 'base64'},
+
+ 'invalid_content_type_none_content_encoding': {
+ 'payload_content_type': 'invalid',
+ 'payload_content_encoding': None},
+
+ 'octet_content_type_invalid_content_encoding': {
+ 'payload_content_type': 'application/octet-stream',
+ 'payload_content_encoding': 'invalid'},
+
+ 'text_content_type_invalid_content_encoding': {
+ 'payload_content_type': 'text/plain',
+ 'payload_content_encoding': 'invalid'},
+
+ #Launchpad Bug (1434652)
+ # 'none_content_type_invalid_content_encoding': {
+ # 'payload_content_type': None,
+ # 'payload_content_encoding': 'invalid'},
+ #
+ # 'empty_content_type_and_encoding': {
+ # 'payload_content_type': '',
+ # 'payload_content_encoding': ''},
+ #
+ # 'none_content_type_and_encoding': {
+ # 'payload_content_type': None,
+ # 'payload_content_encoding': None},
+ #
+ # 'none_content_type_base64_content_encoding': {
+ # 'payload_content_type': None,
+ # 'payload_content_encoding': 'base64'}
+ })
+ @testcase.attr('negative')
+ def test_secret_create_defaults_invalid_types_and_encoding(self, **kwargs):
+ """Creating secrets with invalid payload types and encodings."""
+ test_model = self.behaviors.create_secret(
+ secret_create_defaults_data)
+ test_model.payload_content_encoding = kwargs[
+ 'payload_content_encoding']
+ test_model.payload_content_type = kwargs[
+ 'payload_content_type']
+
+ e = self.assertRaises(Exception, self.behaviors.store_secret,
+ test_model)
+
+ self.assertEqual(e.http_status, 400)
+
+ @utils.parameterized_dataset({
'max_payload_string': [base.TestCase.max_sized_payload]
})
@testcase.attr('positive')
@@ -437,6 +596,24 @@ class SecretsTestCase(base.TestCase):
self.assertEqual(get_resp.name, test_model.name)
@utils.parameterized_dataset({
+ 'malformed_timezone': {
+ 'timezone': '-5:00',
+ 'days': 0}
+ })
+ @testcase.attr('negative')
+ def test_secret_create_defaults_invalid_expiration(self, **kwargs):
+ """Create secrets with various invalid expiration data."""
+ timestamp = utils.create_timestamp_w_tz_and_offset(**kwargs)
+ test_model = self.behaviors.create_secret(
+ secret_create_defaults_data)
+ test_model.expiration = timestamp
+
+ e = self.assertRaises(Exception, self.behaviors.store_secret,
+ test_model)
+
+ self.assertEqual(e.http_status, 400)
+
+ @utils.parameterized_dataset({
'alphanumeric': ['1f34ds'],
'punctuation': ['~!@#$%^&*()_+`-={}[]|:;<>,.?'],
'uuid': ['54262d9d-4bc7-4821-8df0-dc2ca8e112bb'],