Skip to content

Commit

Permalink
apply password generator policy to all users (#8641)
Browse files Browse the repository at this point in the history
  • Loading branch information
audreyality authored Apr 11, 2024
1 parent c2b91d2 commit 787ad64
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ describe("PolicyService", () => {
organization("org4", true, true, OrganizationUserStatusType.Confirmed, false),
// Another User
organization("org5", true, true, OrganizationUserStatusType.Confirmed, false),
// Can manage policies
organization("org6", true, true, OrganizationUserStatusType.Confirmed, true),
]);

policyService = new PolicyService(stateProvider, organizationService);
Expand Down Expand Up @@ -254,6 +256,22 @@ describe("PolicyService", () => {
expect(result).toBeNull();
});

it.each([
["owners", "org2"],
["administrators", "org6"],
])("returns the password generator policy for %s", async (_, organization) => {
activeUserState.nextState(
arrayToRecord([
policyData("policy1", "org1", PolicyType.ActivateAutofill, false),
policyData("policy2", organization, PolicyType.PasswordGenerator, true),
]),
);

const result = await firstValueFrom(policyService.get$(PolicyType.PasswordGenerator));

expect(result).toBeTruthy();
});

it("does not return policies for organizations that do not use policies", async () => {
activeUserState.nextState(
arrayToRecord([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
case PolicyType.MaximumVaultTimeout:
// Max Vault Timeout applies to everyone except owners
return organization.isOwner;
case PolicyType.PasswordGenerator:
// password generation policy applies to everyone
return false;
default:
return organization.canManagePolicies;
}
Expand Down

0 comments on commit 787ad64

Please sign in to comment.