-
Notifications
You must be signed in to change notification settings - Fork 390
Recapcha integ test #1599
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
Recapcha integ test #1599
Changes from all commits
d593c52
0faf913
9cab7f9
87faf5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ import { deepExtend, deepCopy } from '../../src/utils/deep-copy'; | |
import { | ||
AuthProviderConfig, CreateTenantRequest, DeleteUsersResult, PhoneMultiFactorInfo, | ||
TenantAwareAuth, UpdatePhoneMultiFactorInfoRequest, UpdateTenantRequest, UserImportOptions, | ||
UserImportRecord, UserRecord, getAuth, | ||
UserImportRecord, UserRecord, getAuth, UpdateProjectConfigRequest, | ||
} from '../../lib/auth/index'; | ||
|
||
const chalk = require('chalk'); // eslint-disable-line @typescript-eslint/no-var-requires | ||
|
@@ -1154,6 +1154,56 @@ describe('admin.auth', () => { | |
}); | ||
}); | ||
|
||
describe('Project config management operations', () => { | ||
before(function() { | ||
if (authEmulatorHost) { | ||
this.skip(); // getConfig is not supported in Auth Emulator | ||
} | ||
}); | ||
const projectConfigOption1: UpdateProjectConfigRequest = { | ||
recaptchaConfig: { | ||
emailPasswordEnforcementState: 'AUDIT', | ||
managedRules: [{ endScore: 0.1, action: 'BLOCK' }], | ||
}, | ||
}; | ||
const projectConfigOption2: UpdateProjectConfigRequest = { | ||
recaptchaConfig: { | ||
emailPasswordEnforcementState: 'OFF', | ||
}, | ||
}; | ||
const expectedProjectConfig1: any = { | ||
recaptchaConfig: { | ||
emailPasswordEnforcementState: 'AUDIT', | ||
managedRules: [{ endScore: 0.1, action: 'BLOCK' }], | ||
}, | ||
}; | ||
const expectedProjectConfig2: any = { | ||
recaptchaConfig: { | ||
emailPasswordEnforcementState: 'OFF', | ||
managedRules: [{ endScore: 0.1, action: 'BLOCK' }], | ||
}, | ||
}; | ||
|
||
it('updateProjectConfig() should resolve with the updated project config', () => { | ||
return getAuth().projectConfigManager().updateProjectConfig(projectConfigOption1) | ||
.then((actualProjectConfig) => { | ||
expect(actualProjectConfig.toJSON()).to.deep.equal(expectedProjectConfig1); | ||
return getAuth().projectConfigManager().updateProjectConfig(projectConfigOption2); | ||
}) | ||
.then((actualProjectConfig) => { | ||
expect(actualProjectConfig.toJSON()).to.deep.equal(expectedProjectConfig2); | ||
}); | ||
}); | ||
|
||
it('getProjectConfig() should resolve with expected project config', () => { | ||
return getAuth().projectConfigManager().getProjectConfig() | ||
.then((actualConfig) => { | ||
const actualConfigObj = actualConfig.toJSON(); | ||
expect(actualConfigObj).to.deep.equal(expectedProjectConfig2); | ||
Xiaoshouzi-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
}); | ||
}); | ||
|
||
describe('Tenant management operations', () => { | ||
let createdTenantId: string; | ||
const createdTenants: string[] = []; | ||
|
@@ -1210,6 +1260,15 @@ describe('admin.auth', () => { | |
testPhoneNumbers: { | ||
'+16505551234': '123456', | ||
}, | ||
recaptchaConfig: { | ||
emailPasswordEnforcementState: 'AUDIT', | ||
managedRules: [ | ||
{ | ||
endScore: 0.3, | ||
action: 'BLOCK', | ||
}, | ||
], | ||
}, | ||
}; | ||
const expectedUpdatedTenant2: any = { | ||
displayName: 'testTenantUpdated', | ||
|
@@ -1222,6 +1281,15 @@ describe('admin.auth', () => { | |
state: 'ENABLED', | ||
factorIds: ['phone'], | ||
}, | ||
recaptchaConfig: { | ||
emailPasswordEnforcementState: 'OFF', | ||
managedRules: [ | ||
{ | ||
endScore: 0.3, | ||
action: 'BLOCK', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
// https://mochajs.org/ | ||
|
@@ -1634,6 +1702,7 @@ describe('admin.auth', () => { | |
}, | ||
multiFactorConfig: deepCopy(expectedUpdatedTenant.multiFactorConfig), | ||
testPhoneNumbers: deepCopy(expectedUpdatedTenant.testPhoneNumbers), | ||
recaptchaConfig: deepCopy(expectedUpdatedTenant.recaptchaConfig), | ||
}; | ||
const updatedOptions2: UpdateTenantRequest = { | ||
emailSignInConfig: { | ||
|
@@ -1643,6 +1712,7 @@ describe('admin.auth', () => { | |
multiFactorConfig: deepCopy(expectedUpdatedTenant2.multiFactorConfig), | ||
// Test clearing of phone numbers. | ||
testPhoneNumbers: null, | ||
recaptchaConfig: deepCopy(expectedUpdatedTenant2.recaptchaConfig), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does updating a config with an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. With recaptchaConfig being undefined, the current config will stay unchanged. Added integration test for updateTenants. As of project config, since it's the only config, it got covered by unit test. |
||
}; | ||
if (authEmulatorHost) { | ||
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions) | ||
|
@@ -1672,6 +1742,28 @@ describe('admin.auth', () => { | |
}); | ||
}); | ||
|
||
it('updateTenant() should not update tenant reCAPTCHA config is undefined', () => { | ||
expectedUpdatedTenant.tenantId = createdTenantId; | ||
const updatedOptions2: UpdateTenantRequest = { | ||
displayName: expectedUpdatedTenant2.displayName, | ||
recaptchaConfig: undefined, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
}; | ||
if (authEmulatorHost) { | ||
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions2) | ||
.then((actualTenant) => { | ||
const actualTenantObj = actualTenant.toJSON(); | ||
// Not supported in Auth Emulator | ||
delete (actualTenantObj as {testPhoneNumbers: Record<string, string>}).testPhoneNumbers; | ||
delete expectedUpdatedTenant2.testPhoneNumbers; | ||
expect(actualTenantObj).to.deep.equal(expectedUpdatedTenant2); | ||
}); | ||
} | ||
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions2) | ||
.then((actualTenant) => { | ||
expect(actualTenant.toJSON()).to.deep.equal(expectedUpdatedTenant2); | ||
}); | ||
}); | ||
|
||
it('updateTenant() should be able to enable/disable anon provider', async () => { | ||
const tenantManager = getAuth().tenantManager(); | ||
let tenant = await tenantManager.createTenant({ | ||
|
Uh oh!
There was an error while loading. Please reload this page.