Browse Source

Allow null values for secret names

This secret allows null values for names in secrets as discussed a
couple of cycles back.

Since the code for the mocked client in the functional tests actually
filters out null values, it is currently not possible to write a
functional test for this in this functional test code base. However, it
will be written as part of the python-barbicanclient functional test
suite.

Change-Id: I68330d1d1b13e1bbb6436ca4f6684a76af3babd3
Related-bug: #1425667
Related-bug: #1376469
tags/2.0.0.0b1
Juan Antonio Osorio Robles 4 years ago
parent
commit
c098455d2e
2 changed files with 6 additions and 1 deletions
  1. 2
    1
      barbican/common/validators.py
  2. 4
    0
      barbican/tests/common/test_validators.py

+ 2
- 1
barbican/common/validators.py View File

@@ -180,7 +180,7 @@ class NewSecretValidator(ValidatorBase):
180 180
         self.schema = {
181 181
             "type": "object",
182 182
             "properties": {
183
-                "name": {"type": "string", "maxLength": 255},
183
+                "name": {"type": ["string", "null"], "maxLength": 255},
184 184
                 "algorithm": {"type": "string", "maxLength": 255},
185 185
                 "mode": {"type": "string", "maxLength": 255},
186 186
                 "bit_length": {
@@ -242,6 +242,7 @@ class NewSecretValidator(ValidatorBase):
242 242
                                                        payload, schema_name)
243 243
             json_data['payload'] = payload
244 244
         elif 'payload_content_type' in json_data:
245
+            # parent_schema would be populated if it comes from an order.
245 246
             self._assert_validity(parent_schema is not None, schema_name,
246 247
                                   u._("payload must be provided when "
247 248
                                       "payload_content_type is specified"),

+ 4
- 0
barbican/tests/common/test_validators.py View File

@@ -146,6 +146,10 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
146 146
         self.secret_req['name'] = '    '
147 147
         self.validator.validate(self.secret_req)
148 148
 
149
+    def test_should_validate_null_name(self):
150
+        self.secret_req['name'] = None
151
+        self.validator.validate(self.secret_req)
152
+
149 153
     def test_should_validate_no_payload(self):
150 154
         del self.secret_req['payload']
151 155
         del self.secret_req['payload_content_type']

Loading…
Cancel
Save