From 111647f851a6a0f2a8859e2a7e5815cdf5acbcbb Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:04:20 -0500 Subject: [PATCH] UI: Remove deprecated Client Count keys (#27916) * remove destructureClientCounts * Update type and mirage generator * remove deprecated keys from hardcoded response samples * Add back destructureClientCounts with updated description --- ui/lib/core/addon/utils/client-count-utils.ts | 5 +- ui/mirage/handlers/clients.js | 11 +- ui/mirage/handlers/sync.js | 42 ------- .../helpers/clients/client-count-helpers.js | 108 ------------------ .../utils/client-count-utils-test.js | 4 - 5 files changed, 2 insertions(+), 168 deletions(-) diff --git a/ui/lib/core/addon/utils/client-count-utils.ts b/ui/lib/core/addon/utils/client-count-utils.ts index 69091f888e..3d20f540e6 100644 --- a/ui/lib/core/addon/utils/client-count-utils.ts +++ b/ui/lib/core/addon/utils/client-count-utils.ts @@ -152,8 +152,7 @@ export const formatByNamespace = (namespaceArray: NamespaceObject[] | null): ByN }); }; -// In 1.10 'distinct_entities' changed to 'entity_clients' and 'non_entity_tokens' to 'non_entity_clients' -// these deprecated keys still exist on the response, so only return relevant keys here +// This method returns only client types from the passed object, excluding other keys such as "label". // when querying historical data the response will always contain the latest client type keys because the activity log is // constructed based on the version of Vault the user is on (key values will be 0) export const destructureClientCounts = (verboseObject: Counts | ByNamespaceClients) => { @@ -358,9 +357,7 @@ export interface EmptyActivityMonthBlock { export interface Counts { acme_clients: number; clients: number; - distinct_entities: number; entity_clients: number; non_entity_clients: number; - non_entity_tokens: number; secret_syncs: number; } diff --git a/ui/mirage/handlers/clients.js b/ui/mirage/handlers/clients.js index 508c11b40e..c0cb782814 100644 --- a/ui/mirage/handlers/clients.js +++ b/ui/mirage/handlers/clients.js @@ -49,17 +49,10 @@ function getSum(array, key) { } function getTotalCounts(array) { - const counts = CLIENT_TYPES.reduce((obj, key) => { + return CLIENT_TYPES.reduce((obj, key) => { obj[key] = getSum(array, key); return obj; }, {}); - - // add deprecated keys - return { - ...counts, - distinct_entities: counts.entity_clients, - non_entity_tokens: counts.non_entity_clients, - }; } function randomBetween(min, max) { @@ -75,8 +68,6 @@ function generateMountBlock(path, counts) { mount_path: path, counts: { ...baseObject, - distinct_entities: 0, - non_entity_tokens: 0, // object contains keys for which 0-values of base object to overwrite ...counts, }, diff --git a/ui/mirage/handlers/sync.js b/ui/mirage/handlers/sync.js index ae35dd35dc..2a066e2260 100644 --- a/ui/mirage/handlers/sync.js +++ b/ui/mirage/handlers/sync.js @@ -276,30 +276,24 @@ export default function (server) { end_time, // set by query params total: { clients: 15, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 15, }, by_namespace: [ { counts: { clients: 15, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 15, }, mounts: [ { counts: { clients: 15, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 15, }, mount_path: 'sys/', @@ -314,30 +308,24 @@ export default function (server) { { counts: { clients: 10, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 10, }, namespaces: [ { counts: { clients: 10, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 10, }, mounts: [ { counts: { clients: 10, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 10, }, mount_path: 'sys/', @@ -350,30 +338,24 @@ export default function (server) { new_clients: { counts: { clients: 10, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 10, }, namespaces: [ { counts: { clients: 10, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 10, }, mounts: [ { counts: { clients: 10, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 10, }, mount_path: 'sys/', @@ -389,30 +371,24 @@ export default function (server) { { counts: { clients: 7, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 7, }, namespaces: [ { counts: { clients: 7, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 7, }, mounts: [ { counts: { clients: 7, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 7, }, mount_path: 'sys/', @@ -425,30 +401,24 @@ export default function (server) { new_clients: { counts: { clients: 3, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 3, }, namespaces: [ { counts: { clients: 3, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 3, }, mounts: [ { counts: { clients: 3, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 3, }, mount_path: 'sys/', @@ -464,30 +434,24 @@ export default function (server) { { counts: { clients: 7, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 7, }, namespaces: [ { counts: { clients: 7, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 7, }, mounts: [ { counts: { clients: 7, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 7, }, mount_path: 'sys/', @@ -500,30 +464,24 @@ export default function (server) { new_clients: { counts: { clients: 2, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 2, }, namespaces: [ { counts: { clients: 2, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 2, }, mounts: [ { counts: { clients: 2, - distinct_entities: 0, entity_clients: 0, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 2, }, mount_path: 'sys/', diff --git a/ui/tests/helpers/clients/client-count-helpers.js b/ui/tests/helpers/clients/client-count-helpers.js index a4d38a723a..e847519b09 100644 --- a/ui/tests/helpers/clients/client-count-helpers.js +++ b/ui/tests/helpers/clients/client-count-helpers.js @@ -42,8 +42,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 4256, non_entity_clients: 4138, secret_syncs: 4810, - distinct_entities: 4256, - non_entity_tokens: 4138, }, mounts: [ { @@ -54,8 +52,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 4256, non_entity_clients: 4138, secret_syncs: 0, - distinct_entities: 4256, - non_entity_tokens: 4138, }, }, { @@ -66,8 +62,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 4810, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -78,8 +72,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -93,8 +85,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 4002, non_entity_clients: 4089, secret_syncs: 4290, - distinct_entities: 4002, - non_entity_tokens: 4089, }, mounts: [ { @@ -105,8 +95,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 4002, non_entity_clients: 4089, secret_syncs: 0, - distinct_entities: 4002, - non_entity_tokens: 4089, }, }, { @@ -117,8 +105,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 4290, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -129,8 +115,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -151,8 +135,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 100, - distinct_entities: 100, - non_entity_tokens: 100, }, namespaces: [ { @@ -164,8 +146,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 100, - distinct_entities: 100, - non_entity_tokens: 100, }, mounts: [ { @@ -176,8 +156,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -188,8 +166,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -200,8 +176,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 100, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -214,8 +188,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 100, - distinct_entities: 100, - non_entity_tokens: 100, }, namespaces: [ { @@ -227,8 +199,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 100, - distinct_entities: 100, - non_entity_tokens: 100, }, mounts: [ { @@ -239,8 +209,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -251,8 +219,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -263,8 +229,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 100, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -280,8 +244,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 100, - distinct_entities: 100, - non_entity_tokens: 100, }, namespaces: [ { @@ -293,8 +255,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 100, - distinct_entities: 100, - non_entity_tokens: 100, }, mounts: [ { @@ -305,8 +265,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -317,8 +275,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 100, non_entity_clients: 100, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -329,8 +285,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 100, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -349,8 +303,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 832, non_entity_clients: 930, secret_syncs: 238, - distinct_entities: 832, - non_entity_tokens: 930, }, namespaces: [ { @@ -362,8 +314,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 708, non_entity_clients: 182, secret_syncs: 157, - distinct_entities: 708, - non_entity_tokens: 182, }, mounts: [ { @@ -374,8 +324,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -386,8 +334,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 708, non_entity_clients: 182, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -398,8 +344,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 157, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -413,8 +357,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 124, non_entity_clients: 748, secret_syncs: 81, - distinct_entities: 124, - non_entity_tokens: 748, }, mounts: [ { @@ -425,8 +367,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -437,8 +377,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 124, non_entity_clients: 748, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -449,8 +387,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 81, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -463,8 +399,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 59, non_entity_clients: 112, secret_syncs: 49, - distinct_entities: 59, - non_entity_tokens: 112, }, namespaces: [ { @@ -476,8 +410,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 25, non_entity_clients: 50, secret_syncs: 25, - distinct_entities: 25, - non_entity_tokens: 50, }, mounts: [ { @@ -488,8 +420,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -500,8 +430,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 25, non_entity_clients: 50, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -512,8 +440,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 25, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -527,8 +453,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 34, non_entity_clients: 62, secret_syncs: 24, - distinct_entities: 34, - non_entity_tokens: 62, }, mounts: [ { @@ -539,8 +463,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 34, non_entity_clients: 62, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -551,8 +473,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 0, - distinct_entities: 0, - non_entity_tokens: 0, }, }, { @@ -563,8 +483,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 0, non_entity_clients: 0, secret_syncs: 24, - distinct_entities: 0, - non_entity_tokens: 0, }, }, ], @@ -579,8 +497,6 @@ export const ACTIVITY_RESPONSE_STUB = { entity_clients: 8258, non_entity_clients: 8227, secret_syncs: 9100, - distinct_entities: 8258, - non_entity_tokens: 8227, }, }; @@ -591,10 +507,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { total: { acme_clients: 0, clients: 3, - distinct_entities: 3, entity_clients: 3, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, by_namespace: [ @@ -602,10 +516,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 3, - distinct_entities: 3, entity_clients: 3, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mounts: [ @@ -613,10 +525,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 2, - distinct_entities: 2, entity_clients: 2, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mount_path: 'no mount accessor (pre-1.10 upgrade?)', @@ -625,10 +535,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 1, - distinct_entities: 1, entity_clients: 1, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mount_path: 'auth/u/', @@ -649,10 +557,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 3, - distinct_entities: 0, entity_clients: 3, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, namespaces: [ @@ -660,10 +566,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 3, - distinct_entities: 0, entity_clients: 3, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mounts: [ @@ -671,10 +575,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 2, - distinct_entities: 0, entity_clients: 2, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mount_path: 'no mount accessor (pre-1.10 upgrade?)', @@ -683,10 +585,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 1, - distinct_entities: 0, entity_clients: 1, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mount_path: 'auth/u/', @@ -700,10 +600,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 3, - distinct_entities: 0, entity_clients: 3, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, namespaces: [ @@ -711,10 +609,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 3, - distinct_entities: 0, entity_clients: 3, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mounts: [ @@ -722,10 +618,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 2, - distinct_entities: 0, entity_clients: 2, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mount_path: 'no mount accessor (pre-1.10 upgrade?)', @@ -734,10 +628,8 @@ export const MIXED_ACTIVITY_RESPONSE_STUB = { counts: { acme_clients: 0, clients: 1, - distinct_entities: 0, entity_clients: 1, non_entity_clients: 0, - non_entity_tokens: 0, secret_syncs: 0, }, mount_path: 'auth/u/', diff --git a/ui/tests/integration/utils/client-count-utils-test.js b/ui/tests/integration/utils/client-count-utils-test.js index d6da1a5a04..7465297726 100644 --- a/ui/tests/integration/utils/client-count-utils-test.js +++ b/ui/tests/integration/utils/client-count-utils-test.js @@ -231,9 +231,7 @@ module('Integration | Util | client count utils', function (hooks) { namespace_id: 'root', namespace_path: '', counts: { - distinct_entities: 10, entity_clients: 10, - non_entity_tokens: 20, non_entity_clients: 20, secret_syncs: 0, acme_clients: 0, @@ -242,9 +240,7 @@ module('Integration | Util | client count utils', function (hooks) { mounts: [ { counts: { - distinct_entities: 10, entity_clients: 10, - non_entity_tokens: 20, non_entity_clients: 20, secret_syncs: 0, acme_clients: 0,