forked from ustaxcourt/ef-cms
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
10007: Have initiate auth handle AWS specific errors
- Loading branch information
1 parent
556be48
commit 0635e45
Showing
5 changed files
with
69 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import { | ||
ChallengeNameType, | ||
InitiateAuthCommandOutput, | ||
InvalidPasswordException, | ||
NotAuthorizedException, | ||
UserNotConfirmedException, | ||
|
@@ -17,13 +15,11 @@ describe('loginInteractor', () => { | |
it('should throw an error when the user attempts to log in and they are in a NEW_PASSWORD_REQUIRED state', async () => { | ||
const mockEmail = '[email protected]'; | ||
const mockPassword = 'MyPa$Sword!'; | ||
const mockNewPasswordRequiredResponse: InitiateAuthCommandOutput = { | ||
$metadata: {}, | ||
ChallengeName: ChallengeNameType.NEW_PASSWORD_REQUIRED, | ||
}; | ||
const mockNewPasswordRequiredError = new Error('NewPasswordRequired'); | ||
mockNewPasswordRequiredError.name = 'NewPasswordRequired'; | ||
applicationContext | ||
.getUserGateway() | ||
.initiateAuth.mockResolvedValue(mockNewPasswordRequiredResponse); | ||
.initiateAuth.mockRejectedValue(mockNewPasswordRequiredError); | ||
|
||
await expect( | ||
loginInteractor(applicationContext, { | ||
|
@@ -111,9 +107,11 @@ describe('loginInteractor', () => { | |
it('should throw an error when initiateAuth does not return access, id, and refresh tokens', async () => { | ||
const mockEmail = '[email protected]'; | ||
const mockPassword = 'MyPa$Sword!'; | ||
const initiateAuthError = new Error('InitiateAuthError'); | ||
initiateAuthError.name = 'InitiateAuthError'; | ||
applicationContext | ||
.getUserGateway() | ||
.initiateAuth.mockResolvedValue({ AuthenticationResult: {} }); | ||
.initiateAuth.mockRejectedValue(initiateAuthError); | ||
|
||
await expect( | ||
loginInteractor(applicationContext, { | ||
|
@@ -208,13 +206,10 @@ describe('loginInteractor', () => { | |
it('should return the access, id, refresh tokens to the user when the user is successfully authenticated', async () => { | ||
const mockEmail = '[email protected]'; | ||
const mockPassword = 'MyPa$Sword!'; | ||
const mockSuccessFullLoginResponse: InitiateAuthCommandOutput = { | ||
$metadata: {}, | ||
AuthenticationResult: { | ||
AccessToken: 'TEST_ACCESS_TOKEN', | ||
IdToken: 'TEST_ID_TOKEN', | ||
RefreshToken: 'TEST_REFRESH_TOKEN', | ||
}, | ||
const mockSuccessFullLoginResponse = { | ||
accessToken: 'TEST_ACCESS_TOKEN', | ||
idToken: 'TEST_ID_TOKEN', | ||
refreshToken: 'TEST_REFRESH_TOKEN', | ||
}; | ||
applicationContext | ||
.getUserGateway() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters