Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Portner committed Jun 3, 2022
1 parent e9a5f98 commit 8a58d18
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface UpgradeableConfigType {
buildNum: number;
defaultIndex?: string;
isDefaultIndexMigrated?: boolean;
[key: string]: unknown;
}

/**
Expand All @@ -37,7 +38,6 @@ export async function getUpgradeableConfig({
type: 'config',
page: 1,
perPage: 1000,
fields: ['buildNum', 'defaultIndex', 'isDefaultIndexMigrated'], // Optimization: we only need these type-level fields, don't return anything else
sortField: 'buildNum',
sortOrder: 'desc',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ describe('createOrUpgradeSavedConfig()', () => {
// 5.4.0-SNAPSHOT and @@version were ignored so we only have the
// attributes from 5.4.0-rc1, even though the other build nums are greater
'5.4.0-rc1': true,

// Should have the transform(s) applied
isDefaultIndexMigrated: true,
});

// add the 5.4.0 flag to the 5.4.0 savedConfig
Expand All @@ -115,6 +118,9 @@ describe('createOrUpgradeSavedConfig()', () => {
// should also include properties from 5.4.0 and 5.4.0-rc1
'5.4.0': true,
'5.4.0-rc1': true,

// Should have the transform(s) applied
isDefaultIndexMigrated: true,
});

// add the 5.4.1 flag to the 5.4.1 savedConfig
Expand All @@ -141,6 +147,9 @@ describe('createOrUpgradeSavedConfig()', () => {
'5.4.1': true,
'5.4.0': true,
'5.4.0-rc1': true,

// Should have the transform(s) applied
isDefaultIndexMigrated: true,
});

// tag the 7.0.0-rc1 doc
Expand Down Expand Up @@ -168,6 +177,9 @@ describe('createOrUpgradeSavedConfig()', () => {
'5.4.1': true,
'5.4.0': true,
'5.4.0-rc1': true,

// Should have the transform(s) applied
isDefaultIndexMigrated: true,
});

// tag the 7.0.0 doc
Expand All @@ -194,6 +206,9 @@ describe('createOrUpgradeSavedConfig()', () => {
'5.4.1': true,
'5.4.0': true,
'5.4.0-rc1': true,

// Should have the transform(s) applied
isDefaultIndexMigrated: true,
});
}, 30000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import { UsageStats } from './types';
import { REDACTED_KEYWORD } from '../../../common/constants';
import { stackManagementSchema } from './schema';

/**
* These config keys should be redacted from any usage data, they are only used for implementation details of the config saved object.
*/
const CONFIG_KEYS_TO_REDACT = ['buildNum', 'isDefaultIndexMigrated'];

export function createCollectorFetch(getUiSettingsClient: () => IUiSettingsClient | undefined) {
return async function fetchUsageStats(): Promise<UsageStats | undefined> {
const uiSettingsClient = getUiSettingsClient();
Expand All @@ -21,7 +26,7 @@ export function createCollectorFetch(getUiSettingsClient: () => IUiSettingsClien

const userProvided = await uiSettingsClient.getUserProvided();
const modifiedEntries = Object.entries(userProvided)
.filter(([key]) => key !== 'buildNum')
.filter(([key]) => !CONFIG_KEYS_TO_REDACT.includes(key))
.reduce((obj: Record<string, unknown>, [key, { userValue }]) => {
const sensitive = uiSettingsClient.isSensitive(key);
obj[key] = sensitive ? REDACTED_KEYWORD : userValue;
Expand Down

0 comments on commit 8a58d18

Please sign in to comment.