Skip to content

Commit

Permalink
Fix nesting in auth config tests (#2228)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthecheung authored Jun 27, 2023
1 parent f182c36 commit 626814a
Showing 1 changed file with 50 additions and 48 deletions.
98 changes: 50 additions & 48 deletions test/unit/auth/auth-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,60 +1239,62 @@ describe('OIDCConfig', () => {
});
});
});
describe('PasswordPolicyAuthConfig',() => {
describe('constructor',() => {
const validConfig = new PasswordPolicyAuthConfig({
passwordPolicyEnforcementState: 'ENFORCE',
});

describe('PasswordPolicyAuthConfig',() => {
describe('constructor',() => {
const validConfig = new PasswordPolicyAuthConfig({
passwordPolicyEnforcementState: 'ENFORCE',
passwordPolicyVersions: [
{
customStrengthOptions: {
containsNumericCharacter: true,
containsLowercaseCharacter: true,
containsNonAlphanumericCharacter: true,
containsUppercaseCharacter: true,
minPasswordLength: 8,
maxPasswordLength: 30,
},
},
],
forceUpgradeOnSignin: true,
});

it('should throw an error on missing state',() => {
expect(() => new PasswordPolicyAuthConfig({
passwordPolicyVersions: [
{
customStrengthOptions: {
containsNumericCharacter: true,
containsLowercaseCharacter: true,
containsNonAlphanumericCharacter: true,
containsUppercaseCharacter: true,
minPasswordLength: 8,
maxPasswordLength: 30,
},
},
customStrengthOptions: {},
}
],
forceUpgradeOnSignin: true,
});

it('should throw an error on missing state',() => {
expect(() => new PasswordPolicyAuthConfig({
passwordPolicyVersions: [
{
customStrengthOptions: {},
}
],
} as any)).to.throw('INTERNAL ASSERT FAILED: Invalid password policy configuration response');
});
} as any)).to.throw('INTERNAL ASSERT FAILED: Invalid password policy configuration response');
});

it('should set readonly property "enforcementState" to ENFORCE on state enforced',() => {
expect(validConfig.enforcementState).to.equal('ENFORCE');
});
it('should set readonly property "enforcementState" to ENFORCE on state enforced',() => {
expect(validConfig.enforcementState).to.equal('ENFORCE');
});

it('should set readonly property "enforcementState" to OFF on state disabling',() => {
const offStateConfig=new PasswordPolicyAuthConfig({
passwordPolicyEnforcementState: 'OFF',
});
expect(offStateConfig.enforcementState).to.equal('OFF');
it('should set readonly property "enforcementState" to OFF on state disabling',() => {
const offStateConfig=new PasswordPolicyAuthConfig({
passwordPolicyEnforcementState: 'OFF',
});
expect(offStateConfig.enforcementState).to.equal('OFF');
});

it('should set readonly property "constraints"',() => {
const expectedConstraints: CustomStrengthOptionsConfig = {
requireUppercase: true,
requireLowercase: true,
requireNonAlphanumeric: true,
requireNumeric: true,
minLength: 8,
maxLength: 30,
}
expect(validConfig.constraints).to.deep.equal(expectedConstraints);
});
it('should set readonly property "constraints"',() => {
const expectedConstraints: CustomStrengthOptionsConfig = {
requireUppercase: true,
requireLowercase: true,
requireNonAlphanumeric: true,
requireNumeric: true,
minLength: 8,
maxLength: 30,
}
expect(validConfig.constraints).to.deep.equal(expectedConstraints);
});

it('should set readonly property "forceUpgradeOnSignin"',() => {
expect(validConfig.forceUpgradeOnSignin).to.deep.equal(true);
});
it('should set readonly property "forceUpgradeOnSignin"',() => {
expect(validConfig.forceUpgradeOnSignin).to.deep.equal(true);
});
});});
});
});

0 comments on commit 626814a

Please sign in to comment.