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

Account for null metadata in update API key test #89195

Merged
merged 4 commits into from
Aug 9, 2022

Conversation

n1v0lg
Copy link
Contributor

@n1v0lg n1v0lg commented Aug 9, 2022

When the metadata field on the raw API key doc is null, the GET API
automatically translates it to an empty map. This PR fixes a failing
test by accounting for this difference in a test assertion.

Closes #89193

@n1v0lg n1v0lg changed the title Fix metadata assertion in update API key test Account for null metadata in update API key test Aug 9, 2022
"for api key doc " + actualRawApiKeyDoc,
// Internally, metadata may be stored as `null`. However, it is always exposed as an empty map through the API. We define
// `expectedMetadata` as the expected value according to the API, so we need to account for this discrepancy here
actualMetadata == null ? anEmptyMap() : actualMetadata,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm addressing the issue here, instead of going the other direction and accounting for null values on the GET API response. I think it is more intuitive to treat the API response as the expected result. We also run into an issue with null pointers if we try to pass a null value into expectAttributesForApiKey via Map.of(METADATA, null).

I would be up for only asserting on the API response, and removing expectMetadataForApiKey altogether.

@n1v0lg n1v0lg added >test Issues or PRs that are addressing/adding tests :Security/Security Security issues without another label labels Aug 9, 2022
@n1v0lg n1v0lg requested a review from ywangd August 9, 2022 10:12
@n1v0lg n1v0lg marked this pull request as ready for review August 9, 2022 10:25
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Aug 9, 2022
Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for picking this up.

@n1v0lg n1v0lg merged commit 9dd47d8 into elastic:main Aug 9, 2022
@n1v0lg n1v0lg deleted the fix/test-failure-89193 branch August 9, 2022 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Security/Security Security issues without another label Team:Security Meta label for security team >test Issues or PRs that are addressing/adding tests v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] ApiKeyIntegTests testUpdateApiKeysForSingleKey failing
3 participants