Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(integ-runner): (assertions on object keys) #33068

Open
1 of 2 tasks
graydenshand opened this issue Jan 22, 2025 · 2 comments
Open
1 of 2 tasks

(integ-runner): (assertions on object keys) #33068

graydenshand opened this issue Jan 22, 2025 · 2 comments
Labels
@aws-cdk/integ-runner effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@graydenshand
Copy link
Contributor

Describe the feature

Allow assertions about the keys contained in an API call response. ExpectedResults that contain generated data. Currently, only full matching is supported.

Use Case

One example - Writing a custom provider that generates a set of secret values and stores it in a secretsmanager secret as a JSON object. It's impossible to match the complete object since the secrets are generated by the custom provider. A partial match on the object (e.g. verifying a particular key exists) would be sufficient to verify the behavior of the provider.

Proposed Solution

In the base assertions module, this can be accomplished using Match.absent() and Match.any_value(). Adding comparable methods for integration test assertions seems like a reasonable implementation.

Beyond that, adding the ability to match an object value by regex would allow for greater specificity in one's assertions.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.174.0

Environment details (OS name and version, etc.)

MacOS 15.2

@graydenshand graydenshand added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jan 22, 2025
@pahud
Copy link
Contributor

pahud commented Jan 22, 2025

Sounds like a good idea. We welcome PRs and I'll bring this up to the team for inputs as well.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 22, 2025
@graydenshand
Copy link
Contributor Author

I was actually able to find a work around.

This docstring was helpful in discovering that objects passed to ExpectedResults.object_like() can themselves include Match objects.

So I can achieve the use case I highlighted using something like:

ExpectedResult.object_like({"SecretString": Match.string_like_regexp(".*")})

Not sure if it's still worth considering creating those top level API methods. It might be worth at least documenting this nested matching pattern with an example in the package overview.

I'm less inclined to make this contribution personally now that I've got a path forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/integ-runner effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants