From 8c9024337c67f2dbf1a851f12209cb6bdf6f1e7c Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Robles Date: Tue, 3 Mar 2015 14:30:41 +0200 Subject: [PATCH] Do not filter empty strings Empty strings shouldn't be filtered from requests, as we have explicitly set some attributes to be optional and actually differentiate between null and empty attributes in the server side. So now, only attributes containing None are filtered and empty strings are actually passed to the server. Change-Id: Ia048d7de6bcbc12317930eeccc009b6b0db10e13 Closes-bug: #1420445 --- barbicanclient/base.py | 4 ++-- barbicanclient/containers.py | 2 +- barbicanclient/orders.py | 2 +- barbicanclient/secrets.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/barbicanclient/base.py b/barbicanclient/base.py index e8de75e6..c3350937 100644 --- a/barbicanclient/base.py +++ b/barbicanclient/base.py @@ -20,8 +20,8 @@ import uuid import six -def filter_empty_keys(dictionary): - return dict(((k, v) for k, v in dictionary.items() if v)) +def filter_null_keys(dictionary): + return dict(((k, v) for k, v in dictionary.items() if v is not None)) def validate_ref(ref, entity): diff --git a/barbicanclient/containers.py b/barbicanclient/containers.py index 6fc0b97a..686ad457 100644 --- a/barbicanclient/containers.py +++ b/barbicanclient/containers.py @@ -182,7 +182,7 @@ class Container(ContainerFormatter): """Store Container in Barbican""" secret_refs = self._get_secrets_and_store_them_if_necessary() - container_dict = base.filter_empty_keys({ + container_dict = base.filter_null_keys({ 'name': self.name, 'type': self._type, 'secret_refs': secret_refs diff --git a/barbicanclient/orders.py b/barbicanclient/orders.py index b5d01c58..49c6de45 100644 --- a/barbicanclient/orders.py +++ b/barbicanclient/orders.py @@ -108,7 +108,7 @@ class Order(object): self._order_ref = order_ref - self._meta = base.filter_empty_keys(meta) + self._meta = base.filter_null_keys(meta) self._error_status_code = error_status_code self._error_reason = error_reason diff --git a/barbicanclient/secrets.py b/barbicanclient/secrets.py index f6f9c58b..7d87376c 100644 --- a/barbicanclient/secrets.py +++ b/barbicanclient/secrets.py @@ -232,7 +232,7 @@ class Secret(SecretFormatter): Stores the Secret in Barbican. New Secret objects are not persisted in Barbican until this method is called. """ - secret_dict = base.filter_empty_keys({ + secret_dict = base.filter_null_keys({ 'name': self.name, 'payload': self.payload, 'payload_content_type': self.payload_content_type,