Add negative functional test for substitution
It is currently surprising for users when null is getting substituted into documents when there is no actual source data to grab. Silent "None" substitution sometimes results in surprising symptoms in complex configurations. Depends-On: If2b08f443cde765a1dbfaf7bac6b549591e59148 Change-Id: I253dc1d10f9493b9611fb6abd86810c6d57afbf6
This commit is contained in:
parent
6b9cd17e98
commit
7086973386
@ -119,6 +119,7 @@ class RenderedDocumentsResource(api_base.BaseResource):
|
||||
errors.InvalidDocumentReplacement,
|
||||
errors.IndeterminateDocumentParent,
|
||||
errors.MissingDocumentKey,
|
||||
errors.SubstitutionSourceDataNotFound,
|
||||
errors.UnsupportedActionMethod) as e:
|
||||
raise falcon.HTTPBadRequest(description=e.format_message())
|
||||
except (errors.LayeringPolicyNotFound,
|
||||
|
@ -365,9 +365,10 @@ class SecretsSubstitution(object):
|
||||
dest_path = sub['dest']['path']
|
||||
dest_pattern = sub['dest'].get('pattern', None)
|
||||
|
||||
LOG.debug('Substituting from schema=%s name=%s src_path=%s '
|
||||
'into dest_path=%s, dest_pattern=%s', src_schema,
|
||||
src_name, src_path, dest_path, dest_pattern)
|
||||
LOG.debug('Substituting from schema=%s layer=%s name=%s '
|
||||
'src_path=%s into dest_path=%s, dest_pattern=%s',
|
||||
src_schema, src_doc.layer, src_name, src_path,
|
||||
dest_path, dest_pattern)
|
||||
try:
|
||||
exc_message = ''
|
||||
substituted_data = utils.jsonpath_replace(
|
||||
|
@ -0,0 +1,37 @@
|
||||
---
|
||||
schema: deckhand/LayeringPolicy/v1
|
||||
metadata:
|
||||
schema: metadata/Control/v1
|
||||
name: layering-policy
|
||||
data:
|
||||
layerOrder:
|
||||
- one
|
||||
---
|
||||
schema: deckhand/Source/v1
|
||||
metadata:
|
||||
name: src
|
||||
schema: metadata/Document/v1
|
||||
layeringDefinition:
|
||||
layer: one
|
||||
storagePolicy: cleartext
|
||||
data:
|
||||
a: AAA
|
||||
b: BBB
|
||||
---
|
||||
schema: deckhand/Dest/v1
|
||||
metadata:
|
||||
name: dest
|
||||
schema: metadata/Document/v1
|
||||
layeringDefinition:
|
||||
layer: one
|
||||
substitutions:
|
||||
- dest:
|
||||
path: .out
|
||||
src:
|
||||
schema: deckhand/Source/v1
|
||||
name: src
|
||||
# NOTE(mark-burnett): This path does not exist in the source.
|
||||
path: .c
|
||||
data:
|
||||
d: DDD
|
||||
...
|
@ -0,0 +1,35 @@
|
||||
# Tests success path for missing substitution source data.
|
||||
#
|
||||
# 1. Purges existing data to ensure test isolation
|
||||
# 2. Adds documents with a bad substitution source path
|
||||
# 3. Verifies that a 400 Bad Request is raised
|
||||
|
||||
defaults:
|
||||
request_headers:
|
||||
content-type: application/x-yaml
|
||||
response_headers:
|
||||
content-type: application/x-yaml
|
||||
|
||||
tests:
|
||||
- name: purge
|
||||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: initialize_documents_with_missing_src_substitution_path
|
||||
desc: |
|
||||
Initialize the test documents where the destination document references
|
||||
a path via `src.path` that doesn't exist in the source document.
|
||||
PUT: /api/v1.0/buckets/mop/documents
|
||||
status: 200
|
||||
data: <@resources/substitution-results-in-none-bug.yaml
|
||||
|
||||
- name: verify_bad_request_raised
|
||||
desc: |
|
||||
Check that a 400 Bad Request is raised because the source data could not
|
||||
be found since the `src.path` doesn't exist in the source document.
|
||||
GET: /api/v1.0/revisions/$RESPONSE['$.[0].status.revision']/rendered-documents
|
||||
query_parameters:
|
||||
schema: deckhand/Dest/v1
|
||||
status: 400
|
Loading…
x
Reference in New Issue
Block a user