Skip to content

Commit

Permalink
[Security Solution] Fixes value_lists_items tests on MKI (#182950)
Browse files Browse the repository at this point in the history
## Summary

On MKI environments, the `can CRUD value list items` inside
`value_list_items` spec file is failing with the following error:

```
Expected to find content: 'Updated by: system_indices_superuse' within the element: <div.euiFlexGroup.css-1drqwgc-euiFlexGroup-responsive-l-flexStart-stretch-row> but never did.
```

<img width="2555" alt="Screenshot 2024-05-08 at 18 29 50"
src="https://github.com/elastic/kibana/assets/17427073/66825a48-254c-46d7-ac24-3816a24e4827">

This is because as part of the test we are asserting the name of the
user that interacted with the value list. The username value is
hardcoded as `system_indices_superuser`, that user is value on the the
ESS Elasticsearch and stateless elasticsearch but does not exist on MKI
environments.

In this test we are fixing that, by checking first if we are triggering
the test for an MKI environment, and if so, set the username
appropriately.
  • Loading branch information
MadameSheema committed May 8, 2024
1 parent 50b04d5 commit 4ded78d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
VALUE_LIST_ITEMS_MODAL_TITLE,
} from '../../../../screens/lists';
import { RULES_MANAGEMENT_URL } from '../../../../urls/rules_management';
import { getDefaultUsername } from '../../../../tasks/common/users';

describe(
'Value list items',
Expand Down Expand Up @@ -72,7 +73,7 @@ describe(
// check modal title and info
cy.get(VALUE_LIST_ITEMS_MODAL_TITLE).should('have.text', KNOWN_VALUE_LIST_FILES.TEXT);
cy.get(VALUE_LIST_ITEMS_MODAL_INFO).contains('Type: keyword');
cy.get(VALUE_LIST_ITEMS_MODAL_INFO).contains('Updated by: system_indices_superuse');
cy.get(VALUE_LIST_ITEMS_MODAL_INFO).contains(`Updated by: ${getDefaultUsername()}`);
checkTotalItems(totalItems);

// search working
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { CLOUD_SERVERLESS } from '../../env_var_names_constants';

type DefaultUsername = 'testing-internal' | 'system_indices_superuser';

export const getDefaultUsername = (): DefaultUsername => {
const isMKIserverless: boolean = Cypress.env(CLOUD_SERVERLESS);
return isMKIserverless ? 'testing-internal' : 'system_indices_superuser';
};

0 comments on commit 4ded78d

Please sign in to comment.