fix(cfn): support oauth and callback configurations in UserPoolClient (#1458)

This commit is contained in:
MAN$I VERMA authored and GitHub committed 2026-06-19 15:35:27 -05:00
1 parent ac8ae81909
commit 4bd43020d5
2 files changed
+157 -4

No files matched your search

@@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.matchesRegex;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
@@ -4717,6 +4718,107 @@ class CloudFormationIntegrationTest {
.statusCode(404);
}
@Test
void createStack_withCognitoUserPoolClientOAuthFlowsAndCallbacks() {
String template = """
{
"Resources": {
"Pool": {
"Type": "AWS::Cognito::UserPool",
"Properties": {
"UserPoolName": "cfn-oauth-test-pool"
}
},
"Client": {
"Type": "AWS::Cognito::UserPoolClient",
"Properties": {
"ClientName": "web-client",
"UserPoolId": {"Ref": "Pool"},
"AllowedOAuthFlows": ["implicit", "code"],
"AllowedOAuthFlowsUserPoolClient": true,
"AllowedOAuthScopes": ["openid", "profile", "email"],
"CallbackURLs": ["https://example.local/signin-redirect"],
"LogoutURLs": ["https://example.local"],
"SupportedIdentityProviders": ["COGNITO"],
"GenerateSecret": false
}
}
},
"Outputs": {
"PoolId": { "Value": { "Ref": "Pool" } },
"ClientId": { "Value": { "Ref": "Client" } }
}
}
""";
String stackName = "cognito-oauth-stack";
// 1. Create Stack
given()
.contentType("application/x-www-form-urlencoded")
.formParam("Action", "CreateStack")
.formParam("StackName", stackName)
.formParam("TemplateBody", template)
.when()
.post("/")
.then()
.statusCode(200)
.body(containsString("<StackId>"));
// 2. Describe Stacks and capture outputs
String describeXml = given()
.contentType("application/x-www-form-urlencoded")
.formParam("Action", "DescribeStacks")
.formParam("StackName", stackName)
.when()
.post("/")
.then()
.statusCode(200)
.body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"))
.extract().asString();
String poolId = describeXml.split("<OutputKey>PoolId</OutputKey>")[1].split("<OutputValue>")[1].split("</OutputValue>")[0];
String clientId = describeXml.split("<OutputKey>ClientId</OutputKey>")[1].split("<OutputValue>")[1].split("</OutputValue>")[0];
// 3. Verify UserPoolClient via Cognito API
given()
.header("X-Amz-Target", "AWSCognitoIdentityProviderService.DescribeUserPoolClient")
.contentType(COGNITO_CONTENT_TYPE)
.body("{\"UserPoolId\": \"" + poolId + "\", \"ClientId\": \"" + clientId + "\"}")
.when()
.post("/")
.then()
.statusCode(200)
.body("UserPoolClient.ClientName", equalTo("web-client"))
.body("UserPoolClient.UserPoolId", equalTo(poolId))
.body("UserPoolClient.AllowedOAuthFlowsUserPoolClient", equalTo(true))
.body("UserPoolClient.AllowedOAuthFlows", hasItems("implicit", "code"))
.body("UserPoolClient.AllowedOAuthScopes", hasItems("openid", "profile", "email"))
.body("UserPoolClient.CallbackURLs", hasItems("https://example.local/signin-redirect"))
.body("UserPoolClient.LogoutURLs", hasItems("https://example.local"))
.body("UserPoolClient.SupportedIdentityProviders", hasItems("COGNITO"));
// 4. Delete Stack
given()
.contentType("application/x-www-form-urlencoded")
.formParam("Action", "DeleteStack")
.formParam("StackName", stackName)
.when()
.post("/")
.then()
.statusCode(200);
// 5. Verify resources are deleted
given()
.header("X-Amz-Target", "AWSCognitoIdentityProviderService.DescribeUserPoolClient")
.contentType(COGNITO_CONTENT_TYPE)
.body("{\"UserPoolId\": \"" + poolId + "\", \"ClientId\": \"" + clientId + "\"}")
.when()
.post("/")
.then()
.statusCode(404);
}
@Test
void createStack_withNestedStack_resourcesAreProvisioned() {
String childTemplate = """