summaryrefslogtreecommitdiff
path: root/functionaltests/cli/v1/behaviors/secret_behaviors.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 /functionaltests/cli/v1/behaviors/secret_behaviors.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 'functionaltests/cli/v1/behaviors/secret_behaviors.py')
-rw-r--r--functionaltests/cli/v1/behaviors/secret_behaviors.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/functionaltests/cli/v1/behaviors/secret_behaviors.py b/functionaltests/cli/v1/behaviors/secret_behaviors.py
index 9522871..733da3a 100644
--- a/functionaltests/cli/v1/behaviors/secret_behaviors.py
+++ b/functionaltests/cli/v1/behaviors/secret_behaviors.py
@@ -15,7 +15,7 @@
import logging
-import base_behaviors
+from functionaltests.cli.v1.behaviors import base_behaviors
class SecretBehaviors(base_behaviors.BaseBehaviors):
@@ -54,7 +54,7 @@ class SecretBehaviors(base_behaviors.BaseBehaviors):
self.secret_hrefs_to_delete.remove(secret_href)
- def store_secret(self, payload="Payload for testing", store_argv=[]):
+ def store_secret(self, payload=b"Payload for testing", store_argv=[]):
"""Store (aka create) a secret
The store_argv parameter allows additional command line parameters for
@@ -68,6 +68,11 @@ class SecretBehaviors(base_behaviors.BaseBehaviors):
"""
argv = ['secret', 'store']
self.add_auth_and_endpoint(argv)
+
+ if payload is not None and not isinstance(payload, str):
+ # Payload shouldn't be bytes but string on Python3
+ payload = payload.decode('utf-8')
+
argv.extend(['--payload', payload])
argv.extend(store_argv)
@@ -197,9 +202,9 @@ class SecretBehaviors(base_behaviors.BaseBehaviors):
:param filename: name of file to write
:return contents of the file
"""
- with open(filename, "r") as myfile:
+ with open(filename, "rb") as myfile:
data = myfile.read()
- return data
+ return data.decode('utf-8')
def write_secret_test_file(self, filename='/tmp/storesecret',
payload="Payload for testing"):
@@ -210,6 +215,6 @@ class SecretBehaviors(base_behaviors.BaseBehaviors):
:return
"""
myfile = open(filename, "wb")
- myfile.write(payload)
+ myfile.write(payload.encode('utf-8'))
myfile.close()
return