feat(identity-center): complete IAM Identity Center emulation (#3331)

* feat(ssoadmin): add region operation

* feat(ssoadmin): attach customer managed policies

* feat(ssoadmin): create applications

* feat(ssoadmin): create application assignments

* feat(ssoadmin): create account instances

* feat(ssoadmin): create ABAC configuration

* feat(ssoadmin): create trusted token issuers

* feat(ssoadmin): delete account assignments

* feat(ssoadmin): delete applications

* feat(ssoadmin): delete application access scopes

* feat(ssoadmin): delete application assignments

* feat(ssoadmin): delete application authentication methods

* feat(ssoadmin): delete application grants

* feat(ssoadmin): delete identity center instances

* feat(ssoadmin): list principal account assignments

* feat(ssoadmin): provision permission sets

* feat(ssoadmin): list provisioned permission sets

* feat(ssoadmin): list accounts for provisioned permission set

* feat(ssoadmin): describe permission set provisioning status

* feat(ssoadmin): list permission set provisioning status

* feat(ssoadmin): describe account assignment deletion status

* feat(ssoadmin): list account assignment creation status

* feat(ssoadmin): list account assignment deletion status

* feat(ssoadmin): delete permission sets

* feat(ssoadmin): detach customer managed policy references

* feat(ssoadmin): list customer managed policy references

* feat(ssoadmin): get inline permission set policies

* feat(ssoadmin): put permission set boundaries

* feat(ssoadmin): get permission set boundaries

* feat(ssoadmin): delete permission set boundaries

* feat(scim): create groups

* feat(scim): create users

* feat(scim): delete groups

* feat(scim): delete users

* feat(scim): get groups

* feat(scim): get users

* feat(scim): list groups

* feat(scim): list users

* feat(scim): get schemas

* feat(scim): list schemas

* feat(scim): list resource types

* feat(scim): add service provider config

* feat(scim): patch groups

* feat(scim): patch users

* feat(scim): put users

* feat(ssoadmin): delete ABAC configuration

* feat(ssoadmin): delete trusted token issuers

* feat(ssoadmin): describe applications

* feat(ssoadmin): describe application assignments

* feat(ssoadmin): describe instances

* feat(ssoadmin): describe ABAC configuration

* feat(ssoadmin): describe regions

* feat(ssoadmin): describe trusted token issuers

* feat(ssoadmin): describe application providers

* feat(ssoadmin): list application assignments

* feat(ssoadmin): list principal application assignments

* feat(ssoadmin): list applications

* feat(ssoadmin): list application providers

* feat(ssoadmin): list regions

* feat(ssoadmin): list trusted token issuers

* feat(ssoadmin): put application access scopes

* feat(ssoadmin): get application access scopes

* feat: support listing application access scopes

* feat(ssoadmin): get application assignment configuration

* feat(ssoadmin): put application assignment configuration

* feat(ssoadmin): get application authentication methods

* feat(ssoadmin): put application authentication methods

* feat(ssoadmin): list application authentication methods

* feat(ssoadmin): get application grants

* feat(ssoadmin): put application grants

* feat(ssoadmin): list application grants

* feat(ssoadmin): get application session configuration

* feat(ssoadmin): put application session configuration

* feat(ssoadmin): list resource tags

* feat(ssoadmin): tag resources

* feat(ssoadmin): untag resources

* feat(ssoadmin): remove regions

* feat(ssoadmin): update applications

* feat(ssoadmin): update instances

* feat(ssoadmin): update ABAC configuration

* feat(ssoadmin): update trusted token issuers

* feat(ssooidc): register clients

* feat(ssooidc): start device authorization

* feat(ssooidc): create public client tokens

* feat(ssooidc): create IAM-authenticated tokens

* feat(ssoportal): list assigned accounts

* feat(ssoportal): list assigned account roles

* feat(ssoportal): issue assigned role credentials

* feat(ssoportal): invalidate portal sessions

* docs(ssoadmin): report complete operation count

* fix(identity-center): repair CI validation

* fix(identity-center): harden auth and native build

* fix(ssooidc): disambiguate RestAssured query parameter

* fix(identity-center): resolve CI compatibility failures

* fix(identity-center): address maintainer review

* fix(ssoadmin): preserve application provider partition

* fix(identity-center): repair Java compatibility tests

* fix(identity-center): trust local TLS in browser flows

* fix(identity-center): register refresh token grant in SDK test
This commit is contained in:
Franklin G. Mendoza authored and GitHub committed 2026-09-10 16:34:41 -04:00
1 parent 8624ccce83
commit cbfa034470
65 files changed
+12464 -40

No files matched your search

@@ -43,6 +43,12 @@ class CredentialScopeAliasTest {
assertEquals("iot", catalog.canonicalCredentialScope("iot-jobs-data"));
}
@Test
void ssoPortalAliasNormalisesToSso() {
assertEquals("sso", catalog.canonicalCredentialScope("awsssoportal"));
}
@Test
void canonicalScopeIsUnchanged() {
assertEquals("s3", catalog.canonicalCredentialScope("s3"));
@@ -76,7 +82,7 @@ class CredentialScopeAliasTest {
.filter(scope -> !scope.equals(catalog.canonicalCredentialScope(scope)))
.collect(Collectors.toMap(scope -> scope, catalog::canonicalCredentialScope));
assertEquals(Map.of("s3express", "s3", "iot-jobs-data", "iot"), rewritten);
assertEquals(Map.of("s3express", "s3", "iot-jobs-data", "iot", "awsssoportal", "sso"), rewritten);
}
@Test
@@ -0,0 +1,910 @@
package io.github.hectorvent.floci.services.identitystore;
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.hasItem;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@QuarkusTest
class ScimIntegrationTest {
private static final String TENANT = "9067f2a3c1-00000000-0000-0000-0000-000000000000";
private static final String STORE = "d-9067f2a3c1";
private static final String BEARER = "Bearer floci-scim-token";
private static final String AWS_AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260904/us-east-1/identitystore/aws4_request";
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void rejectsUnknownBearerToken() {
given()
.header("Authorization", "Bearer wrong-token")
.when()
.get("/" + TENANT + "/scim/v2/ServiceProviderConfig")
.then()
.statusCode(401)
.body("status", equalTo("401"));
}
@Test
void createGroupUsesAwsScimShapeAndPersistsToIdentityStore() {
String groupId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"701984\",\"displayName\":\"SCIM Platform Admins\"}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(201)
.body("schemas[0]", equalTo("urn:ietf:params:scim:schemas:core:2.0:Group"))
.body("id", notNullValue())
.body("externalId", equalTo("701984"))
.body("displayName", equalTo("SCIM Platform Admins"))
.body("meta.resourceType", equalTo("Group"))
.body("meta.created", notNullValue())
.body("meta.lastModified", notNullValue())
.extract().path("id");
given()
.contentType("application/x-amz-json-1.1")
.header("Authorization", AWS_AUTH)
.header("X-Amz-Target", "AWSIdentityStore.ListGroups")
.body("{\"IdentityStoreId\":\"" + STORE + "\"}")
.when()
.post("/")
.then()
.statusCode(200)
.body("Groups.GroupId", hasItem(groupId))
.body("Groups.DisplayName", hasItem("SCIM Platform Admins"));
}
@Test
void createUserUsesAwsScimShapeAndPersistsToIdentityStore() {
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"2819\",\"userName\":\"bjensen@example.com\","
+ "\"displayName\":\"Babs Jensen\",\"active\":true,"
+ "\"name\":{\"formatted\":\"Ms. Barbara J Jensen III\","
+ "\"familyName\":\"Jensen\",\"givenName\":\"Barbara\",\"middleName\":\"Jane\"},"
+ "\"emails\":[{\"value\":\"bjensen@example.com\",\"type\":\"work\",\"primary\":true}]}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.body("schemas[0]", equalTo("urn:ietf:params:scim:schemas:core:2.0:User"))
.body("id", notNullValue())
.body("externalId", equalTo("2819"))
.body("userName", equalTo("bjensen@example.com"))
.body("displayName", equalTo("Babs Jensen"))
.body("name.familyName", equalTo("Jensen"))
.body("name.givenName", equalTo("Barbara"))
.body("emails[0].value", equalTo("bjensen@example.com"))
.body("emails[0].primary", equalTo(true))
.body("active", equalTo(true))
.body("meta.resourceType", equalTo("User"))
.extract().path("id");
given()
.contentType("application/x-amz-json-1.1")
.header("Authorization", AWS_AUTH)
.header("X-Amz-Target", "AWSIdentityStore.DescribeUser")
.body("{\"IdentityStoreId\":\"" + STORE + "\",\"UserId\":\"" + userId + "\"}")
.when()
.post("/")
.then()
.statusCode(200)
.body("UserName", equalTo("bjensen@example.com"))
.body("DisplayName", equalTo("Babs Jensen"))
.body("Name.FamilyName", equalTo("Jensen"))
.body("Emails[0].Value", equalTo("bjensen@example.com"));
}
@Test
void createUserValidatesAwsUnsupportedAttributesAndRequiredFields() {
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"missing@example.com\",\"displayName\":\"Missing Name\"}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(400)
.body("status", equalTo("400"));
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"groups@example.com\",\"displayName\":\"Groups User\","
+ "\"name\":{\"givenName\":\"Groups\",\"familyName\":\"User\"},\"groups\":[]}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(400)
.body("status", equalTo("400"));
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"multi@example.com\",\"displayName\":\"Multi Email\","
+ "\"name\":{\"givenName\":\"Multi\",\"familyName\":\"Email\"},"
+ "\"emails\":[{\"value\":\"one@example.com\",\"primary\":true},"
+ "{\"value\":\"two@example.com\",\"primary\":true}]}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(400)
.body("status", equalTo("400"));
}
@Test
void getUserUsesAwsScimRepresentation() {
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"get-user-ext\",\"userName\":\"get@example.com\","
+ "\"displayName\":\"Get User\",\"name\":{\"givenName\":\"Get\",\"familyName\":\"User\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(200)
.body("schemas[0]", equalTo("urn:ietf:params:scim:schemas:core:2.0:User"))
.body("id", equalTo(userId))
.body("externalId", equalTo("get-user-ext"))
.body("userName", equalTo("get@example.com"))
.body("displayName", equalTo("Get User"))
.body("name.givenName", equalTo("Get"))
.body("name.familyName", equalTo("User"))
.body("meta.resourceType", equalTo("User"));
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Users/9067f2a3c1-00000000-0000-0000-0000-000000000098")
.then()
.statusCode(404)
.body("status", equalTo("404"));
}
@Test
void getGroupUsesAwsScimRepresentation() {
String groupId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"get-group-ext\",\"displayName\":\"SCIM Get Group\"}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(201)
.extract().path("id");
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Groups/" + groupId)
.then()
.statusCode(200)
.body("schemas[0]", equalTo("urn:ietf:params:scim:schemas:core:2.0:Group"))
.body("id", equalTo(groupId))
.body("externalId", equalTo("get-group-ext"))
.body("displayName", equalTo("SCIM Get Group"))
.body("meta.resourceType", equalTo("Group"))
.body("meta.created", notNullValue())
.body("meta.lastModified", notNullValue());
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Groups/9067f2a3c1-00000000-0000-0000-0000-000000000099")
.then()
.statusCode(404)
.body("status", equalTo("404"));
}
@Test
void deleteUserUsesAwsScimStatusAndRemovesIdentityStoreResource() {
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"delete@example.com\",\"displayName\":\"Delete User\","
+ "\"name\":{\"givenName\":\"Delete\",\"familyName\":\"User\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
given()
.header("Authorization", BEARER)
.when()
.delete("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(204);
given()
.header("Authorization", BEARER)
.when()
.delete("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(404)
.body("status", equalTo("404"));
}
@Test
void deleteGroupUsesAwsScimStatusAndRemovesIdentityStoreResource() {
String groupId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"displayName\":\"SCIM Delete Me\"}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(201)
.extract().path("id");
given()
.header("Authorization", BEARER)
.when()
.delete("/" + TENANT + "/scim/v2/Groups/" + groupId)
.then()
.statusCode(204);
given()
.header("Authorization", BEARER)
.when()
.delete("/" + TENANT + "/scim/v2/Groups/" + groupId)
.then()
.statusCode(404)
.body("status", equalTo("404"));
}
@Test
void createGroupRequiresBearerAndKnownTenant() {
given()
.contentType("application/json")
.body("{\"displayName\":\"Unauthorized Group\"}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(401)
.body("schemas[0]", equalTo("urn:ietf:params:scim:api:messages:2.0:Error"))
.body("status", equalTo("401"));
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"displayName\":\"Wrong Tenant Group\"}")
.when()
.post("/aaaaaaaaaa-00000000-0000-0000-0000-000000000000/scim/v2/Groups")
.then()
.statusCode(401)
.body("status", equalTo("401"));
}
@Test
void createGroupValidatesRequiredDisplayNameAndMemberLimit() {
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(400)
.body("status", equalTo("400"));
StringBuilder members = new StringBuilder("[\n");
for (int i = 0; i < 101; i++) {
if (i > 0) {
members.append(',');
}
members.append("{\"value\":\"11111111-2222-3333-4444-")
.append(String.format("%012d", i))
.append("\"}");
}
members.append(']');
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"displayName\":\"Too Many Members\",\"members\":" + members + "}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(400)
.body("status", equalTo("400"));
}
@Test
void putUserOverwritesExistingUserAndPreservesResourceIdentity() {
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"put-user-old\",\"userName\":\"put-user-old@example.com\","
+ "\"displayName\":\"Put User Old\",\"nickName\":\"OldNick\","
+ "\"name\":{\"givenName\":\"Put\",\"familyName\":\"Old\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
String createdAt = given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(200)
.extract().path("meta.created");
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"id\":\"" + userId + "\",\"externalId\":\"put-user-new\","
+ "\"userName\":\"put-user-new@example.com\",\"displayName\":\"Put User New\","
+ "\"name\":{\"formatted\":\"Put User New\",\"givenName\":\"Put\",\"familyName\":\"New\"},"
+ "\"emails\":[{\"value\":\"put-user-new@example.com\",\"type\":\"work\",\"primary\":true}],"
+ "\"active\":false,\"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User\":{"
+ "\"department\":\"Platform\",\"manager\":{\"value\":\"9067f2a3c1-00000000-0000-0000-0000-000000000077\","
+ "\"$ref\":\"../Users/9067f2a3c1-00000000-0000-0000-0000-000000000077\"}}}")
.when()
.put("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(201)
.body("id", equalTo(userId))
.body("externalId", equalTo("put-user-new"))
.body("userName", equalTo("put-user-new@example.com"))
.body("displayName", equalTo("Put User New"))
.body("nickName", nullValue())
.body("active", equalTo(false))
.body("emails[0].value", equalTo("put-user-new@example.com"))
.body("meta.created", equalTo(createdAt))
.body("'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User'.department", equalTo("Platform"))
.body("'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User'.manager.value",
equalTo("9067f2a3c1-00000000-0000-0000-0000-000000000077"));
given()
.contentType("application/x-amz-json-1.1")
.header("Authorization", AWS_AUTH)
.header("X-Amz-Target", "AWSIdentityStore.DescribeUser")
.body("{\"IdentityStoreId\":\"" + STORE + "\",\"UserId\":\"" + userId + "\"}")
.when()
.post("/")
.then()
.statusCode(200)
.body("UserName", equalTo("put-user-new@example.com"))
.body("DisplayName", equalTo("Put User New"))
.body("NickName", nullValue())
.body("UserStatus", equalTo("DISABLED"));
}
@Test
void putUserRejectsInvalidReplacementAndConflictingUserName() {
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"put-target@example.com\",\"displayName\":\"Put Target\","
+ "\"name\":{\"givenName\":\"Put\",\"familyName\":\"Target\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"put-conflict@example.com\",\"displayName\":\"Put Conflict\","
+ "\"name\":{\"givenName\":\"Put\",\"familyName\":\"Conflict\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201);
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"put-target@example.com\",\"displayName\":\"Missing Name\"}")
.when()
.put("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(400)
.body("status", equalTo("400"));
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"put-conflict@example.com\",\"displayName\":\"Put Target Conflict\","
+ "\"name\":{\"givenName\":\"Put\",\"familyName\":\"Target\"}}")
.when()
.put("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(409)
.body("status", equalTo("409"));
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(200)
.body("userName", equalTo("put-target@example.com"))
.body("displayName", equalTo("Put Target"));
}
@Test
void patchUserUpdatesSupportedAttributesAndReturnsUser() {
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"patch-user-old\",\"userName\":\"patch-user@example.com\","
+ "\"displayName\":\"Patch User Old\","
+ "\"name\":{\"givenName\":\"Patch\",\"familyName\":\"User\"},"
+ "\"emails\":[{\"value\":\"old@example.com\",\"primary\":true}]}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":["
+ "{\"op\":\"replace\",\"path\":\"active\",\"value\":\"false\"},"
+ "{\"op\":\"replace\",\"value\":{\"displayName\":\"Patch User New\","
+ "\"externalId\":\"patch-user-new\"}},"
+ "{\"op\":\"replace\",\"path\":\"emails\",\"value\":["
+ "{\"value\":\"new@example.com\",\"type\":\"work\",\"primary\":true}]}]}")
.when()
.patch("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(200)
.body("id", equalTo(userId))
.body("active", equalTo(false))
.body("displayName", equalTo("Patch User New"))
.body("externalId", equalTo("patch-user-new"))
.body("emails[0].value", equalTo("new@example.com"));
}
@Test
void patchUserRejectsUnsupportedAndRepeatedProtectedChanges() {
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"patch-user-validation@example.com\",\"displayName\":\"Patch Validation\","
+ "\"name\":{\"givenName\":\"Patch\",\"familyName\":\"Validation\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":["
+ "{\"op\":\"replace\",\"path\":\"active\",\"value\":true},"
+ "{\"op\":\"replace\",\"path\":\"active\",\"value\":false}]}")
.when()
.patch("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(400)
.body("status", equalTo("400"));
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":["
+ "{\"op\":\"remove\",\"path\":\"active\"}]}")
.when()
.patch("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(400)
.body("status", equalTo("400"));
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":["
+ "{\"op\":\"replace\",\"path\":\"password\",\"value\":\"nope\"}]}")
.when()
.patch("/" + TENANT + "/scim/v2/Users/" + userId)
.then()
.statusCode(400)
.body("status", equalTo("400"));
}
@Test
void patchGroupUpdatesAttributesAndMemberships() {
String firstUserId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"patch-group-one@example.com\",\"displayName\":\"Patch One\","
+ "\"name\":{\"givenName\":\"Patch\",\"familyName\":\"One\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
String secondUserId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"patch-group-two@example.com\",\"displayName\":\"Patch Two\","
+ "\"name\":{\"givenName\":\"Patch\",\"familyName\":\"Two\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
String groupId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"patch-group-old\",\"displayName\":\"Patch Group Old\","
+ "\"members\":[{\"value\":\"" + firstUserId + "\"}]}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(201)
.extract().path("id");
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":["
+ "{\"op\":\"replace\",\"path\":\"displayName\",\"value\":\"Patch Group New\"},"
+ "{\"op\":\"replace\",\"path\":\"externalId\",\"value\":\"patch-group-new\"},"
+ "{\"op\":\"add\",\"path\":\"members\",\"value\":[{\"value\":\"" + secondUserId + "\"}]},"
+ "{\"op\":\"remove\",\"path\":\"members\",\"value\":[{\"value\":\"" + firstUserId + "\"}]}]}")
.when()
.patch("/" + TENANT + "/scim/v2/Groups/" + groupId)
.then()
.statusCode(204);
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Groups/" + groupId)
.then()
.statusCode(200)
.body("displayName", equalTo("Patch Group New"))
.body("externalId", equalTo("patch-group-new"));
given()
.header("Authorization", BEARER)
.queryParam("filter", "members.value eq \"" + secondUserId + "\"")
.when()
.get("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(200)
.body("Resources.id", hasItem(groupId));
given()
.header("Authorization", BEARER)
.queryParam("filter", "members.value eq \"" + firstUserId + "\"")
.when()
.get("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(200)
.body("totalResults", equalTo(0));
}
@Test
void patchGroupRejectsUnsupportedOrBulkMembershipChanges() {
String groupId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"displayName\":\"Patch Group Validation\"}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(201)
.extract().path("id");
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],"
+ "\"Operations\":[{\"op\":\"remove\",\"path\":\"members\",\"value\":[]}]}")
.when()
.patch("/" + TENANT + "/scim/v2/Groups/" + groupId)
.then()
.statusCode(400)
.body("status", equalTo("400"));
given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],"
+ "\"Operations\":[{\"op\":\"replace\",\"path\":\"description\",\"value\":\"nope\"}]}")
.when()
.patch("/" + TENANT + "/scim/v2/Groups/" + groupId)
.then()
.statusCode(400)
.body("status", equalTo("400"));
}
@Test
void serviceProviderConfigMatchesAwsScimCapabilities() {
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/ServiceProviderConfig")
.then()
.statusCode(200)
.body("schemas[0]", equalTo("urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"))
.body("authenticationSchemes[0].type", equalTo("oauthbearertoken"))
.body("authenticationSchemes[0].primary", equalTo(true))
.body("patch.supported", equalTo(true))
.body("bulk.supported", equalTo(false))
.body("bulk.maxOperations", equalTo(1))
.body("bulk.maxPayloadSize", equalTo(1048576))
.body("filter.supported", equalTo(true))
.body("filter.maxResults", equalTo(50))
.body("changePassword.supported", equalTo(false))
.body("sort.supported", equalTo(false))
.body("etag.supported", equalTo(false));
}
@Test
void listResourceTypesReturnsAwsScimCatalog() {
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/ResourceTypes")
.then()
.statusCode(200)
.body("schemas[0]", equalTo("urn:ietf:params:scim:api:messages:2.0:ListResponse"))
.body("totalResults", equalTo(2))
.body("itemsPerPage", equalTo(2))
.body("startIndex", equalTo(1))
.body("Resources.id", hasItem("User"))
.body("Resources.id", hasItem("Group"))
.body("Resources.find { it.id == 'User' }.endpoint", equalTo("/Users"))
.body("Resources.find { it.id == 'User' }.schema", equalTo("urn:ietf:params:scim:schemas:core:2.0:User"))
.body("Resources.find { it.id == 'User' }.schemaExtensions[0].schema",
equalTo("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"))
.body("Resources.find { it.id == 'User' }.schemaExtensions[0].required", equalTo(true))
.body("Resources.find { it.id == 'User' }.meta.resourceType", equalTo("ResourceType"))
.body("Resources.find { it.id == 'User' }.meta.location", notNullValue());
}
@Test
void listSchemasReturnsAwsScimCatalog() {
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Schemas")
.then()
.statusCode(200)
.body("schemas[0]", equalTo("urn:ietf:params:scim:api:messages:2.0:ListResponse"))
.body("totalResults", equalTo(3))
.body("itemsPerPage", equalTo(3))
.body("startIndex", equalTo(1))
.body("Resources.id", hasItem("urn:ietf:params:scim:schemas:core:2.0:User"))
.body("Resources.id", hasItem("urn:ietf:params:scim:schemas:core:2.0:Group"))
.body("Resources.id", hasItem("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"));
}
@Test
void getSchemaReturnsAwsScimSchema() {
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Schemas/urn:ietf:params:scim:schemas:core:2.0:User")
.then()
.statusCode(200)
.body("id", equalTo("urn:ietf:params:scim:schemas:core:2.0:User"))
.body("name", equalTo("User"))
.body("description", equalTo("User Schema"))
.body("attributes.name", hasItem("userName"))
.body("attributes.find { it.name == 'userName' }.required", equalTo(true));
given()
.header("Authorization", BEARER)
.when()
.get("/" + TENANT + "/scim/v2/Schemas/urn:example:missing")
.then()
.statusCode(404)
.body("status", equalTo("404"));
}
@Test
void listUsersSupportsAwsFiltersAndCursorPagination() {
String managerId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"manager-list@example.com\",\"displayName\":\"List Manager\","
+ "\"name\":{\"givenName\":\"List\",\"familyName\":\"Manager\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"list-users-ext\",\"userName\":\"list-users@example.com\","
+ "\"displayName\":\"SCIM List Users Target\","
+ "\"name\":{\"givenName\":\"List\",\"familyName\":\"Users\"},"
+ "\"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User\":{"
+ "\"manager\":{\"value\":\"" + managerId + "\"}}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
String groupId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"displayName\":\"SCIM List Users Group\",\"members\":[{\"value\":\""
+ userId + "\",\"type\":\"User\"}]}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(201)
.extract().path("id");
given()
.header("Authorization", BEARER)
.queryParam("filter", "userName eq \"list-users@example.com\"")
.when()
.get("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(200)
.body("totalResults", equalTo(1))
.body("Resources[0].id", equalTo(userId));
given()
.header("Authorization", BEARER)
.queryParam("filter", "groups.value eq \"" + groupId + "\"")
.when()
.get("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(200)
.body("Resources.id", hasItem(userId));
given()
.header("Authorization", BEARER)
.queryParam("filter", "id eq \"" + userId + "\" and manager eq \"" + managerId + "\"")
.when()
.get("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(200)
.body("totalResults", equalTo(1))
.body("Resources[0].id", equalTo(userId));
String nextCursor = given()
.header("Authorization", BEARER)
.queryParam("cursor", "")
.queryParam("count", 1)
.when()
.get("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(200)
.body("itemsPerPage", equalTo(1))
.body("totalResults", org.hamcrest.Matchers.nullValue())
.body("startIndex", org.hamcrest.Matchers.nullValue())
.body("nextCursor", notNullValue())
.extract().path("nextCursor");
given()
.header("Authorization", BEARER)
.queryParam("cursor", nextCursor)
.queryParam("filter", "userName eq \"changed@example.com\"")
.when()
.get("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(400)
.body("status", equalTo("400"));
}
@Test
void listGroupsSupportsAwsFiltersAndCursorPagination() {
String userId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"userName\":\"list-groups@example.com\",\"displayName\":\"List Groups User\","
+ "\"name\":{\"givenName\":\"List\",\"familyName\":\"Groups\"}}")
.when()
.post("/" + TENANT + "/scim/v2/Users")
.then()
.statusCode(201)
.extract().path("id");
String groupId = given()
.contentType("application/json")
.header("Authorization", BEARER)
.body("{\"externalId\":\"list-groups-ext\",\"displayName\":\"SCIM List Groups Target\","
+ "\"members\":[{\"value\":\"" + userId + "\",\"type\":\"User\"}]}")
.when()
.post("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(201)
.extract().path("id");
given()
.header("Authorization", BEARER)
.queryParam("filter", "displayName eq \"SCIM List Groups Target\"")
.when()
.get("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(200)
.body("schemas[0]", equalTo("urn:ietf:params:scim:api:messages:2.0:ListResponse"))
.body("totalResults", equalTo(1))
.body("itemsPerPage", equalTo(1))
.body("startIndex", equalTo(1))
.body("Resources[0].id", equalTo(groupId));
given()
.header("Authorization", BEARER)
.queryParam("filter", "members.value eq \"" + userId + "\"")
.when()
.get("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(200)
.body("Resources.id", hasItem(groupId));
given()
.header("Authorization", BEARER)
.queryParam("filter", "id eq \"" + groupId + "\" and member eq \"" + userId + "\"")
.when()
.get("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(200)
.body("totalResults", equalTo(1))
.body("Resources[0].id", equalTo(groupId));
String nextCursor = given()
.header("Authorization", BEARER)
.queryParam("cursor", "")
.queryParam("count", 1)
.when()
.get("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(200)
.body("itemsPerPage", equalTo(1))
.body("totalResults", org.hamcrest.Matchers.nullValue())
.body("startIndex", org.hamcrest.Matchers.nullValue())
.body("nextCursor", notNullValue())
.extract().path("nextCursor");
given()
.header("Authorization", BEARER)
.queryParam("cursor", nextCursor)
.queryParam("count", 1)
.when()
.get("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(200)
.body("itemsPerPage", equalTo(1));
given()
.header("Authorization", BEARER)
.queryParam("cursor", nextCursor)
.queryParam("filter", "displayName eq \"changed\"")
.when()
.get("/" + TENANT + "/scim/v2/Groups")
.then()
.statusCode(400)
.body("status", equalTo("400"));
}
}
@@ -29,7 +29,7 @@ class SsoAdminAssignmentsIntegrationTest {
.then().statusCode(200).body("PermissionSet.PermissionSetArn", notNullValue())
.extract().path("PermissionSet.PermissionSetArn");
json("SWBExternalService.ListPermissionSets", "{\"InstanceArn\":\"" + instanceArn + "\"}")
.then().statusCode(200).body("PermissionSets", hasSize(1));
.then().statusCode(200).body("PermissionSets", org.hamcrest.Matchers.hasItem(permissionSetArn));
String assignment = "{\"InstanceArn\":\"" + instanceArn
+ "\",\"TargetId\":\"123456789012\",\"TargetType\":\"AWS_ACCOUNT\",\"PermissionSetArn\":\""
@@ -38,13 +38,76 @@ class SsoAdminAssignmentsIntegrationTest {
.then().statusCode(200).extract().path("AccountAssignmentCreationStatus.RequestId");
json("SWBExternalService.DescribeAccountAssignmentCreationStatus",
"{\"InstanceArn\":\"" + instanceArn + "\",\"AccountAssignmentCreationRequestId\":\"" + requestId + "\"}")
.then().statusCode(200).body("AccountAssignmentCreationStatus.Status", equalTo("SUCCEEDED"));
.then().statusCode(200)
.body("AccountAssignmentCreationStatus.Status", equalTo("SUCCEEDED"))
.body("AccountAssignmentCreationStatus.CreatedDate", notNullValue());
json("SWBExternalService.ListAccountAssignmentCreationStatus",
"{\"InstanceArn\":\"" + instanceArn + "\",\"Filter\":{\"Status\":\"SUCCEEDED\"}}")
.then().statusCode(200)
.body("AccountAssignmentsCreationStatus.RequestId", org.hamcrest.Matchers.hasItem(requestId));
json("SWBExternalService.ListAccountAssignments",
"{\"InstanceArn\":\"" + instanceArn + "\",\"AccountId\":\"123456789012\",\"PermissionSetArn\":\""
+ permissionSetArn + "\"}")
.then().statusCode(200).body("AccountAssignments[0].PrincipalType", equalTo("GROUP"));
}
@Test
void deletePermissionSetReturnsEmptyResponseAndRemovesIt() {
String instanceArn = json("SWBExternalService.ListInstances", "{}")
.then().statusCode(200).extract().path("Instances[0].InstanceArn");
String permissionSetArn = json("SWBExternalService.CreatePermissionSet",
"{\"InstanceArn\":\"" + instanceArn + "\",\"Name\":\"DeletePermissionSetIntegration\"}")
.then().statusCode(200).extract().path("PermissionSet.PermissionSetArn");
json("SWBExternalService.DeletePermissionSet",
"{\"InstanceArn\":\"" + instanceArn + "\",\"PermissionSetArn\":\"" + permissionSetArn + "\"}")
.then().statusCode(200).body(equalTo(""));
json("SWBExternalService.DescribePermissionSet",
"{\"InstanceArn\":\"" + instanceArn + "\",\"PermissionSetArn\":\"" + permissionSetArn + "\"}")
.then().statusCode(400).body("__type", equalTo("ResourceNotFoundException"));
}
@Test
void detachCustomerManagedPolicyReferenceReturnsEmptyResponse() {
String instanceArn = json("SWBExternalService.ListInstances", "{}")
.then().statusCode(200).extract().path("Instances[0].InstanceArn");
String permissionSetArn = json("SWBExternalService.CreatePermissionSet",
"{\"InstanceArn\":\"" + instanceArn + "\",\"Name\":\"DetachCustomerPolicyIntegration\"}")
.then().statusCode(200).extract().path("PermissionSet.PermissionSetArn");
String body = "{\"InstanceArn\":\"" + instanceArn + "\",\"PermissionSetArn\":\"" + permissionSetArn
+ "\",\"CustomerManagedPolicyReference\":{\"Name\":\"PlatformPolicy\",\"Path\":\"/platform/\"}}";
json("SWBExternalService.AttachCustomerManagedPolicyReferenceToPermissionSet", body)
.then().statusCode(200);
json("SWBExternalService.ListCustomerManagedPolicyReferencesInPermissionSet",
"{\"InstanceArn\":\"" + instanceArn + "\",\"PermissionSetArn\":\"" + permissionSetArn + "\"}")
.then().statusCode(200)
.body("CustomerManagedPolicyReferences[0].Name", equalTo("PlatformPolicy"))
.body("CustomerManagedPolicyReferences[0].Path", equalTo("/platform/"));
json("SWBExternalService.DetachCustomerManagedPolicyReferenceFromPermissionSet", body)
.then().statusCode(200).body(equalTo(""));
}
@Test
void putPermissionsBoundaryReturnsEmptyResponse() {
String instanceArn = json("SWBExternalService.ListInstances", "{}")
.then().statusCode(200).extract().path("Instances[0].InstanceArn");
String permissionSetArn = json("SWBExternalService.CreatePermissionSet",
"{\"InstanceArn\":\"" + instanceArn + "\",\"Name\":\"BoundaryIntegration\"}")
.then().statusCode(200).extract().path("PermissionSet.PermissionSetArn");
String body = "{\"InstanceArn\":\"" + instanceArn + "\",\"PermissionSetArn\":\"" + permissionSetArn
+ "\",\"PermissionsBoundary\":{\"ManagedPolicyArn\":\"arn:aws:iam::aws:policy/PowerUserAccess\"}}";
json("SWBExternalService.PutPermissionsBoundaryToPermissionSet", body)
.then().statusCode(200).body(equalTo(""));
String getBody = "{\"InstanceArn\":\"" + instanceArn + "\",\"PermissionSetArn\":\"" + permissionSetArn + "\"}";
json("SWBExternalService.GetPermissionsBoundaryForPermissionSet", getBody)
.then().statusCode(200)
.body("PermissionsBoundary.ManagedPolicyArn", equalTo("arn:aws:iam::aws:policy/PowerUserAccess"));
json("SWBExternalService.DeletePermissionsBoundaryFromPermissionSet", getBody)
.then().statusCode(200).body(equalTo(""));
json("SWBExternalService.GetPermissionsBoundaryForPermissionSet", getBody)
.then().statusCode(400).body("__type", equalTo("ResourceNotFoundException"));
}
@Test
void invalidAssignmentRequestIdReturnsResourceNotFound() {
String instanceArn = json("SWBExternalService.ListInstances", "{}")
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,219 @@
package io.github.hectorvent.floci.services.ssooidc;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.services.ssoadmin.SsoAdminService;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.matchesPattern;
@QuarkusTest
class SsoOidcIntegrationTest {
private static final String AUTH_HEADER =
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/sso-oauth/aws4_request";
@Inject
SsoAdminService ssoAdminService;
@Inject
SsoOidcService ssoOidcService;
@Inject
ObjectMapper mapper;
@Test
void registerClientReturnsAwsOidcShapeWithoutSigV4() {
given()
.contentType("application/json")
.body("{\"clientName\":\"Floci CLI\",\"clientType\":\"public\","
+ "\"grantTypes\":[\"authorization_code\",\"refresh_token\"],"
+ "\"redirectUris\":[\"http://127.0.0.1:8400/callback\"],"
+ "\"scopes\":[\"sso:account:access\"]}")
.when().post("/client/register")
.then().statusCode(200)
.body("clientId", matchesPattern("[0-9a-f]{32}"))
.body("clientSecret", matchesPattern("[0-9a-f]{64}"))
.body("clientIdIssuedAt", greaterThan(0))
.body("clientSecretExpiresAt", greaterThan(0))
.body("authorizationEndpoint", equalTo("http://localhost:4566/authorize"))
.body("tokenEndpoint", equalTo("http://localhost:4566/token"));
}
@Test
void startDeviceAuthorizationUsesRegisteredClient() {
var registration = given()
.contentType("application/json")
.body("{\"clientName\":\"Device Integration\",\"clientType\":\"public\","
+ "\"grantTypes\":[\"urn:ietf:params:oauth:grant-type:device_code\"]}")
.when().post("/client/register")
.then().statusCode(200)
.extract().response();
String clientId = registration.path("clientId");
String clientSecret = registration.path("clientSecret");
given()
.contentType("application/json")
.body("{\"clientId\":\"" + clientId + "\",\"clientSecret\":\"" + clientSecret
+ "\",\"startUrl\":\"https://example.awsapps.com/start\"}")
.when().post("/device_authorization")
.then().statusCode(200)
.body("deviceCode", matchesPattern("[0-9a-f]{64}"))
.body("userCode", matchesPattern("[0-9A-F]{4}-[0-9A-F]{4}"))
.body("verificationUri", equalTo("http://localhost:4566/device"))
.body("expiresIn", greaterThan(0))
.body("interval", equalTo(5));
given()
.contentType("application/json")
.body("{\"clientId\":\"" + clientId + "\",\"clientSecret\":\"wrong\","
+ "\"startUrl\":\"https://example.awsapps.com/start\"}")
.when().post("/device_authorization")
.then().statusCode(401)
.body("error", equalTo("invalid_client"));
}
@Test
void deviceAuthorizationRejectsCallerSelectedPrincipal() {
var registration = given()
.contentType("application/json")
.body("{\"clientName\":\"Principal Guard\",\"clientType\":\"public\","
+ "\"grantTypes\":[\"urn:ietf:params:oauth:grant-type:device_code\"]}")
.when().post("/client/register")
.then().statusCode(200)
.extract().response();
var authorization = given()
.contentType("application/json")
.body("{\"clientId\":\"" + registration.path("clientId") + "\",\"clientSecret\":\""
+ registration.path("clientSecret") + "\",\"startUrl\":\"https://example.awsapps.com/start\"}")
.when().post("/device_authorization")
.then().statusCode(200)
.extract().response();
String userCode = authorization.path("userCode");
given()
.queryParam("user_code", userCode)
.queryParam("principal_id", "11111111-2222-3333-4444-555555555555")
.when().get("/device")
.then().statusCode(403)
.body("error", equalTo("access_denied"));
}
@Test
void createTokenCompletesDeviceFlowAndRefreshesToken() {
var registration = given()
.contentType("application/json")
.body("{\"clientName\":\"Token Integration\",\"clientType\":\"public\","
+ "\"grantTypes\":[\"urn:ietf:params:oauth:grant-type:device_code\",\"refresh_token\"]}")
.when().post("/client/register")
.then().statusCode(200)
.extract().response();
String clientId = registration.path("clientId");
String clientSecret = registration.path("clientSecret");
var authorization = given()
.contentType("application/json")
.body("{\"clientId\":\"" + clientId + "\",\"clientSecret\":\"" + clientSecret
+ "\",\"startUrl\":\"https://example.awsapps.com/start\"}")
.when().post("/device_authorization")
.then().statusCode(200)
.extract().response();
String deviceCode = authorization.path("deviceCode");
String userCode = authorization.path("userCode");
given().queryParam("user_code", userCode)
.when().get("/device")
.then().statusCode(200).body("status", equalTo("authorized"));
var token = given()
.contentType("application/json")
.body("{\"clientId\":\"" + clientId + "\",\"clientSecret\":\"" + clientSecret
+ "\",\"grantType\":\"urn:ietf:params:oauth:grant-type:device_code\","
+ "\"deviceCode\":\"" + deviceCode + "\"}")
.when().post("/token")
.then().statusCode(200)
.body("tokenType", equalTo("Bearer"))
.body("accessToken", matchesPattern("[0-9a-f]{64}"))
.extract().response();
String refreshToken = token.path("refreshToken");
given()
.contentType("application/json")
.body("{\"clientId\":\"" + clientId + "\",\"clientSecret\":\"" + clientSecret
+ "\",\"grantType\":\"refresh_token\",\"refreshToken\":\"" + refreshToken + "\"}")
.when().post("/token")
.then().statusCode(200)
.body("tokenType", equalTo("Bearer"));
}
@Test
void createTokenWithIamRequiresSigV4AndUsesApplicationPolicy() {
String instanceArn = ssoAdminService.getInstanceArn();
var create = mapper.createObjectNode();
create.put("InstanceArn", instanceArn);
create.put("ApplicationProviderArn", "arn:aws:sso::aws:applicationProvider/custom");
create.put("Name", "IAM OIDC Integration");
String applicationArn = ssoAdminService.createApplication(create, "000000000000", "us-east-1").applicationArn();
var authentication = mapper.createObjectNode();
authentication.put("ApplicationArn", applicationArn);
authentication.put("AuthenticationMethodType", "IAM");
var policy = authentication.putObject("AuthenticationMethod").putObject("Iam").putObject("ActorPolicy");
policy.put("Version", "2012-10-17");
var statement = policy.putArray("Statement").addObject();
statement.put("Effect", "Allow");
statement.put("Principal", "*");
statement.put("Action", "sso-oauth:CreateTokenWithIAM");
statement.put("Resource", "*");
ssoAdminService.putApplicationAuthenticationMethod(authentication);
String redirectUri = "http://127.0.0.1:8400/iam-callback";
var grant = mapper.createObjectNode();
grant.put("ApplicationArn", applicationArn);
grant.put("GrantType", "authorization_code");
grant.putObject("Grant").putObject("AuthorizationCode").putArray("RedirectUris").add(redirectUri);
ssoAdminService.putApplicationGrant(grant);
String verifier = "01234567890123456789012345678901234567890123456789";
String challenge = java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(sha256(verifier));
String code = ssoOidcService.createIamAuthorizationCode(applicationArn, redirectUri, challenge,
java.util.List.of(redirectUri)).code();
String body = "{\"clientId\":\"" + applicationArn + "\",\"grantType\":\"authorization_code\","
+ "\"code\":\"" + code + "\",\"codeVerifier\":\"" + verifier + "\","
+ "\"redirectUri\":\"" + redirectUri + "\",\"scope\":[\"openid\"]}";
given().contentType("application/json").body(body)
.when().post("/token?aws_iam=t")
.then().statusCode(400).body("error", equalTo("access_denied"));
given().contentType("application/json").header("Authorization", AUTH_HEADER).body(body)
.when().post("/token?aws_iam=t")
.then().statusCode(200)
.body("tokenType", equalTo("Bearer"))
.body("scope[0]", equalTo("openid"))
.body("accessToken", matchesPattern("[0-9a-f]{64}"))
.body("idToken", org.hamcrest.Matchers.not(org.hamcrest.Matchers.blankOrNullString()))
.body("awsAdditionalDetails.identityContext", org.hamcrest.Matchers.not(org.hamcrest.Matchers.blankOrNullString()));
}
private static byte[] sha256(String value) {
try {
return java.security.MessageDigest.getInstance("SHA-256")
.digest(value.getBytes(java.nio.charset.StandardCharsets.US_ASCII));
} catch (java.security.NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
}
}
@Test
void registerClientReturnsOidcErrorShape() {
given()
.contentType("application/json")
.body("{\"clientName\":\"Bad Client\",\"clientType\":\"confidential\"}")
.when().post("/client/register")
.then().statusCode(400)
.body("error", equalTo("invalid_client_metadata"));
}
}
@@ -0,0 +1,216 @@
package io.github.hectorvent.floci.services.ssooidc;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
import io.github.hectorvent.floci.services.ssooidc.model.RegisteredClient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
class SsoOidcServiceTest {
private final ObjectMapper mapper = new ObjectMapper();
private SsoOidcService service;
@BeforeEach
void setUp() {
service = new SsoOidcService(
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
new InMemoryStorage<>(), "http://localhost:4566/");
}
@Test
void registerClientPersistsAwsOidcMetadata() {
ObjectNode request = mapper.createObjectNode();
request.put("clientName", "Floci CLI");
request.put("clientType", "public");
request.putArray("scopes").add("sso:account:access");
request.putArray("redirectUris").add("http://127.0.0.1:8400/callback");
request.putArray("grantTypes")
.add("authorization_code")
.add("refresh_token");
RegisteredClient client = service.registerClient(request);
assertNotNull(client.clientId());
assertEquals(32, client.clientId().length());
assertNotNull(client.clientSecret());
assertEquals(64, client.clientSecret().length());
assertTrue(client.clientSecretExpiresAt() > client.clientIdIssuedAt());
assertEquals(client, service.requireClient(client.clientId()));
assertEquals("http://localhost:4566/authorize", service.authorizationEndpoint());
assertEquals("http://localhost:4566/token", service.tokenEndpoint());
}
@Test
void startDeviceAuthorizationValidatesCredentialsAndPersistsChallenge() {
ObjectNode register = mapper.createObjectNode();
register.put("clientName", "Device Client");
register.put("clientType", "public");
register.putArray("grantTypes").add("urn:ietf:params:oauth:grant-type:device_code");
RegisteredClient client = service.registerClient(register);
ObjectNode request = mapper.createObjectNode();
request.put("clientId", client.clientId());
request.put("clientSecret", client.clientSecret());
request.put("startUrl", "https://example.awsapps.com/start");
var authorization = service.startDeviceAuthorization(request);
assertEquals(client.clientId(), authorization.clientId());
assertEquals(64, authorization.deviceCode().length());
assertTrue(authorization.userCode().matches("[0-9A-F]{4}-[0-9A-F]{4}"));
assertEquals(authorization, service.requireDeviceAuthorization(authorization.deviceCode()));
assertEquals("http://localhost:4566/device", service.verificationUri());
assertTrue(service.verificationUriComplete(authorization).endsWith("user_code=" + authorization.userCode()));
ObjectNode wrongSecret = request.deepCopy().put("clientSecret", "wrong");
assertOidcError("invalid_client", () -> service.startDeviceAuthorization(wrongSecret));
}
@Test
void createTokenSupportsDeviceAndRefreshGrants() {
ObjectNode register = mapper.createObjectNode();
register.put("clientName", "Token Client");
register.put("clientType", "public");
register.putArray("grantTypes")
.add("urn:ietf:params:oauth:grant-type:device_code")
.add("refresh_token");
RegisteredClient client = service.registerClient(register);
ObjectNode start = mapper.createObjectNode();
start.put("clientId", client.clientId());
start.put("clientSecret", client.clientSecret());
start.put("startUrl", "https://example.awsapps.com/start");
var authorization = service.startDeviceAuthorization(start);
ObjectNode token = mapper.createObjectNode();
token.put("clientId", client.clientId());
token.put("clientSecret", client.clientSecret());
token.put("grantType", "urn:ietf:params:oauth:grant-type:device_code");
token.put("deviceCode", authorization.deviceCode());
assertOidcError("authorization_pending", () -> service.createToken(token));
assertOidcError("slow_down", () -> service.createToken(token));
var approvedAuthorization = service.startDeviceAuthorization(start);
service.authorizeDevice(approvedAuthorization.userCode(), "11111111-1111-1111-1111-111111111111");
token.put("deviceCode", approvedAuthorization.deviceCode());
var session = service.createToken(token);
assertEquals("Token Client", client.clientName());
assertEquals(64, session.accessToken().length());
assertEquals(64, session.refreshToken().length());
ObjectNode refresh = mapper.createObjectNode();
refresh.put("clientId", client.clientId());
refresh.put("clientSecret", client.clientSecret());
refresh.put("grantType", "refresh_token");
refresh.put("refreshToken", session.refreshToken());
assertEquals(client.clientId(), service.createToken(refresh).clientId());
}
@Test
void createTokenSupportsAuthorizationCodePkce() {
ObjectNode register = mapper.createObjectNode();
register.put("clientName", "PKCE Client");
register.put("clientType", "public");
register.putArray("grantTypes").add("authorization_code");
register.putArray("redirectUris").add("http://127.0.0.1:8400/callback");
RegisteredClient client = service.registerClient(register);
String verifier = "01234567890123456789012345678901234567890123456789";
String challenge = java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(
sha256(verifier));
var code = service.createAuthorizationCode(client.clientId(),
"http://127.0.0.1:8400/callback", challenge);
ObjectNode token = mapper.createObjectNode();
token.put("clientId", client.clientId());
token.put("clientSecret", client.clientSecret());
token.put("grantType", "authorization_code");
token.put("code", code.code());
token.put("codeVerifier", verifier);
token.put("redirectUri", "http://127.0.0.1:8400/callback");
assertEquals(client.clientId(), service.createToken(token).clientId());
assertOidcError("invalid_grant", () -> service.createToken(token));
}
@Test
void createIamTokenSupportsRefreshJwtBearerAndTokenExchangeBranches() {
String sourceApplication = "arn:aws:sso::123456789012:application/ssoins-7223b02a5d9f7c8e/apl-1111111111111111";
String targetApplication = "arn:aws:sso::123456789012:application/ssoins-7223b02a5d9f7c8e/apl-2222222222222222";
var source = service.issueIamToken(sourceApplication, java.util.List.of("api:read"), true);
ObjectNode refresh = mapper.createObjectNode();
refresh.put("grantType", "refresh_token");
refresh.put("refreshToken", source.refreshToken());
assertOidcError("invalid_scope",
() -> service.createIamToken(refresh, sourceApplication, java.util.List.of("api:write")));
assertEquals(sourceApplication,
service.createIamToken(refresh, sourceApplication, java.util.List.of("api:read")).clientId());
ObjectNode jwt = mapper.createObjectNode();
jwt.put("grantType", "urn:ietf:params:oauth:grant-type:jwt-bearer");
jwt.put("assertion", "header.payload.signature");
assertEquals(targetApplication,
service.createIamToken(jwt, targetApplication, java.util.List.of("openid")).clientId());
ObjectNode exchange = mapper.createObjectNode();
exchange.put("grantType", "urn:ietf:params:oauth:grant-type:token-exchange");
exchange.put("subjectToken", source.accessToken());
exchange.put("subjectTokenType", "urn:ietf:params:oauth:token-type:access_token");
exchange.put("requestedTokenType", "urn:ietf:params:oauth:token-type:access_token");
var exchanged = service.createIamToken(exchange, targetApplication, java.util.List.of("openid"));
assertEquals(targetApplication, exchanged.clientId());
assertNull(exchanged.refreshToken());
assertOidcError("invalid_grant",
() -> service.createIamToken(exchange, sourceApplication, java.util.List.of("openid")));
}
private static byte[] sha256(String value) {
try {
return java.security.MessageDigest.getInstance("SHA-256")
.digest(value.getBytes(java.nio.charset.StandardCharsets.US_ASCII));
} catch (java.security.NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
}
}
@Test
void registerClientValidatesPublicClientAndGrantType() {
ObjectNode confidential = mapper.createObjectNode();
confidential.put("clientName", "Bad Client");
confidential.put("clientType", "confidential");
assertOidcError("invalid_client_metadata", () -> service.registerClient(confidential));
ObjectNode unsupportedGrant = mapper.createObjectNode();
unsupportedGrant.put("clientName", "Bad Grant");
unsupportedGrant.put("clientType", "public");
unsupportedGrant.putArray("grantTypes").add("client_credentials");
assertOidcError("unsupported_grant_type", () -> service.registerClient(unsupportedGrant));
}
@Test
void registerClientValidatesRequestShapes() {
ObjectNode missingName = mapper.createObjectNode().put("clientType", "public");
assertOidcError("invalid_request", () -> service.registerClient(missingName));
ObjectNode badScopes = mapper.createObjectNode();
badScopes.put("clientName", "Bad Scope");
badScopes.put("clientType", "public");
badScopes.put("scopes", "not-an-array");
assertOidcError("invalid_request", () -> service.registerClient(badScopes));
ObjectNode badArn = mapper.createObjectNode();
badArn.put("clientName", "Bad ARN");
badArn.put("clientType", "public");
badArn.put("entitledApplicationArn", "not-an-arn");
assertOidcError("invalid_client_metadata", () -> service.registerClient(badArn));
}
private static void assertOidcError(String code, Runnable action) {
SsoOidcException error = assertThrows(SsoOidcException.class, action::run);
assertEquals(code, error.error());
}
}
@@ -0,0 +1,177 @@
package io.github.hectorvent.floci.services.ssoportal;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.services.identitystore.IdentityStoreService;
import io.github.hectorvent.floci.services.ssoadmin.SsoAdminService;
import io.github.hectorvent.floci.services.ssooidc.SsoOidcService;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItems;
@QuarkusTest
class SsoPortalIntegrationTest {
@Inject
ObjectMapper mapper;
@Inject
IdentityStoreService identityStoreService;
@Inject
SsoAdminService ssoAdminService;
@Inject
SsoOidcService oidcService;
@Test
void listAccountsIncludesDirectAndGroupAssignmentsForTokenPrincipal() {
String suffix = UUID.randomUUID().toString().substring(0, 8);
String storeId = ssoAdminService.getIdentityStoreId();
var userRequest = mapper.createObjectNode();
userRequest.put("IdentityStoreId", storeId);
userRequest.put("UserName", "portal-" + suffix + "@example.com");
String userId = identityStoreService.createUser(userRequest).userId();
var groupRequest = mapper.createObjectNode();
groupRequest.put("IdentityStoreId", storeId);
groupRequest.put("DisplayName", "PortalGroup" + suffix);
String groupId = identityStoreService.createGroup(groupRequest).groupId();
var membershipRequest = mapper.createObjectNode();
membershipRequest.put("IdentityStoreId", storeId);
membershipRequest.put("GroupId", groupId);
membershipRequest.putObject("MemberId").put("UserId", userId);
identityStoreService.createMembership(membershipRequest);
String instanceArn = ssoAdminService.getInstanceArn();
String directPermissionSet = createPermissionSet(instanceArn, "PortalDirect" + suffix);
String groupPermissionSet = createPermissionSet(instanceArn, "PortalGroupPs" + suffix);
createAssignment(instanceArn, "111111111111", directPermissionSet, userId, "USER");
createAssignment(instanceArn, "222222222222", groupPermissionSet, groupId, "GROUP");
String accessToken = accessTokenFor(userId, suffix);
given()
.header("x-amz-sso_bearer_token", accessToken)
.when().get("/assignment/accounts")
.then().statusCode(200)
.body("accountList.accountId", hasItems("111111111111", "222222222222"));
given()
.header("x-amz-sso_bearer_token", accessToken)
.queryParam("account_id", "111111111111")
.when().get("/assignment/roles")
.then().statusCode(200)
.body("roleList[0].accountId", org.hamcrest.Matchers.equalTo("111111111111"))
.body("roleList[0].roleName", org.hamcrest.Matchers.equalTo("PortalDirect" + suffix));
given()
.header("x-amz-sso_bearer_token", accessToken)
.when().get("/assignment/roles")
.then().statusCode(400)
.body("__type", containsString("InvalidRequestException"));
given()
.header("x-amz-sso_bearer_token", accessToken)
.queryParam("account_id", "111111111111")
.queryParam("role_name", "PortalDirect" + suffix)
.when().get("/federation/credentials")
.then().statusCode(200)
.body("roleCredentials.accessKeyId", org.hamcrest.Matchers.startsWith("ASIA"))
.body("roleCredentials.secretAccessKey", org.hamcrest.Matchers.not(org.hamcrest.Matchers.emptyString()))
.body("roleCredentials.sessionToken", org.hamcrest.Matchers.not(org.hamcrest.Matchers.emptyString()))
.body("roleCredentials.expiration", org.hamcrest.Matchers.greaterThan(System.currentTimeMillis()));
given()
.header("x-amz-sso_bearer_token", accessToken)
.queryParam("account_id", "111111111111")
.queryParam("role_name", "NotAssigned")
.when().get("/federation/credentials")
.then().statusCode(404)
.body("__type", containsString("ResourceNotFoundException"));
given()
.when().get("/assignment/accounts")
.then().statusCode(401)
.body("__type", containsString("UnauthorizedException"));
given()
.header("x-amz-sso_bearer_token", accessToken)
.queryParam("max_result", "0")
.when().get("/assignment/accounts")
.then().statusCode(400)
.body("__type", containsString("InvalidRequestException"));
given()
.header("x-amz-sso_bearer_token", accessToken)
.queryParam("max_result", "not-a-number")
.when().get("/assignment/accounts")
.then().statusCode(400)
.body("__type", containsString("InvalidRequestException"));
given()
.header("x-amz-sso_bearer_token", accessToken)
.when().post("/logout")
.then().statusCode(200)
.body(org.hamcrest.Matchers.emptyOrNullString());
given()
.header("x-amz-sso_bearer_token", accessToken)
.when().get("/assignment/accounts")
.then().statusCode(401)
.body("__type", containsString("UnauthorizedException"));
given()
.header("x-amz-sso_bearer_token", accessToken)
.when().post("/logout")
.then().statusCode(401)
.body("__type", containsString("UnauthorizedException"));
}
private String createPermissionSet(String instanceArn, String name) {
var request = mapper.createObjectNode();
request.put("InstanceArn", instanceArn);
request.put("Name", name);
return ssoAdminService.createPermissionSet(request).arn();
}
private void createAssignment(String instanceArn, String accountId, String permissionSetArn,
String principalId, String principalType) {
var request = mapper.createObjectNode();
request.put("InstanceArn", instanceArn);
request.put("TargetId", accountId);
request.put("TargetType", "AWS_ACCOUNT");
request.put("PermissionSetArn", permissionSetArn);
request.put("PrincipalId", principalId);
request.put("PrincipalType", principalType);
ssoAdminService.createAssignment(request);
}
private String accessTokenFor(String principalId, String suffix) {
var registration = mapper.createObjectNode();
registration.put("clientName", "Portal Integration " + suffix);
registration.put("clientType", "public");
registration.putArray("grantTypes").add("urn:ietf:params:oauth:grant-type:device_code");
registration.putArray("scopes").add("sso:account:access");
var client = oidcService.registerClient(registration);
var start = mapper.createObjectNode();
start.put("clientId", client.clientId());
start.put("clientSecret", client.clientSecret());
start.put("startUrl", "https://example.awsapps.com/start");
var authorization = oidcService.startDeviceAuthorization(start);
oidcService.authorizeDevice(authorization.userCode(), principalId);
var token = mapper.createObjectNode();
token.put("clientId", client.clientId());
token.put("clientSecret", client.clientSecret());
token.put("grantType", "urn:ietf:params:oauth:grant-type:device_code");
token.put("deviceCode", authorization.deviceCode());
return oidcService.createToken(token).accessToken();
}
}
@@ -0,0 +1,94 @@
package io.github.hectorvent.floci.services.ssoportal;
import io.github.hectorvent.floci.services.iam.IamService;
import io.github.hectorvent.floci.services.organizations.OrganizationsService;
import io.github.hectorvent.floci.services.ssoadmin.SsoAdminService;
import io.github.hectorvent.floci.services.ssoadmin.model.Assignment;
import io.github.hectorvent.floci.services.ssoadmin.model.PermissionSet;
import io.github.hectorvent.floci.services.ssooidc.SsoOidcException;
import io.github.hectorvent.floci.services.ssooidc.SsoOidcService;
import io.github.hectorvent.floci.services.ssooidc.model.TokenSession;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
class SsoPortalServiceTest {
private SsoOidcService oidcService;
private SsoAdminService ssoAdminService;
private OrganizationsService organizationsService;
private IamService iamService;
private SsoPortalService service;
@BeforeEach
void setUp() {
oidcService = mock(SsoOidcService.class);
ssoAdminService = mock(SsoAdminService.class);
organizationsService = mock(OrganizationsService.class);
iamService = mock(IamService.class);
service = new SsoPortalService(oidcService, ssoAdminService, organizationsService, iamService);
}
@Test
void listsAssignedAccountsAndRolesAndIssuesCredentials() {
String accessToken = "access-token";
String principalId = "11111111-2222-3333-4444-555555555555";
String accountId = "123456789012";
String permissionSetArn = "arn:aws:sso:::permissionSet/ssoins-7223b02a5d9f7c8e/ps-1234567890abcdef";
when(oidcService.requireAccessToken(accessToken)).thenReturn(new TokenSession(
accessToken, "refresh-token", "client-id", List.of("sso:account:access"),
Instant.now().plusSeconds(3600).getEpochSecond(), Instant.now().plusSeconds(7200).getEpochSecond(), principalId));
when(ssoAdminService.portalAssignmentsForUser(principalId)).thenReturn(List.of(
new Assignment(accountId, permissionSetArn, principalId, "USER")));
when(organizationsService.findAccountForPortal(accountId)).thenReturn(Optional.empty());
when(ssoAdminService.permissionSetForPortal(permissionSetArn)).thenReturn(new PermissionSet(
permissionSetArn, "PlatformAdmins", null, "PT1H", Map.of(), Map.of(), null, null, Map.of()));
var accounts = service.listAccounts(accessToken, null, null);
assertEquals(List.of(accountId), accounts.items().stream().map(a -> a.accountId()).toList());
var roles = service.listAccountRoles(accessToken, accountId, null, null);
assertEquals("PlatformAdmins", roles.items().getFirst().roleName());
var credentials = service.getRoleCredentials(accessToken, accountId, "PlatformAdmins");
assertTrue(credentials.accessKeyId().startsWith("ASIA"));
assertTrue(credentials.expiration() > System.currentTimeMillis());
ArgumentCaptor<String> roleArn = ArgumentCaptor.forClass(String.class);
verify(iamService).registerSessionForAccount(eq(accountId), any(), any(), any(), roleArn.capture(), any(), eq(null));
assertTrue(roleArn.getValue().contains(":iam::" + accountId + ":role/aws-reserved/sso.amazonaws.com/AWSReservedSSO_PlatformAdmins_floci"));
}
@Test
void logoutRevokesTheAccessTokenSession() {
when(oidcService.requireAccessToken("access-token")).thenReturn(new TokenSession(
"access-token", null, "client-id", List.of(),
Instant.now().plusSeconds(3600).getEpochSecond(), 0, "principal"));
service.logout("access-token");
verify(oidcService).revokeAccessTokenSession("access-token");
}
@Test
void rejectsInvalidOrExpiredTokens() {
when(oidcService.requireAccessToken("bad-token")).thenThrow(new SsoOidcException("invalid_token", "expired", 401));
var error = assertThrows(io.github.hectorvent.floci.core.common.AwsException.class,
() -> service.listAccounts("bad-token", null, null));
assertEquals("UnauthorizedException", error.getErrorCode());
}
}