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:
sakshigupta12feb
2025-10-28 19:11:12 +05:30
committed by GitHub
parent 0578910b9e
commit 18ecaaba78
7 changed files with 0 additions and 19 deletions

View File

@@ -236,7 +236,6 @@ export interface DataMaskingPolicy {
length: number; length: number;
}>; }>;
excludedPaths: string[]; excludedPaths: string[];
policyFormatVersion: number;
isPolicyEnabled: boolean; isPolicyEnabled: boolean;
} }

View File

@@ -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,
}; };

View File

@@ -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 =

View File

@@ -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",
}; };

View File

@@ -33,7 +33,6 @@ const emptyDataMaskingPolicy: DataModels.DataMaskingPolicy = {
}, },
], ],
excludedPaths: [], excludedPaths: [],
policyFormatVersion: 2,
isPolicyEnabled: false, isPolicyEnabled: false,
}; };

View File

@@ -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: () => {

View File

@@ -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);