Skip to content

Commit

Permalink
Fix MFA endpoint names to be mfa provider-agnostic. (#6572)
Browse files Browse the repository at this point in the history
We will have other MFA providers than phone in the near future.
  • Loading branch information
prameshj committed Aug 31, 2022
1 parent ca1b0c8 commit 04dcdbb
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 25 deletions.
8 changes: 4 additions & 4 deletions packages/auth/src/api/account_management/mfa.test.ts
Expand Up @@ -52,7 +52,7 @@ describe('api/account_management/startEnrollPhoneMfa', () => {
afterEach(mockFetch.tearDown);

it('should POST to the correct endpoint', async () => {
const mock = mockEndpoint(Endpoint.START_PHONE_MFA_ENROLLMENT, {
const mock = mockEndpoint(Endpoint.START_MFA_ENROLLMENT, {
phoneSessionInfo: {
sessionInfo: 'session-info'
}
Expand All @@ -72,7 +72,7 @@ describe('api/account_management/startEnrollPhoneMfa', () => {

it('should handle errors', async () => {
const mock = mockEndpoint(
Endpoint.START_PHONE_MFA_ENROLLMENT,
Endpoint.START_MFA_ENROLLMENT,
{
error: {
code: 400,
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('api/account_management/finalizeEnrollPhoneMfa', () => {
afterEach(mockFetch.tearDown);

it('should POST to the correct endpoint', async () => {
const mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT, {
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_ENROLLMENT, {
idToken: 'id-token',
refreshToken: 'refresh-token'
});
Expand All @@ -136,7 +136,7 @@ describe('api/account_management/finalizeEnrollPhoneMfa', () => {

it('should handle errors', async () => {
const mock = mockEndpoint(
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
Endpoint.FINALIZE_MFA_ENROLLMENT,
{
error: {
code: 400,
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/api/account_management/mfa.ts
Expand Up @@ -71,7 +71,7 @@ export function startEnrollPhoneMfa(
>(
auth,
HttpMethod.POST,
Endpoint.START_PHONE_MFA_ENROLLMENT,
Endpoint.START_MFA_ENROLLMENT,
_addTidIfNecessary(auth, request)
);
}
Expand All @@ -96,7 +96,7 @@ export function finalizeEnrollPhoneMfa(
>(
auth,
HttpMethod.POST,
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
Endpoint.FINALIZE_MFA_ENROLLMENT,
_addTidIfNecessary(auth, request)
);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/auth/src/api/authentication/mfa.test.ts
Expand Up @@ -48,7 +48,7 @@ describe('api/authentication/startSignInPhoneMfa', () => {
afterEach(mockFetch.tearDown);

it('should POST to the correct endpoint', async () => {
const mock = mockEndpoint(Endpoint.START_PHONE_MFA_SIGN_IN, {
const mock = mockEndpoint(Endpoint.START_MFA_SIGN_IN, {
phoneResponseInfo: {
sessionInfo: 'session-info'
}
Expand All @@ -68,7 +68,7 @@ describe('api/authentication/startSignInPhoneMfa', () => {

it('should handle errors', async () => {
const mock = mockEndpoint(
Endpoint.START_PHONE_MFA_SIGN_IN,
Endpoint.START_MFA_SIGN_IN,
{
error: {
code: 400,
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('api/authentication/finalizeSignInPhoneMfa', () => {
afterEach(mockFetch.tearDown);

it('should POST to the correct endpoint', async () => {
const mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_SIGN_IN, {
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, {
idToken: 'id-token',
refreshToken: 'refresh-token'
});
Expand All @@ -132,7 +132,7 @@ describe('api/authentication/finalizeSignInPhoneMfa', () => {

it('should handle errors', async () => {
const mock = mockEndpoint(
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
Endpoint.FINALIZE_MFA_SIGN_IN,
{
error: {
code: 400,
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/api/authentication/mfa.ts
Expand Up @@ -68,7 +68,7 @@ export function startSignInPhoneMfa(
>(
auth,
HttpMethod.POST,
Endpoint.START_PHONE_MFA_SIGN_IN,
Endpoint.START_MFA_SIGN_IN,
_addTidIfNecessary(auth, request)
);
}
Expand All @@ -91,7 +91,7 @@ export function finalizeSignInPhoneMfa(
>(
auth,
HttpMethod.POST,
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
Endpoint.FINALIZE_MFA_SIGN_IN,
_addTidIfNecessary(auth, request)
);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/auth/src/api/index.ts
Expand Up @@ -60,10 +60,10 @@ export const enum Endpoint {
SET_ACCOUNT_INFO = '/v1/accounts:update',
GET_ACCOUNT_INFO = '/v1/accounts:lookup',
GET_RECAPTCHA_PARAM = '/v1/recaptchaParams',
START_PHONE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:start',
FINALIZE_PHONE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:finalize',
START_PHONE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:start',
FINALIZE_PHONE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:finalize',
START_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:start',
FINALIZE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:finalize',
START_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:start',
FINALIZE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:finalize',
WITHDRAW_MFA = '/v2/accounts/mfaEnrollment:withdraw',
GET_PROJECT_CONFIG = '/v1/projects'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/mfa/mfa_resolver.test.ts
Expand Up @@ -114,7 +114,7 @@ describe('core/mfa/mfa_resolver/MultiFactorResolver', () => {
};

beforeEach(() => {
mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_SIGN_IN, {
mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, {
idToken: finalIdToken,
refreshToken: 'final-refresh-token'
});
Expand Down
Expand Up @@ -63,7 +63,7 @@ describe('platform_browser/mfa/phone', () => {

it('should finalize the MFA enrollment', async () => {
const mock = mockEndpoint(
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
Endpoint.FINALIZE_MFA_ENROLLMENT,
serverResponse
);
const response = await assertion._process(auth, session);
Expand All @@ -80,7 +80,7 @@ describe('platform_browser/mfa/phone', () => {
context('with display name', () => {
it('should set the display name', async () => {
const mock = mockEndpoint(
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
Endpoint.FINALIZE_MFA_ENROLLMENT,
serverResponse
);
const response = await assertion._process(
Expand Down Expand Up @@ -109,10 +109,7 @@ describe('platform_browser/mfa/phone', () => {
});

it('should finalize the MFA sign in', async () => {
const mock = mockEndpoint(
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
serverResponse
);
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, serverResponse);
const response = await assertion._process(auth, session);
expect(response).to.eql(serverResponse);
expect(mock.calls[0].request).to.eql({
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/platform_browser/strategies/phone.test.ts
Expand Up @@ -323,7 +323,7 @@ describe('platform_browser/strategies/phone', () => {
});

it('works with an enrollment flow', async () => {
const endpoint = mockEndpoint(Endpoint.START_PHONE_MFA_ENROLLMENT, {
const endpoint = mockEndpoint(Endpoint.START_MFA_ENROLLMENT, {
phoneSessionInfo: {
sessionInfo: 'session-info'
}
Expand All @@ -345,7 +345,7 @@ describe('platform_browser/strategies/phone', () => {
});

it('works when completing the sign in flow', async () => {
const endpoint = mockEndpoint(Endpoint.START_PHONE_MFA_SIGN_IN, {
const endpoint = mockEndpoint(Endpoint.START_MFA_SIGN_IN, {
phoneResponseInfo: {
sessionInfo: 'session-info'
}
Expand Down

0 comments on commit 04dcdbb

Please sign in to comment.