Unskip all multi-doc CRUD functional tests
Change-Id: Ibda6028ea26290c6a2eee5b8f183f9b2d11e616e
This commit is contained in:
parent
6817b39911
commit
5dfcc600ac
|
@ -54,13 +54,11 @@ class BucketsResource(api_base.BaseResource):
|
|||
|
||||
try:
|
||||
documents.extend(validation_policies)
|
||||
created_documents = db_api.documents_create(
|
||||
bucket_name, documents)
|
||||
created_documents = db_api.documents_create(bucket_name, documents)
|
||||
except db_exc.DBDuplicateEntry as e:
|
||||
raise falcon.HTTPConflict(description=e.format_message())
|
||||
except Exception as e:
|
||||
raise falcon.HTTPInternalServerError(
|
||||
description=e.format_message())
|
||||
raise falcon.HTTPInternalServerError(description=e)
|
||||
|
||||
if created_documents:
|
||||
resp.body = self.to_yaml_body(
|
||||
|
|
|
@ -139,6 +139,14 @@ def _documents_create(values_list, session=None):
|
|||
values['_metadata'] = values.pop('metadata')
|
||||
values['name'] = values['_metadata']['name']
|
||||
|
||||
# NOTE(fmontei): Database requires that the 'data' column be a dict, so
|
||||
# coerce the secret into a dictionary if it already isn't one.
|
||||
if values['schema'] in (types.CERTIFICATE_SCHEMA,
|
||||
types.CERTIFICATE_KEY_SCHEMA,
|
||||
types.PASSPHRASE_SCHEMA):
|
||||
if not isinstance(values['data'], dict):
|
||||
values['data'] = {'secret': values['data']}
|
||||
|
||||
try:
|
||||
existing_document = document_get(
|
||||
raw_dict=True, **{c: values[c] for c in filters})
|
||||
|
|
|
@ -29,7 +29,7 @@ schema = {
|
|||
'name': {'type': 'string'},
|
||||
'storagePolicy': {
|
||||
'type': 'string',
|
||||
'pattern': '^(encrypted)$'
|
||||
'enum': ['encrypted', 'cleartext']
|
||||
}
|
||||
},
|
||||
'additionalProperties': False,
|
||||
|
|
|
@ -29,7 +29,7 @@ schema = {
|
|||
'name': {'type': 'string'},
|
||||
'storagePolicy': {
|
||||
'type': 'string',
|
||||
'pattern': '^(cleartext)$'
|
||||
'enum': ['encrypted', 'cleartext']
|
||||
}
|
||||
},
|
||||
'additionalProperties': False,
|
||||
|
|
|
@ -29,7 +29,7 @@ schema = {
|
|||
'name': {'type': 'string'},
|
||||
'storagePolicy': {
|
||||
'type': 'string',
|
||||
'pattern': '^(encrypted)$'
|
||||
'enum': ['encrypted', 'cleartext']
|
||||
}
|
||||
},
|
||||
'additionalProperties': False,
|
||||
|
|
|
@ -24,78 +24,72 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
skip: Not implemented.
|
||||
|
||||
- name: create_a
|
||||
desc: Create documents in one bucket (a)
|
||||
PUT: /api/v1.0/bucket/a/documents
|
||||
status: 201
|
||||
status: 200
|
||||
data: <@resources/layering-needs-substitution-source.yaml
|
||||
skip: Not implemented.
|
||||
|
||||
- name: verify_first_bucket
|
||||
desc: Verify document count and revisions
|
||||
GET: /api/v1.0/revisions/$RESPONSE['$.documents[0].revision']/documents
|
||||
GET: /api/v1.0/revisions/$RESPONSE['$.[0].status.revision']/documents
|
||||
status: 200
|
||||
response_multidoc_jsonpaths:
|
||||
$.documents[*].metadata.name:
|
||||
$.[*].metadata.name:
|
||||
- layering-policy
|
||||
- abstract-1234
|
||||
- concrete-1234
|
||||
$.documents[*].status.revision:
|
||||
- "$RESPONSE['$.documents[0].revision']"
|
||||
- "$RESPONSE['$.documents[0].revision']"
|
||||
- "$RESPONSE['$.documents[0].revision']"
|
||||
$.documents[*].status.bucket:
|
||||
$.[*].status.revision:
|
||||
- "$RESPONSE['$.[0].status.revision']"
|
||||
- "$RESPONSE['$.[0].status.revision']"
|
||||
- "$RESPONSE['$.[0].status.revision']"
|
||||
$.[*].status.bucket:
|
||||
- a
|
||||
- a
|
||||
- a
|
||||
skip: Not implemented.
|
||||
|
||||
- name: create_b
|
||||
desc: Create documents in a second bucket (b)
|
||||
PUT: /api/v1.0/bucket/b/documents
|
||||
status: 201
|
||||
status: 200
|
||||
data: <@resources/passphrase.yaml
|
||||
skip: Not implemented.
|
||||
|
||||
- name: verify_second_bucket
|
||||
desc: Verify document count and revisions
|
||||
GET: /api/v1.0/revisions/$RESPONSE['$.documents[0].revision']/documents
|
||||
GET: /api/v1.0/revisions/$RESPONSE['$.[0].status.revision']/documents
|
||||
status: 200
|
||||
response_multidoc_jsonpaths:
|
||||
$.documents[*].metadata.name:
|
||||
$.[*].metadata.name:
|
||||
- layering-policy
|
||||
- abstract-1234
|
||||
- concrete-1234
|
||||
- my-passphrase
|
||||
$.documents[*].status.revision:
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.documents[0].revision']"
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.documents[0].revision']"
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.documents[0].revision']"
|
||||
- "$RESPONSE['$.documents[0].revision']"
|
||||
$.documents[*].status.bucket:
|
||||
$.[*].status.revision:
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.[0].status.revision']"
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.[0].status.revision']"
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.[0].status.revision']"
|
||||
- "$RESPONSE['$.[0].status.revision']"
|
||||
$.[*].status.bucket:
|
||||
- a
|
||||
- a
|
||||
- a
|
||||
- b
|
||||
skip: Not implemented.
|
||||
|
||||
- name: verify_first_revision_unchanged
|
||||
desc: Verify initial revision is unchanged
|
||||
GET: /api/v1.0/revisions/$HISTORY['create_a'].$RESPONSE['$.documents[0].revision']/documents
|
||||
GET: /api/v1.0/revisions/$HISTORY['create_a'].$RESPONSE['$.[0].status.revision']/documents
|
||||
status: 200
|
||||
response_multidoc_jsonpaths:
|
||||
$.documents[*].metadata.name:
|
||||
$.[*].metadata.name:
|
||||
- layering-policy
|
||||
- abstract-1234
|
||||
- concrete-1234
|
||||
$.documents[*].status.revision:
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.documents[0].revision']"
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.documents[0].revision']"
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.documents[0].revision']"
|
||||
$.documents[*].status.bucket:
|
||||
$.[*].status.revision:
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.[0].status.revision']"
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.[0].status.revision']"
|
||||
- "$HISTORY['create_a'].$RESPONSE['$.[0].status.revision']"
|
||||
$.[*].status.bucket:
|
||||
- a
|
||||
- a
|
||||
- a
|
||||
skip: Not implemented.
|
||||
|
|
|
@ -3,5 +3,6 @@ schema: deckhand/Passphrase/v1
|
|||
metadata:
|
||||
schema: metadata/Document/v1
|
||||
name: my-passphrase
|
||||
storagePolicy: cleartext
|
||||
data: not-a-real-password
|
||||
...
|
||||
|
|
|
@ -94,19 +94,6 @@ class TestDocumentValidationNegative(
|
|||
properties_to_remove = self.BASIC_ATTRS + ('metadata.storagePolicy',)
|
||||
self._test_missing_required_sections(properties_to_remove)
|
||||
|
||||
def test_passphrase_with_incorrect_storage_policy(self):
|
||||
self._read_data('sample_passphrase')
|
||||
expected_err = (
|
||||
"The provided deckhand/Passphrase/v1.0 YAML failed schema "
|
||||
"validation. Details: 'cleartext' does not match '^(encrypted)$'")
|
||||
wrong_data = self._corrupt_data('metadata.storagePolicy', 'cleartext',
|
||||
op='replace')
|
||||
|
||||
doc_validation = document_validation.DocumentValidation(wrong_data)
|
||||
e = self.assertRaises(errors.InvalidDocumentFormat,
|
||||
doc_validation.validate_all)
|
||||
self.assertIn(expected_err, str(e))
|
||||
|
||||
def test_validation_policy_missing_required_sections(self):
|
||||
self._read_data('sample_validation_policy')
|
||||
properties_to_remove = self.BASIC_ATTRS + (
|
||||
|
|
|
@ -13,10 +13,16 @@
|
|||
# limitations under the License.
|
||||
|
||||
DOCUMENT_SCHEMA_TYPES = (
|
||||
CERTIFICATE_SCHEMA,
|
||||
CERTIFICATE_KEY_SCHEMA,
|
||||
LAYERING_POLICY_SCHEMA,
|
||||
PASSPHRASE_SCHEMA,
|
||||
VALIDATION_POLICY_SCHEMA,
|
||||
) = (
|
||||
'deckhand/Certificate/v1',
|
||||
'deckhand/CertificateKey/v1',
|
||||
'deckhand/LayeringPolicy/v1',
|
||||
'deckhand/Passphrase/v1',
|
||||
'deckhand/ValidationPolicy/v1',
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue