mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 00:41:31 +00:00
DDM Updated the validation logic as per BE values (policyFormatVersion field is removed from BE) (#2237)
* updated the validation logic as per BE values(policyFormatVersion will be removed from BE) * removed field * updated all test --------- Co-authored-by: Sakshi Gupta <sakshig@microsoft.com>
This commit is contained in:
@@ -236,7 +236,6 @@ export interface DataMaskingPolicy {
|
|||||||
length: number;
|
length: number;
|
||||||
}>;
|
}>;
|
||||||
excludedPaths: string[];
|
excludedPaths: string[];
|
||||||
policyFormatVersion: number;
|
|
||||||
isPolicyEnabled: boolean;
|
isPolicyEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ jest.mock("../../../Common/dataAccess/updateCollection", () => ({
|
|||||||
dataMaskingPolicy: {
|
dataMaskingPolicy: {
|
||||||
includedPaths: [],
|
includedPaths: [],
|
||||||
excludedPaths: ["/excludedPath"],
|
excludedPaths: ["/excludedPath"],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: true,
|
isPolicyEnabled: true,
|
||||||
},
|
},
|
||||||
indexes: [],
|
indexes: [],
|
||||||
@@ -308,13 +307,11 @@ describe("SettingsComponent", () => {
|
|||||||
dataMaskingContent: {
|
dataMaskingContent: {
|
||||||
includedPaths: [],
|
includedPaths: [],
|
||||||
excludedPaths: ["/excludedPath"],
|
excludedPaths: ["/excludedPath"],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: true,
|
isPolicyEnabled: true,
|
||||||
},
|
},
|
||||||
dataMaskingContentBaseline: {
|
dataMaskingContentBaseline: {
|
||||||
includedPaths: [],
|
includedPaths: [],
|
||||||
excludedPaths: [],
|
excludedPaths: [],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: false,
|
isPolicyEnabled: false,
|
||||||
},
|
},
|
||||||
isDataMaskingDirty: true,
|
isDataMaskingDirty: true,
|
||||||
@@ -329,7 +326,6 @@ describe("SettingsComponent", () => {
|
|||||||
expect(wrapper.state("dataMaskingContentBaseline")).toEqual({
|
expect(wrapper.state("dataMaskingContentBaseline")).toEqual({
|
||||||
includedPaths: [],
|
includedPaths: [],
|
||||||
excludedPaths: ["/excludedPath"],
|
excludedPaths: ["/excludedPath"],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: true,
|
isPolicyEnabled: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -344,7 +340,6 @@ describe("SettingsComponent", () => {
|
|||||||
const invalidPolicy: InvalidPolicy = {
|
const invalidPolicy: InvalidPolicy = {
|
||||||
includedPaths: "invalid",
|
includedPaths: "invalid",
|
||||||
excludedPaths: [],
|
excludedPaths: [],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: false,
|
isPolicyEnabled: false,
|
||||||
};
|
};
|
||||||
// Use type assertion since we're deliberately testing with invalid data
|
// Use type assertion since we're deliberately testing with invalid data
|
||||||
@@ -354,7 +349,6 @@ describe("SettingsComponent", () => {
|
|||||||
expect(wrapper.state("dataMaskingContent")).toEqual({
|
expect(wrapper.state("dataMaskingContent")).toEqual({
|
||||||
includedPaths: "invalid",
|
includedPaths: "invalid",
|
||||||
excludedPaths: [],
|
excludedPaths: [],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: false,
|
isPolicyEnabled: false,
|
||||||
});
|
});
|
||||||
expect(wrapper.state("dataMaskingValidationErrors")).toEqual(["includedPaths must be an array"]);
|
expect(wrapper.state("dataMaskingValidationErrors")).toEqual(["includedPaths must be an array"]);
|
||||||
@@ -370,7 +364,6 @@ describe("SettingsComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
excludedPaths: ["/excludedPath"],
|
excludedPaths: ["/excludedPath"],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: true,
|
isPolicyEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -395,7 +388,6 @@ describe("SettingsComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
excludedPaths: ["/excludedPath1"],
|
excludedPaths: ["/excludedPath1"],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: false,
|
isPolicyEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -409,7 +401,6 @@ describe("SettingsComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
excludedPaths: ["/excludedPath2"],
|
excludedPaths: ["/excludedPath2"],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: true,
|
isPolicyEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -700,9 +700,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
if (!Array.isArray(newDataMasking.excludedPaths)) {
|
if (!Array.isArray(newDataMasking.excludedPaths)) {
|
||||||
validationErrors.push("excludedPaths must be an array");
|
validationErrors.push("excludedPaths must be an array");
|
||||||
}
|
}
|
||||||
if (typeof newDataMasking.policyFormatVersion !== "number") {
|
|
||||||
validationErrors.push("policyFormatVersion must be a number");
|
|
||||||
}
|
|
||||||
if (typeof newDataMasking.isPolicyEnabled !== "boolean") {
|
if (typeof newDataMasking.isPolicyEnabled !== "boolean") {
|
||||||
validationErrors.push("isPolicyEnabled must be a boolean");
|
validationErrors.push("isPolicyEnabled must be a boolean");
|
||||||
}
|
}
|
||||||
@@ -845,7 +842,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
const dataMaskingContent: DataModels.DataMaskingPolicy = {
|
const dataMaskingContent: DataModels.DataMaskingPolicy = {
|
||||||
includedPaths: this.collection.dataMaskingPolicy?.()?.includedPaths || [],
|
includedPaths: this.collection.dataMaskingPolicy?.()?.includedPaths || [],
|
||||||
excludedPaths: this.collection.dataMaskingPolicy?.()?.excludedPaths || [],
|
excludedPaths: this.collection.dataMaskingPolicy?.()?.excludedPaths || [],
|
||||||
policyFormatVersion: this.collection.dataMaskingPolicy?.()?.policyFormatVersion || 2,
|
|
||||||
isPolicyEnabled: this.collection.dataMaskingPolicy?.()?.isPolicyEnabled || false,
|
isPolicyEnabled: this.collection.dataMaskingPolicy?.()?.isPolicyEnabled || false,
|
||||||
};
|
};
|
||||||
const conflictResolutionPolicy: DataModels.ConflictResolutionPolicy =
|
const conflictResolutionPolicy: DataModels.ConflictResolutionPolicy =
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ describe("DataMaskingComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
excludedPaths: [],
|
excludedPaths: [],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: false,
|
isPolicyEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,7 +174,6 @@ describe("DataMaskingComponent", () => {
|
|||||||
const invalidPolicy: Record<string, unknown> = {
|
const invalidPolicy: Record<string, unknown> = {
|
||||||
includedPaths: "not an array",
|
includedPaths: "not an array",
|
||||||
excludedPaths: [] as string[],
|
excludedPaths: [] as string[],
|
||||||
policyFormatVersion: "not a number",
|
|
||||||
isPolicyEnabled: "not a boolean",
|
isPolicyEnabled: "not a boolean",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ const emptyDataMaskingPolicy: DataModels.DataMaskingPolicy = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
excludedPaths: [],
|
excludedPaths: [],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: false,
|
isPolicyEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ export const collection = {
|
|||||||
dataMaskingPolicy: ko.observable<DataModels.DataMaskingPolicy>({
|
dataMaskingPolicy: ko.observable<DataModels.DataMaskingPolicy>({
|
||||||
includedPaths: [],
|
includedPaths: [],
|
||||||
excludedPaths: ["/excludedPath"],
|
excludedPaths: ["/excludedPath"],
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: true,
|
isPolicyEnabled: true,
|
||||||
}),
|
}),
|
||||||
readSettings: () => {
|
readSettings: () => {
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ export default class Collection implements ViewModels.Collection {
|
|||||||
const defaultDataMaskingPolicy: DataModels.DataMaskingPolicy = {
|
const defaultDataMaskingPolicy: DataModels.DataMaskingPolicy = {
|
||||||
includedPaths: Array<{ path: string; strategy: string; startPosition: number; length: number }>(),
|
includedPaths: Array<{ path: string; strategy: string; startPosition: number; length: number }>(),
|
||||||
excludedPaths: Array<string>(),
|
excludedPaths: Array<string>(),
|
||||||
policyFormatVersion: 2,
|
|
||||||
isPolicyEnabled: false,
|
isPolicyEnabled: false,
|
||||||
};
|
};
|
||||||
const observablePolicy = ko.observable(data.dataMaskingPolicy || defaultDataMaskingPolicy);
|
const observablePolicy = ko.observable(data.dataMaskingPolicy || defaultDataMaskingPolicy);
|
||||||
|
|||||||
Reference in New Issue
Block a user