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

[Security Solution][Explore] Fixes failing test in MKI environments #186116

Merged
merged 8 commits into from
Jun 26, 2024

Conversation

MadameSheema
Copy link
Member

@MadameSheema MadameSheema commented Jun 12, 2024

Fix: #179231

##Summary

When we changed the default role used in Cypress from admin to platform_engineer, the x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/creation.cy.ts test started to fail in MKI environments.

The test was failing in both assertions for MKI environments:

cy.get(CASE_DETAILS_USERNAMES).eq(REPORTER).should('contain', username);
cy.get(CASE_DETAILS_USERNAMES).eq(PARTICIPANTS).should('contain', username);

This was happening because we were hardcoding the username and this is a thing we should not be doing anymore since we are making the test prone to failures.

In this PR we are fixing that behavior by using a method that retrieves the correct value.

@MadameSheema
Copy link
Member Author

/ci

@MadameSheema
Copy link
Member Author

/ci

@MadameSheema MadameSheema changed the title fixes MKI tests [Security Solution][Explore] Fixes failing test in MKI environments Jun 13, 2024
@MadameSheema MadameSheema self-assigned this Jun 20, 2024
@MadameSheema MadameSheema added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Explore v8.15.0 labels Jun 20, 2024
@MadameSheema
Copy link
Member Author

/ci

@MadameSheema MadameSheema marked this pull request as ready for review June 20, 2024 14:15
@MadameSheema MadameSheema requested review from a team as code owners June 20, 2024 14:15
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-explore (Team:Threat Hunting:Explore)

@@ -42,5 +43,17 @@ export const samlAuthentication = async (
);
return sessionManager.getSessionCookieForRole(role);
},
getFullname: async (role: string | SecurityRoleName = 'platform_engineer'): Promise<string> => {
Copy link
Contributor

@semd semd Jun 20, 2024

Choose a reason for hiding this comment

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

Do we have the default serverless role defined as a constant somewhere? Otherwise, we are also hardcoding the platform_engineer here

Copy link
Member Author

Choose a reason for hiding this comment

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

No, but we can do it.

@MadameSheema
Copy link
Member Author

Seems that the changes introduced in the following PR #186279 is affecting this one so I need to touch the code to make it work again.

@MadameSheema MadameSheema enabled auto-merge (squash) June 20, 2024 18:01
@MadameSheema
Copy link
Member Author

Seems that the changes introduced in the following PR #186279 is affecting this one so I need to touch the code to make it work again.

Changes done and seems to be working fine :)

@MadameSheema MadameSheema requested a review from a team as a code owner June 20, 2024 19:45
Copy link
Contributor

@nikitaindik nikitaindik left a comment

Choose a reason for hiding this comment

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

Thanks you @MadameSheema! I have reviewed and left a couple questions, but overall PR LGTM!

const isServerless = Cypress.env(IS_SERVERLESS);
const username = isServerless ? 'platform_engineer' : Cypress.env(ELASTICSEARCH_USERNAME);
const getUsername = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like something that is going to be reused in the future. Should we convert this into a Cypress command, like cy.getUsername()?

Copy link
Member Author

Choose a reason for hiding this comment

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

I put it there since I saw that only this test was using that functionality.

const username = isServerless ? 'platform_engineer' : Cypress.env(ELASTICSEARCH_USERNAME);
const getUsername = () => {
if (isServerless) {
return cy.task('getFullname');
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not familiar with this part, but curious why do we get the full name and not the username. Is it not available in Serverless?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was using code that was already available so I don't know which is the correct answer for that.

Copy link
Contributor

@semd semd left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@charlie-pichette charlie-pichette left a comment

Choose a reason for hiding this comment

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

👍🏼

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @MadameSheema

@MadameSheema MadameSheema merged commit 8ada1ac into elastic:main Jun 26, 2024
41 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 26, 2024
@MadameSheema MadameSheema deleted the cypress/fixes-cases-mki branch June 28, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Explore v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution][Explore][Cypress] Improve the username in cases tests
7 participants