Skip to content

Commit

Permalink
[App Search] Role mappings migration part 2 (elastic#94461)
Browse files Browse the repository at this point in the history
* Add engines mock and fix mock role mapping

The original asRoleMapping was merely for a smoke test in the shared component. Refactored to work better in App Search component

* Add RoleMappingsLogic

* Fix test description

Co-authored-by: Jason Stoltzfus <[email protected]>

* Fix test description

Co-authored-by: Jason Stoltzfus <[email protected]>

* Add flash messages when creating, updating or deleting

* Add path and resetState calls

Refactoring the tests showed me that some parts of the state weren’t being reset.

* Refactor handleAuthProviderChange logic

I some how got the test coverage at 100% with my wrong way of doing tests before (scary). When I fixed it I noticed that noting I could do would trigger the fallback of just returning the `[ANY_AUTH_PROVIDER]` array. After talking with Constance, we could not come up with a way to trigger it either, given the conditions.

She had suggested removing the first return statement but that caused an empty array being returned sometimes.

Ultimately, I was able to get it working and covered with these changes.

* Refactor tests per PR feedback

The places where `role: 'superuser’` was deleted in the listeners was a side effect of using `setRoleMappingData` and not `mount`

* Add back deleted assertion

* Copy nit

Co-authored-by: Constance <[email protected]>

Co-authored-by: Jason Stoltzfus <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Constance <[email protected]>
  • Loading branch information
4 people committed Mar 16, 2021
1 parent a8eb5a9 commit 72a216e
Show file tree
Hide file tree
Showing 7 changed files with 873 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 { EngineTypes } from '../components/engine/types';

export const defaultEngine = {
id: 'e1',
name: 'engine1',
type: EngineTypes.default,
language: null,
result_fields: {},
};

export const indexedEngine = {
id: 'e2',
name: 'engine2',
type: EngineTypes.indexed,
language: null,
result_fields: {},
};

export const engines = [defaultEngine, indexedEngine];
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ConfiguredLimits, Account, Role } from './types';

import { getRoleAbilities } from './utils/role';

interface AppValues {
export interface AppValues {
ilmEnabled: boolean;
configuredLimits: ConfiguredLimits;
account: Account;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,32 @@ export const ROLE_MAPPINGS_TITLE = i18n.translate(
'xpack.enterpriseSearch.appSearch.roleMappings.title',
{ defaultMessage: 'Role Mappings' }
);

export const DELETE_ROLE_MAPPING_MESSAGE = i18n.translate(
'xpack.enterpriseSearch.appSearch.deleteRoleMappingMessage',
{
defaultMessage:
'Are you sure you want to permanently delete this mapping? This action is not reversible and some users might lose access.',
}
);

export const ROLE_MAPPING_DELETED_MESSAGE = i18n.translate(
'xpack.enterpriseSearch.appSearch.roleMappingDeletedMessage',
{
defaultMessage: 'Successfully deleted role mapping',
}
);

export const ROLE_MAPPING_CREATED_MESSAGE = i18n.translate(
'xpack.enterpriseSearch.appSearch.roleMappingCreatedMessage',
{
defaultMessage: 'Role mapping successfully created.',
}
);

export const ROLE_MAPPING_UPDATED_MESSAGE = i18n.translate(
'xpack.enterpriseSearch.appSearch.roleMappingUpdatedMessage',
{
defaultMessage: 'Role mapping successfully updated.',
}
);
Loading

0 comments on commit 72a216e

Please sign in to comment.