Add headers parameter to allow tests to pass HTTP header values directly
Tests for secrets and orders resources can now pass HTTP header values (in a dict) directly from the test using this new headers parameter. Change-Id: I75c91cda89e3ffcec1916f7eb140a73f8f13584e
This commit is contained in:
@@ -82,7 +82,7 @@ class OrdersBehavior(object):
|
||||
|
||||
def create_order_overriding_cfg(self, name=None, payload_content_type=None,
|
||||
expiration=None, algorithm=None,
|
||||
bit_length=None, mode=None):
|
||||
bit_length=None, mode=None, headers=None):
|
||||
"""Creates order using provided parameters or default configurations.
|
||||
Allows for testing individual parameters on creation.
|
||||
"""
|
||||
@@ -93,13 +93,13 @@ class OrdersBehavior(object):
|
||||
algorithm=algorithm or self.config.algorithm,
|
||||
bit_length=bit_length or self.config.bit_length,
|
||||
mode=mode or self.config.mode,
|
||||
expiration=expiration)
|
||||
expiration=expiration, headers=headers)
|
||||
|
||||
return resp
|
||||
|
||||
def create_order(self, name=None, payload_content_type=None,
|
||||
algorithm=None, bit_length=None, mode=None,
|
||||
expiration=None):
|
||||
expiration=None, headers=None):
|
||||
try:
|
||||
resp = self.orders_client.create_order(
|
||||
name=name,
|
||||
@@ -107,7 +107,8 @@ class OrdersBehavior(object):
|
||||
algorithm=algorithm,
|
||||
bit_length=bit_length,
|
||||
mode=mode,
|
||||
expiration=expiration)
|
||||
expiration=expiration,
|
||||
headers=headers)
|
||||
except ConnectionError as e:
|
||||
# Gracefully handling when Falcon doesn't properly handle our req
|
||||
if type(e.message.reason) is BadStatusLine:
|
||||
|
||||
@@ -41,7 +41,7 @@ class OrdersClient(BarbicanRestClient):
|
||||
order_id=order_id)
|
||||
|
||||
def create_order(self, name, payload_content_type, algorithm,
|
||||
bit_length, mode, expiration):
|
||||
bit_length, mode, expiration, headers=None):
|
||||
"""
|
||||
POST http://.../v1/{tenant_id}/orders/{order_uuid}
|
||||
Creates an order to generate a secret
|
||||
@@ -56,7 +56,7 @@ class OrdersClient(BarbicanRestClient):
|
||||
req_obj = Order(secret=secret)
|
||||
|
||||
resp = self.request('POST', remote_url, request_entity=req_obj,
|
||||
response_entity_type=OrderRef)
|
||||
response_entity_type=OrderRef, headers=headers)
|
||||
return resp
|
||||
|
||||
def create_order_w_payload(self, name, payload_content_type, algorithm,
|
||||
|
||||
@@ -81,7 +81,8 @@ class SecretsBehaviors(object):
|
||||
def create_secret(self, name=None, expiration=None, algorithm=None,
|
||||
bit_length=None, mode=None, payload=None,
|
||||
payload_content_type=None,
|
||||
payload_content_encoding=None):
|
||||
payload_content_encoding=None,
|
||||
headers=None):
|
||||
resp = self.client.create_secret(
|
||||
name=name,
|
||||
expiration=expiration,
|
||||
@@ -90,7 +91,8 @@ class SecretsBehaviors(object):
|
||||
mode=mode,
|
||||
payload=payload,
|
||||
payload_content_type=payload_content_type,
|
||||
payload_content_encoding=payload_content_encoding)
|
||||
payload_content_encoding=payload_content_encoding,
|
||||
headers=headers)
|
||||
|
||||
behavior_response = CloudkeepResponse(resp=resp)
|
||||
secret_id = behavior_response.id
|
||||
|
||||
@@ -42,7 +42,7 @@ class SecretsClient(BarbicanRestClient):
|
||||
def create_secret(self, name=None, expiration=None, algorithm=None,
|
||||
bit_length=None, mode=None, payload=None,
|
||||
payload_content_type=None,
|
||||
payload_content_encoding=None):
|
||||
payload_content_encoding=None, headers=None):
|
||||
"""
|
||||
POST http://.../v1/{tenant_id}/secrets
|
||||
Allows a user to create a new secret
|
||||
@@ -55,7 +55,7 @@ class SecretsClient(BarbicanRestClient):
|
||||
payload=payload)
|
||||
|
||||
resp = self.request('POST', remote_url, request_entity=req_obj,
|
||||
response_entity_type=SecretRef)
|
||||
response_entity_type=SecretRef, headers=headers)
|
||||
|
||||
return resp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user