forked from aws-amplify/amplify-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(amplify-category-auth): add auth verification mechanisms to fron…
…tend config (aws-amplify#8037) (aws-amplify#8093)
- Loading branch information
Showing
5 changed files
with
102 additions
and
19 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
46 changes: 46 additions & 0 deletions
46
...-cli/src/__tests__/extensions/amplify-helpers/ensure-amplify-meta-frontend-config.test.ts
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { JSONUtilities, stateManager } from 'amplify-cli-core'; | ||
import { ensureAmplifyMetaFrontendConfig } from '../../../extensions/amplify-helpers/on-category-outputs-change'; | ||
|
||
jest.mock('amplify-cli-core'); | ||
|
||
const stateManager_mock = stateManager as jest.Mocked<typeof stateManager>; | ||
stateManager_mock.getMeta.mockReturnValue({ auth: { authResource: { service: 'Cognito' } } }); | ||
stateManager_mock.getResourceParametersJson.mockReturnValue({ | ||
aliasAttributes: ['EMAIL'], | ||
requiredAttributes: ['EMAIL'], | ||
passwordPolicyMinLength: '10', | ||
mfaConfiguration: 'ON', | ||
mfaTypes: ['SMS Text Message'], | ||
}); | ||
|
||
const jsonUtilities_mock = JSONUtilities as jest.Mocked<typeof JSONUtilities>; | ||
jsonUtilities_mock.writeJson.mockImplementation(jest.fn()); | ||
|
||
describe('ensureAmplifyMetaFrontendConfig', () => { | ||
const mockContext = { | ||
amplify: { | ||
pathManager: { | ||
getAmplifyMetaFilePath: jest.fn(() => 'amplifyDirPath'), | ||
}, | ||
}, | ||
}; | ||
|
||
it('should add front end config to amplify meta', () => { | ||
ensureAmplifyMetaFrontendConfig(mockContext); | ||
expect(jsonUtilities_mock.writeJson).lastCalledWith(expect.anything(), { | ||
auth: { | ||
authResource: { | ||
frontendAuthConfig: { | ||
loginMechanisms: ['EMAIL'], | ||
mfaConfiguration: 'ON', | ||
mfaTypes: ['SMS'], | ||
passwordProtectionSettings: { passwordPolicyCharacters: [], passwordPolicyMinLength: '10' }, | ||
signupAttributes: ['EMAIL'], | ||
verificationMechanisms: [], | ||
}, | ||
service: 'Cognito', | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |
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