apply password generator policy to all users (#8641)

This commit is contained in:
✨ Audrey ✨ 2024-04-11 13:32:50 -04:00 committed by GitHub
parent c2b91d2d46
commit 787ad64b73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

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

View File

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