summaryrefslogtreecommitdiff
path: root/barbicanclient/v1/secrets.py
diff options
context:
space:
mode:
authorTakashi Kajinami <tkajinam@redhat.com>2020-04-20 17:48:17 +0900
committerDouglas Mendizábal <dmendiza@redhat.com>2020-06-08 15:40:22 -0500
commit6420da336083d936da9a4563149b08d785d70c84 (patch)
tree9cf7c2ce2cff5e7352d7b35a1dcee3bf675534e4 /barbicanclient/v1/secrets.py
parente5fdd10f04488d6f6e252a63c57bf2be92a06c8f (diff)
downloadpython-barbicanclient-6420da336083d936da9a4563149b08d785d70c84.tar.gz
Fix gate job failures and py3 compatibility
- Fix incorrect type handling of secret payload in py3 (it should be bytes instead of str by default) - Fix py3 compatibility of test codes - Update expiration date so that resources are created with valid expiration. Change-Id: I4935f601f87e9c49499da1034a320eee2e655b4d
Diffstat (limited to 'barbicanclient/v1/secrets.py')
-rw-r--r--barbicanclient/v1/secrets.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/barbicanclient/v1/secrets.py b/barbicanclient/v1/secrets.py
index a604160..f4bc7ad 100644
--- a/barbicanclient/v1/secrets.py
+++ b/barbicanclient/v1/secrets.py
@@ -292,14 +292,13 @@ class Secret(SecretFormatter):
'expiration': self.expiration
}
- if self.payload == '':
- raise exceptions.PayloadException("Invalid Payload: "
- "Cannot Be Empty String")
+ if self.payload is not None:
+ if not isinstance(self.payload, (six.text_type, six.binary_type)):
+ raise exceptions.PayloadException("Invalid Payload Type")
- if self.payload is not None and not isinstance(self.payload,
- (six.text_type,
- six.binary_type)):
- raise exceptions.PayloadException("Invalid Payload Type")
+ if not len(self.payload):
+ raise exceptions.PayloadException("Invalid Payload: "
+ "Cannot Be Empty String")
if self.payload_content_type or self.payload_content_encoding:
'''
@@ -308,7 +307,10 @@ class Secret(SecretFormatter):
for backwards compatibility and should be removed in a future
release.
'''
- secret_dict['payload'] = self.payload
+ if type(self.payload) is six.binary_type:
+ secret_dict['payload'] = self.payload.decode('utf-8')
+ else:
+ secret_dict['payload'] = self.payload
secret_dict['payload_content_type'] = self.payload_content_type
secret_dict['payload_content_encoding'] = (
self.payload_content_encoding