Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eighty-feet-go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/backend-auth': patch
---

Add unit tests for custom domain and cognito-managed domain OAuth scenarios
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,38 @@ void describe('ReferenceAuthInitializer', () => {
);
});

void it('handles custom domain with external login providers', async () => {
describeUserPoolResponse = {
...httpSuccess,
UserPool: {
...UserPool,
CustomDomain: 'auth.dev.example.com',
},
};
const result = await handler.handleEvent(createCfnEvent);
assert.strictEqual(result.Status, 'SUCCESS');
assert.ok(result.Data);
assert.strictEqual(result.Data.oauthCognitoDomain, 'auth.dev.example.com');
});

void it('handles cognito-managed domain with external login providers', async () => {
describeUserPoolResponse = {
...httpSuccess,
UserPool: {
...UserPool,
CustomDomain: undefined,
Domain: 'ref-auth-userpool-1',
},
};
const result = await handler.handleEvent(createCfnEvent);
assert.strictEqual(result.Status, 'SUCCESS');
assert.ok(result.Data);
assert.strictEqual(
result.Data.oauthCognitoDomain,
'ref-auth-userpool-1.auth.us-east-1.amazoncognito.com',
);
});

void it('throws if user pool group is not found', async () => {
listGroupsResponse = {
...httpSuccess,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ export class ReferenceAuthInitializer {

// domain
const oauthDomain = userPool.CustomDomain ?? userPool.Domain ?? '';
const fullDomainPath = `${oauthDomain}.auth.${region}.amazoncognito.com`;
const fullDomainPath = userPool.CustomDomain
? userPool.CustomDomain
: `${oauthDomain}.auth.${region}.amazoncognito.com`;
const data = {
signupAttributes: JSON.stringify(
userPool.SchemaAttributes?.filter(
Expand Down
Loading