mirror of
https://github.com/bitwarden/browser
synced 2026-03-01 11:01:17 +00:00
[PM-19357] - [Defect] Unauthorised access allows limited access user to change custom hidden field of Items (#14068)
* update tests * finish tests * only disallow hidden fields for hiddenPassword users * fix failing tests * fix story * only disable hidden field option when editing
This commit is contained in:
@@ -45,7 +45,9 @@ describe("CustomFieldsComponent", () => {
|
||||
announce = jest.fn().mockResolvedValue(null);
|
||||
patchCipher = jest.fn();
|
||||
originalCipherView = new CipherView();
|
||||
config = {} as CipherFormConfig;
|
||||
config = {
|
||||
collections: [],
|
||||
} as CipherFormConfig;
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [CustomFieldsComponent],
|
||||
@@ -463,5 +465,91 @@ describe("CustomFieldsComponent", () => {
|
||||
// "reorder boolean label to position 4 of 4"
|
||||
expect(announce).toHaveBeenCalledWith("reorderFieldDown boolean label 4 4", "assertive");
|
||||
});
|
||||
|
||||
it("hides reorder buttons when in partial edit mode", () => {
|
||||
originalCipherView.fields = mockFieldViews;
|
||||
config.mode = "partial-edit";
|
||||
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
toggleItems = fixture.debugElement.queryAll(
|
||||
By.css('button[data-testid="reorder-toggle-button"]'),
|
||||
);
|
||||
|
||||
expect(toggleItems).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
it("shows all reorders button when in edit mode and viewPassword is true", () => {
|
||||
originalCipherView.fields = mockFieldViews;
|
||||
originalCipherView.viewPassword = true;
|
||||
config.mode = "edit";
|
||||
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
const toggleItems = fixture.debugElement.queryAll(
|
||||
By.css('button[data-testid="reorder-toggle-button"]'),
|
||||
);
|
||||
expect(toggleItems).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("shows all reorder buttons except for hidden fields when in edit mode and viewPassword is false", () => {
|
||||
originalCipherView.fields = mockFieldViews;
|
||||
originalCipherView.viewPassword = false;
|
||||
config.mode = "edit";
|
||||
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
const toggleItems = fixture.debugElement.queryAll(
|
||||
By.css('button[data-testid="reorder-toggle-button"]'),
|
||||
);
|
||||
|
||||
expect(toggleItems).toHaveLength(3);
|
||||
});
|
||||
|
||||
describe("edit button", () => {
|
||||
it("hides the edit button when in partial-edit mode", () => {
|
||||
originalCipherView.fields = mockFieldViews;
|
||||
config.mode = "partial-edit";
|
||||
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
const editButtons = fixture.debugElement.queryAll(
|
||||
By.css('button[data-testid="edit-custom-field-button"]'),
|
||||
);
|
||||
expect(editButtons).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("shows all the edit buttons when in edit mode and viewPassword is true", () => {
|
||||
originalCipherView.fields = mockFieldViews;
|
||||
originalCipherView.viewPassword = true;
|
||||
config.mode = "edit";
|
||||
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
const editButtons = fixture.debugElement.queryAll(
|
||||
By.css('button[data-testid="edit-custom-field-button"]'),
|
||||
);
|
||||
expect(editButtons).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("shows all the edit buttons except for hidden fields when in edit mode and viewPassword is false", () => {
|
||||
originalCipherView.fields = mockFieldViews;
|
||||
originalCipherView.viewPassword = false;
|
||||
config.mode = "edit";
|
||||
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
const editButtons = fixture.debugElement.queryAll(
|
||||
By.css('button[data-testid="edit-custom-field-button"]'),
|
||||
);
|
||||
expect(editButtons).toHaveLength(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user