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

@@ -30,7 +30,6 @@ jest.mock("../../../Common/dataAccess/updateCollection", () => ({
dataMaskingPolicy: {
includedPaths: [],
excludedPaths: ["/excludedPath"],
policyFormatVersion: 2,
isPolicyEnabled: true,
},
indexes: [],
@@ -308,13 +307,11 @@ describe("SettingsComponent", () => {
dataMaskingContent: {
includedPaths: [],
excludedPaths: ["/excludedPath"],
policyFormatVersion: 2,
isPolicyEnabled: true,
},
dataMaskingContentBaseline: {
includedPaths: [],
excludedPaths: [],
policyFormatVersion: 2,
isPolicyEnabled: false,
},
isDataMaskingDirty: true,
@@ -329,7 +326,6 @@ describe("SettingsComponent", () => {
expect(wrapper.state("dataMaskingContentBaseline")).toEqual({
includedPaths: [],
excludedPaths: ["/excludedPath"],
policyFormatVersion: 2,
isPolicyEnabled: true,
});
});
@@ -344,7 +340,6 @@ describe("SettingsComponent", () => {
const invalidPolicy: InvalidPolicy = {
includedPaths: "invalid",
excludedPaths: [],
policyFormatVersion: 2,
isPolicyEnabled: false,
};
// Use type assertion since we're deliberately testing with invalid data
@@ -354,7 +349,6 @@ describe("SettingsComponent", () => {
expect(wrapper.state("dataMaskingContent")).toEqual({
includedPaths: "invalid",
excludedPaths: [],
policyFormatVersion: 2,
isPolicyEnabled: false,
});
expect(wrapper.state("dataMaskingValidationErrors")).toEqual(["includedPaths must be an array"]);
@@ -370,7 +364,6 @@ describe("SettingsComponent", () => {
},
],
excludedPaths: ["/excludedPath"],
policyFormatVersion: 2,
isPolicyEnabled: true,
};
@@ -395,7 +388,6 @@ describe("SettingsComponent", () => {
},
],
excludedPaths: ["/excludedPath1"],
policyFormatVersion: 2,
isPolicyEnabled: false,
};
@@ -409,7 +401,6 @@ describe("SettingsComponent", () => {
},
],
excludedPaths: ["/excludedPath2"],
policyFormatVersion: 2,
isPolicyEnabled: true,
};

View File

@@ -700,9 +700,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
if (!Array.isArray(newDataMasking.excludedPaths)) {
validationErrors.push("excludedPaths must be an array");
}
if (typeof newDataMasking.policyFormatVersion !== "number") {
validationErrors.push("policyFormatVersion must be a number");
}
if (typeof newDataMasking.isPolicyEnabled !== "boolean") {
validationErrors.push("isPolicyEnabled must be a boolean");
}
@@ -845,7 +842,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
const dataMaskingContent: DataModels.DataMaskingPolicy = {
includedPaths: this.collection.dataMaskingPolicy?.()?.includedPaths || [],
excludedPaths: this.collection.dataMaskingPolicy?.()?.excludedPaths || [],
policyFormatVersion: this.collection.dataMaskingPolicy?.()?.policyFormatVersion || 2,
isPolicyEnabled: this.collection.dataMaskingPolicy?.()?.isPolicyEnabled || false,
};
const conflictResolutionPolicy: DataModels.ConflictResolutionPolicy =

View File

@@ -53,7 +53,6 @@ describe("DataMaskingComponent", () => {
},
],
excludedPaths: [],
policyFormatVersion: 2,
isPolicyEnabled: false,
};
@@ -175,7 +174,6 @@ describe("DataMaskingComponent", () => {
const invalidPolicy: Record<string, unknown> = {
includedPaths: "not an array",
excludedPaths: [] as string[],
policyFormatVersion: "not a number",
isPolicyEnabled: "not a boolean",
};

View File

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

View File

@@ -68,7 +68,6 @@ export const collection = {
dataMaskingPolicy: ko.observable<DataModels.DataMaskingPolicy>({
includedPaths: [],
excludedPaths: ["/excludedPath"],
policyFormatVersion: 2,
isPolicyEnabled: true,
}),
readSettings: () => {

View File

@@ -141,7 +141,6 @@ export default class Collection implements ViewModels.Collection {
const defaultDataMaskingPolicy: DataModels.DataMaskingPolicy = {
includedPaths: Array<{ path: string; strategy: string; startPosition: number; length: number }>(),
excludedPaths: Array<string>(),
policyFormatVersion: 2,
isPolicyEnabled: false,
};
const observablePolicy = ko.observable(data.dataMaskingPolicy || defaultDataMaskingPolicy);