-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
138 additions
and
64 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
123 changes: 123 additions & 0 deletions
123
...gration-tests/src/__tests__/migration_tests_v12/auth-hosted-ui-lambda-migration-1.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,123 @@ | ||
import { allowedVersionsToMigrateFrom, versionCheck } from '../../migration-helpers'; | ||
import { | ||
addAuthUserPoolOnlyWithOAuth, | ||
AddAuthUserPoolOnlyWithOAuthSettings, | ||
amplifyPushAuth, | ||
amplifyPushForce, | ||
amplifyPushNonInteractive, | ||
createNewProjectDir, | ||
createUserPoolOnlyWithOAuthSettings, | ||
deleteProject, | ||
deleteProjectDir, | ||
generateRandomShortId, | ||
getHostedUIDomain, | ||
getProjectMeta, | ||
getUserPool, | ||
getUserPoolId, | ||
tryScheduleCredentialRefresh, | ||
updateAuthAddUserGroups, | ||
updateHeadlessAuth, | ||
} from '@aws-amplify/amplify-e2e-core'; | ||
import { initJSProjectWithProfileV12 } from '../../migration-helpers-v12/init'; | ||
import { UpdateAuthRequest } from 'amplify-headless-interface'; | ||
|
||
describe('amplify auth hosted ui', () => { | ||
beforeAll(async () => { | ||
tryScheduleCredentialRefresh(); | ||
|
||
const migrateFromVersion = { v: '12.0.3' }; | ||
const migrateToVersion = { v: 'uninitialized' }; | ||
|
||
await versionCheck(process.cwd(), false, migrateFromVersion); | ||
await versionCheck(process.cwd(), true, migrateToVersion); | ||
|
||
expect(allowedVersionsToMigrateFrom).toContain(migrateFromVersion.v); | ||
}); | ||
|
||
let projRoot: string; | ||
|
||
beforeEach(async () => { | ||
projRoot = await createNewProjectDir('hostedUIMigration'); | ||
}); | ||
|
||
afterEach(async () => { | ||
await deleteProject(projRoot, null, true); | ||
deleteProjectDir(projRoot); | ||
}); | ||
|
||
describe('project with hosted ui created by old version', () => { | ||
let oauthSettings: AddAuthUserPoolOnlyWithOAuthSettings; | ||
let originalUserPoolId: string; | ||
let originalHostedUIDomain: string; | ||
let region: string; | ||
beforeEach(async () => { | ||
oauthSettings = createUserPoolOnlyWithOAuthSettings('hui', generateRandomShortId()); | ||
await initJSProjectWithProfileV12(projRoot); | ||
await addAuthUserPoolOnlyWithOAuth(projRoot, oauthSettings); | ||
await amplifyPushAuth(projRoot); | ||
originalUserPoolId = getUserPoolId(projRoot); | ||
originalHostedUIDomain = getHostedUIDomain(projRoot); | ||
const meta = getProjectMeta(projRoot); | ||
region = meta.providers.awscloudformation.Region; | ||
expect(originalHostedUIDomain).toMatch(oauthSettings.domainPrefix); | ||
}); | ||
|
||
it('keeps hosted ui domain after force push with new version', async () => { | ||
await amplifyPushForce(projRoot, true); | ||
const userPoolId = getUserPoolId(projRoot); | ||
const hostedUIDomain = getHostedUIDomain(projRoot); | ||
|
||
expect(userPoolId).toEqual(originalUserPoolId); | ||
const userPoolRes = await getUserPool(userPoolId, region); | ||
expect(hostedUIDomain).toEqual(originalHostedUIDomain); | ||
expect(hostedUIDomain).toEqual(userPoolRes.UserPool.Domain); | ||
}); | ||
|
||
it('keeps hosted ui domain after update and push with new version', async () => { | ||
await updateAuthAddUserGroups(projRoot, ['group1', 'group2'], { testingWithLatestCodebase: true, updateUserPoolGroupsPosition: 5 }); | ||
await amplifyPushAuth(projRoot, true); | ||
const userPoolId = getUserPoolId(projRoot); | ||
const hostedUIDomain = getHostedUIDomain(projRoot); | ||
|
||
expect(userPoolId).toEqual(originalUserPoolId); | ||
const userPoolRes = await getUserPool(userPoolId, region); | ||
expect(hostedUIDomain).toEqual(originalHostedUIDomain); | ||
expect(hostedUIDomain).toEqual(userPoolRes.UserPool.Domain); | ||
}); | ||
|
||
it('keeps hosted ui domain after headless update and push with new version', async () => { | ||
const updateAuthRequest: UpdateAuthRequest = { | ||
version: 2, | ||
serviceModification: { | ||
serviceName: 'Cognito', | ||
userPoolModification: { | ||
autoVerifiedAttributes: [ | ||
{ | ||
type: 'EMAIL', | ||
}, | ||
], | ||
userPoolGroups: [ | ||
{ | ||
groupName: 'group1', | ||
}, | ||
{ | ||
groupName: 'group2', | ||
}, | ||
], | ||
}, | ||
includeIdentityPool: false, | ||
}, | ||
}; | ||
|
||
await updateHeadlessAuth(projRoot, updateAuthRequest, { testingWithLatestCodebase: true }); | ||
await amplifyPushNonInteractive(projRoot, true); | ||
const userPoolId = getUserPoolId(projRoot); | ||
const hostedUIDomain = getHostedUIDomain(projRoot); | ||
|
||
expect(userPoolId).toEqual(originalUserPoolId); | ||
const userPoolRes = await getUserPool(userPoolId, region); | ||
expect(hostedUIDomain).toEqual(originalHostedUIDomain); | ||
expect(hostedUIDomain).toEqual(userPoolRes.UserPool.Domain); | ||
}); | ||
}); | ||
}); |
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