summaryrefslogtreecommitdiff
path: root/barbicanclient/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-09-01 20:05:55 +0000
committerGerrit Code Review <review@openstack.org>2015-09-01 20:05:55 +0000
commit97cc46ac2804e7679237e41a88b1183d98dac619 (patch)
treedb06fb2f61f1fc88df049ddba01db6a756c86370 /barbicanclient/tests
parent3f9585c573fcfb8bdb8fbd85422db52465d6c80b (diff)
parent17ed50a9f960bbbabfae194a27f5ad076958248c (diff)
downloadpython-barbicanclient-97cc46ac2804e7679237e41a88b1183d98dac619.tar.gz
Merge "Add Unit Tests for Store and Update Payload when Payload is zero"
Diffstat (limited to 'barbicanclient/tests')
-rw-r--r--barbicanclient/tests/test_secrets.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/barbicanclient/tests/test_secrets.py b/barbicanclient/tests/test_secrets.py
index 91beb8b..4df946e 100644
--- a/barbicanclient/tests/test_secrets.py
+++ b/barbicanclient/tests/test_secrets.py
@@ -18,7 +18,7 @@ import json
from oslo_utils import timeutils
from barbicanclient.tests import test_client
-from barbicanclient import secrets, base
+from barbicanclient import secrets, base, exceptions
class SecretData(object):
@@ -417,6 +417,30 @@ class WhenTestingSecrets(test_client.BaseEntityResource):
self.assertRaises(ValueError, self.manager.get,
**{'secret_ref': '12345'})
+ def test_should_fail_update_zero(self):
+ data = {'secret_ref': self.entity_href}
+ self.responses.post(self.entity_base + '/', json=data)
+
+ secret = self.manager.create()
+ secret.payload = None
+ secret.store()
+
+ self.responses.put(self.entity_href, status_code=204)
+ secret.payload = 0
+
+ # Verify that an error is thrown
+ self.assertRaises(exceptions.PayloadException, secret.update)
+
+ def test_should_fail_store_zero(self):
+ data = {'secret_ref': self.entity_href}
+ self.responses.post(self.entity_base + '/', json=data)
+
+ secret = self.manager.create()
+ secret.name = self.secret.name
+ secret.payload = 0
+
+ self.assertRaises(exceptions.PayloadException, secret.store)
+
def test_should_fail_decrypt_no_content_types(self):
data = self.secret.get_dict(self.entity_href)
self.responses.get(self.entity_href, json=data)