Skip to content

Replace health with authenticate calls in tests #50073

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

Merged
merged 1 commit into from
Dec 13, 2019

Conversation

jkakavas
Copy link
Member

In integration tests for API Keys and Tokens, we would use calls
we did with the transport client to the cluster health endpoint
after adding Authorization header with filterWithHeader(), in
order to verify that the API Key or Token is valid.
The response would always be successful regardless of the
validity of the Token or API Key since the internal request would
have the _system user as a fallback user and the _system is
allowed to call the health API. When failing to validate the
token or key, we would fallback to the _system user,
see AuthenticationService#handleNullToken

This commit changes our behavior to use the RestClient and call the
authenticate API to verify the validity of tokens and API keys.

In integration tests for API Keys and Tokens, we would use calls
we did with the transport client to the cluster health endpoint
after adding the API key or Token with `filterWithHeader()` in
order to verify that the API Key or Token is valid.
The response would always be successful regardless of the
validity of the Token or API Key since the internal request would
have the `_system` user as a fallback user and the `_system` is
allowed to call the health API. When failing to validate the
token or key, we would fallback to the `_system` user,
see AuthenticationService#handleNullToken

This commit changes our behavior to use the RestClient and call the
authenticate API to verify the validity of tokens and API keys.
@jkakavas jkakavas added >test Issues or PRs that are addressing/adding tests :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) labels Dec 11, 2019
@elasticmachine
Copy link
Collaborator

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

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

LGTM, Good catch!

@jkakavas jkakavas merged commit 59ca3a7 into elastic:master Dec 13, 2019
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
In integration tests for API Keys and Tokens, we would use calls
we did with the transport client to the cluster health endpoint
after adding the API key or Token with `filterWithHeader()` in
order to verify that the API Key or Token is valid.
The response would always be successful regardless of the
validity of the Token or API Key since the internal request would
have the `_system` user as a fallback user and the `_system` is
allowed to call the health API. When failing to validate the
token or key, we would fallback to the `_system` user,
see AuthenticationService#handleNullToken

This commit changes our behavior to use the RestClient and call the
authenticate API to verify the validity of tokens and API keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) >test Issues or PRs that are addressing/adding tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants