Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nesting in auth config tests #2228

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});});
});
});