Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolk committed Jul 15, 2023
1 parent a1aa121 commit 73e93b3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/amplify-e2e-core/src/utils/sdk-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,20 @@ export const getSocialIdpProvider = async (
return res;
};

export const getUserPoolDomain = async (domain: string, region: string) => {
let res;
try {
res = await new CognitoIdentityServiceProvider({ region })
.describeUserPoolDomain({
Domain: domain,
})
.promise();
} catch (err) {
console.log(err);
}
return res;
};

export const getIdentityPoolRoles = async (identityPoolId: string, region: string) => {
let res;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import {
createUserPoolOnlyWithOAuthSettings,
deleteProject,
deleteProjectDir,
deleteUserPoolDomain,
generateRandomShortId,
getHostedUIDomain,
getProjectMeta,
getUserPool,
getUserPoolDomain,
getUserPoolId,
updateAuthAddUserGroups,
updateHeadlessAuth,
Expand Down Expand Up @@ -116,5 +118,54 @@ describe('amplify auth hosted ui', () => {
expect(hostedUIDomain).toEqual(originalHostedUIDomain);
expect(hostedUIDomain).toEqual(userPoolRes.UserPool.Domain);
});

it('updates hosted ui domain headless with new version and pushes', async () => {
const updatedDomainPrefix = `new-prefix-${generateRandomShortId()}`;
const updateAuthRequest: UpdateAuthRequest = {
version: 2,
serviceModification: {
serviceName: 'Cognito',
userPoolModification: {
autoVerifiedAttributes: [
{
type: 'EMAIL',
},
],
userPoolGroups: [
{
groupName: 'group1',
},
{
groupName: 'group2',
},
],
oAuth: {
domainPrefix: updatedDomainPrefix,
},
},
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).not.toEqual(originalHostedUIDomain);
expect(hostedUIDomain).toMatch(updatedDomainPrefix);
expect(hostedUIDomain).toEqual(userPoolRes.UserPool.Domain);

const updatedDomainRes = await getUserPoolDomain(hostedUIDomain, region);
expect(updatedDomainRes).toBeDefined();
const originalDomainRes = await getUserPoolDomain(originalHostedUIDomain, region);
expect(originalDomainRes).toEqual({ DomainDescription: {} });

const deleteOriginalDomainRes = await deleteUserPoolDomain(originalHostedUIDomain, userPoolId, region);
// undefined response as it throws InvalidParameterException: No such domain or user pool exists.
expect(deleteOriginalDomainRes).toBeUndefined();
});
});
});

0 comments on commit 73e93b3

Please sign in to comment.