mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(ssoadmin): serve Identity Center ListInstances (#2581)
* feat(sso): serve Identity Center ListInstances under SWBExternalService
LZA's Custom::GetIdentityCenterInstanceMetadata Lambda calls SSO Admin
ListInstances (target prefix SWBExternalService., the service's AWS-internal
codename, cf. config's StarlingDoveService) and requires exactly one instance
with InstanceArn and IdentityStoreId. Previously no descriptor matched the
target, so the call died with UnknownOperationException. Identifiers are
fixed constants so they survive restarts — LZA persists them into SSM
parameters between stages.
* fix(config): declare ssoadmin enabled toggle in both application.yml files
Upstream's ServiceConfigYamlCoverageTest requires every service config with an
enabled() toggle to declare it explicitly in both files; this branch predates
that test and fails it without the declaration.
* docs(ssoadmin): defer the single-op handler from action-table generation
* docs(ssoadmin): alias the sso descriptor to the IAM page
* fix(ssoadmin): report the caller's account as OwnerAccountId and assert the unsupported-operation error type
* fix(ssoadmin): use UnknownOperationException for unrecognized actions
Matches this codebase's JSON 1.1 dispatch convention (ServiceQuotas, Network
Firewall, and others already use it) and is a real modelled shape unlike the
bare UnsupportedOperation string, which has no Exception suffix and isn't in
sso-admin's error model.
* docs: correct service count to 79 after the #2579 merge
The upstream/main merge (8a4d9bd1b) added two new services
(servicequotas, ram) on top of this branch's own sso-admin
addition. The merge-base count was 76; three disjoint new services
(1 ours + 2 upstream) makes 79, not 78 as the merge commit left it.
This commit is contained in:
1 parent
47034394d1
commit
a2bd22d5f8
13 files changed
+190
-4
No files matched your search
+94
@@ -0,0 +1,94 @@
|
||||
package io.github.hectorvent.floci.services.ssoadmin;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
|
||||
/**
|
||||
* IAM Identity Center (SSO Admin, target prefix {@code SWBExternalService.}).
|
||||
*
|
||||
* <p>LZA's Custom::GetIdentityCenterInstanceMetadata Lambda calls {@code ListInstances} and
|
||||
* requires exactly one instance carrying {@code InstanceArn} and {@code IdentityStoreId}.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class SsoAdminIntegrationTest {
|
||||
|
||||
private static final String AUTH_HEADER =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/sso/aws4_request";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
void listInstances_returnsExactlyOneInstanceWithArnAndIdentityStore() {
|
||||
given()
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.header("X-Amz-Target", "SWBExternalService.ListInstances")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Instances.size()", equalTo(1))
|
||||
.body("Instances[0].InstanceArn", matchesPattern("arn:aws:sso:::instance/ssoins-[0-9a-f]{16}"))
|
||||
.body("Instances[0].IdentityStoreId", matchesPattern("d-[0-9a-f]{10}"))
|
||||
.body("Instances[0].Status", equalTo("ACTIVE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listInstances_isStableAcrossCalls() {
|
||||
String firstArn = listInstancesArn();
|
||||
String secondArn = listInstancesArn();
|
||||
org.junit.jupiter.api.Assertions.assertEquals(firstArn, secondArn);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownAction_returnsUnknownOperationException() {
|
||||
given()
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.header("X-Amz-Target", "SWBExternalService.DescribeInstance")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", org.hamcrest.Matchers.containsString("UnknownOperationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listInstances_ownerAccountIdTracksTheCaller() {
|
||||
given()
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.header("Authorization",
|
||||
"AWS4-HMAC-SHA256 Credential=111122223333/20260101/us-east-1/sso/aws4_request")
|
||||
.header("X-Amz-Target", "SWBExternalService.ListInstances")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Instances[0].OwnerAccountId", org.hamcrest.Matchers.equalTo("111122223333"));
|
||||
}
|
||||
|
||||
private static String listInstancesArn() {
|
||||
return given()
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.header("X-Amz-Target", "SWBExternalService.ListInstances")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("Instances[0].InstanceArn");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user