mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(iam): model account properties and outbound web identity federation (#5177)
Adds GetAccountProperties, PutAccountProperties, SetSecurityTokenServicePreferences, EnableOutboundWebIdentityFederation, DisableOutboundWebIdentityFederation and GetOutboundWebIdentityFederationInfo, which completes step 9f of the IAM gap plan. A property key is Namespace/PropertyName with exactly one forward slash and neither a leading nor a trailing one, and every key in one request must share a namespace, which AWS states directly. A request mixing namespaces is rejected whole rather than partly applied. Enabling federation twice is FeatureEnabled 409 and disabling it twice is FeatureDisabled 404, an asymmetry AWS documents. The getter answers FeatureDisabled too when the feature is off, reusing the disable operation's own wording, which is matched rather than improved. The issuer URL is derived from the request's partition rather than the literal in the API Reference's example: api.aws is only the commercial partition's dual-stack suffix. It is minted once per account and survives a disable, since a relying party verifying tokens will have pinned it. AWS documents neither that nor JwtVendingEnabled's source, so both are recorded in the docs as choices. The OIDC discovery endpoints the issuer is documented to host, and the GetWebIdentityToken API the feature references, are not modelled: these six are the management operations only.
This commit is contained in:
1 parent
2cf011f726
commit
04a3b97346
17 files changed
+1023
-2
No files matched your search
+228
@@ -0,0 +1,228 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* The account property and outbound federation operations over the wire.
|
||||
*
|
||||
* <p>These are account-level singletons, so the tests share one account and are written not to
|
||||
* depend on each other's properties: each uses its own namespace.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class AccountPropertiesIntegrationTest {
|
||||
|
||||
private static final String IAM_AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request";
|
||||
|
||||
private static RequestSpecification iam(String action) {
|
||||
return given().header("Authorization", IAM_AUTH).formParam("Action", action);
|
||||
}
|
||||
|
||||
private static String namespace() {
|
||||
return "Ns" + Long.toString(System.nanoTime(), 36).replace("-", "");
|
||||
}
|
||||
|
||||
private static final String PROPERTIES =
|
||||
"GetAccountPropertiesResponse.GetAccountPropertiesResult.Properties.";
|
||||
|
||||
@Test
|
||||
void propertiesRoundTripThroughPutAndGet() {
|
||||
String ns = namespace();
|
||||
|
||||
iam("PutAccountProperties")
|
||||
.formParam("Properties.entry.1.key", ns + "/RoleManagerEnabled")
|
||||
.formParam("Properties.entry.1.value", "true")
|
||||
.formParam("Properties.entry.2.key", ns + "/Mode")
|
||||
.formParam("Properties.entry.2.value", "strict")
|
||||
.when().post("/").then().statusCode(200);
|
||||
|
||||
iam("GetAccountProperties").when().post("/").then().statusCode(200)
|
||||
.body(containsString(ns + "/RoleManagerEnabled"))
|
||||
.body(containsString(ns + "/Mode"))
|
||||
.body(containsString("strict"));
|
||||
}
|
||||
|
||||
/** "All keys must belong to the same namespace." */
|
||||
@Test
|
||||
void mixingNamespacesInOneRequestIsRejected() {
|
||||
String first = namespace();
|
||||
String second = namespace();
|
||||
|
||||
iam("PutAccountProperties")
|
||||
.formParam("Properties.entry.1.key", first + "/Alpha")
|
||||
.formParam("Properties.entry.1.value", "1")
|
||||
.formParam("Properties.entry.2.key", second + "/Beta")
|
||||
.formParam("Properties.entry.2.value", "2")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("InvalidInput"))
|
||||
.body(containsString("same namespace"));
|
||||
|
||||
// Rejected whole, not partly applied: neither key was written.
|
||||
iam("GetAccountProperties").when().post("/").then().statusCode(200)
|
||||
.body(not(containsString(first + "/Alpha")))
|
||||
.body(not(containsString(second + "/Beta")));
|
||||
}
|
||||
|
||||
/** The key is Namespace/PropertyName: exactly one slash, not at either end. */
|
||||
@Test
|
||||
void aMalformedKeyIsRejected() {
|
||||
for (String key : List.of("NoSlash", "/LeadingSlash", "Trailing/", "Two/Slashes/Here",
|
||||
"1StartsWithADigit", "Has Space/Prop", "Ns/Prop!")) {
|
||||
iam("PutAccountProperties")
|
||||
.formParam("Properties.entry.1.key", key)
|
||||
.formParam("Properties.entry.1.value", "x")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("InvalidInput"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyOrValueOutsideItsLengthBoundsIsRejected() {
|
||||
String ns = namespace();
|
||||
// keyLength is 1 to 50.
|
||||
iam("PutAccountProperties")
|
||||
.formParam("Properties.entry.1.key", ns + "/" + "P".repeat(60))
|
||||
.formParam("Properties.entry.1.value", "x")
|
||||
.when().post("/").then().statusCode(400).body(containsString("InvalidInput"));
|
||||
|
||||
// valueLength is 1 to 1024.
|
||||
iam("PutAccountProperties")
|
||||
.formParam("Properties.entry.1.key", ns + "/TooLongValue")
|
||||
.formParam("Properties.entry.1.value", "v".repeat(1025))
|
||||
.when().post("/").then().statusCode(400).body(containsString("InvalidInput"));
|
||||
|
||||
// And the top of the range is accepted, so the bound is not off by one.
|
||||
iam("PutAccountProperties")
|
||||
.formParam("Properties.entry.1.key", ns + "/AtTheLimit")
|
||||
.formParam("Properties.entry.1.value", "v".repeat(1024))
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAbsentPropertiesMapIsRejected() {
|
||||
iam("PutAccountProperties").when().post("/").then().statusCode(400)
|
||||
.body(containsString("ValidationError"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theTokenVersionTakesOnlyTheTwoDocumentedValues() {
|
||||
for (String version : List.of("v1Token", "v2Token")) {
|
||||
iam("SetSecurityTokenServicePreferences")
|
||||
.formParam("GlobalEndpointTokenVersion", version)
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
for (String version : List.of("v3Token", "V1Token", "")) {
|
||||
iam("SetSecurityTokenServicePreferences")
|
||||
.formParam("GlobalEndpointTokenVersion", version)
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("ValidationError"));
|
||||
}
|
||||
|
||||
iam("SetSecurityTokenServicePreferences").when().post("/").then().statusCode(400)
|
||||
.body(containsString("ValidationError"))
|
||||
.body(containsString("globalEndpointTokenVersion"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The version set here is what GetAccountSummary reports, which the operation's own
|
||||
* description requires: the version "is reported in the GlobalEndpointTokenVersion entry of
|
||||
* the response of the GetAccountSummary operation". Reporting a constant leaves a caller that
|
||||
* set v2Token reading back 1.
|
||||
*/
|
||||
@Test
|
||||
void theTokenVersionIsWhatTheAccountSummaryReports() {
|
||||
String key = "GetAccountSummaryResponse.GetAccountSummaryResult.SummaryMap.entry"
|
||||
+ ".find { it.key == 'GlobalEndpointTokenVersion' }.value";
|
||||
|
||||
iam("SetSecurityTokenServicePreferences")
|
||||
.formParam("GlobalEndpointTokenVersion", "v2Token")
|
||||
.when().post("/").then().statusCode(200);
|
||||
iam("GetAccountSummary").when().post("/").then().statusCode(200)
|
||||
.body(key, equalTo("2"));
|
||||
|
||||
iam("SetSecurityTokenServicePreferences")
|
||||
.formParam("GlobalEndpointTokenVersion", "v1Token")
|
||||
.when().post("/").then().statusCode(200);
|
||||
iam("GetAccountSummary").when().post("/").then().statusCode(200)
|
||||
.body(key, equalTo("1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The federation lifecycle, in one test because it is one account-level switch: the order of
|
||||
* enable and disable is the behaviour under test and separate tests would race each other.
|
||||
*
|
||||
* <p>The asymmetry is the interesting part: enabling twice is 409, disabling twice is 404.
|
||||
*/
|
||||
@Test
|
||||
void theFederationSwitchRefusesBothRedundantDirections() {
|
||||
String enabled = "EnableOutboundWebIdentityFederationResponse"
|
||||
+ ".EnableOutboundWebIdentityFederationResult.IssuerIdentifier";
|
||||
String info = "GetOutboundWebIdentityFederationInfoResponse"
|
||||
+ ".GetOutboundWebIdentityFederationInfoResult.";
|
||||
|
||||
// Start from a known state: disabled, however earlier runs left it.
|
||||
iam("DisableOutboundWebIdentityFederation").when().post("/");
|
||||
|
||||
iam("GetOutboundWebIdentityFederationInfo").when().post("/").then().statusCode(404)
|
||||
.body(containsString("FeatureDisabled"));
|
||||
|
||||
String issuer = iam("EnableOutboundWebIdentityFederation")
|
||||
.when().post("/").then().statusCode(200)
|
||||
// https://<uuid>.tokens.sts.global.<dual-stack suffix>, api.aws in this partition.
|
||||
.body(enabled, matchesPattern(
|
||||
"https://[0-9a-f-]{36}\\.tokens\\.sts\\.global\\.api\\.aws"))
|
||||
.extract().path(enabled);
|
||||
assertNotNull(issuer);
|
||||
|
||||
iam("EnableOutboundWebIdentityFederation").when().post("/").then().statusCode(409)
|
||||
.body(containsString("FeatureEnabled"))
|
||||
.body(containsString("cannot enable the feature multiple times"));
|
||||
|
||||
iam("GetOutboundWebIdentityFederationInfo").when().post("/").then().statusCode(200)
|
||||
.body(info + "IssuerIdentifier", equalTo(issuer))
|
||||
.body(info + "JwtVendingEnabled", equalTo("true"));
|
||||
|
||||
iam("DisableOutboundWebIdentityFederation").when().post("/").then().statusCode(200);
|
||||
iam("DisableOutboundWebIdentityFederation").when().post("/").then().statusCode(404)
|
||||
.body(containsString("FeatureDisabled"))
|
||||
.body(containsString("cannot disable the feature multiple times"));
|
||||
|
||||
// Re-enabling returns the same issuer: a relying party has pinned it.
|
||||
String reissued = iam("EnableOutboundWebIdentityFederation")
|
||||
.when().post("/").then().statusCode(200).extract().path(enabled);
|
||||
assertEquals(issuer, reissued, "the issuer is minted once per account");
|
||||
|
||||
iam("DisableOutboundWebIdentityFederation").when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Without an Authorization header the Query controller infers the service from the action name
|
||||
* alone, so these have to be in its IAM set or they fall through to SQS.
|
||||
*/
|
||||
@Test
|
||||
void theActionsRouteToIamWithNoAuthHeader() {
|
||||
for (String action : List.of("GetAccountProperties", "PutAccountProperties",
|
||||
"SetSecurityTokenServicePreferences", "EnableOutboundWebIdentityFederation",
|
||||
"DisableOutboundWebIdentityFederation",
|
||||
"GetOutboundWebIdentityFederationInfo")) {
|
||||
given().contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", action)
|
||||
.formParam("Version", "2010-05-08")
|
||||
.when().post("/").then()
|
||||
.body(containsString("iam.amazonaws.com/doc/2010-05-08"));
|
||||
}
|
||||
}
|
||||
}
|
||||
+242
@@ -0,0 +1,242 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.RequestContext;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.core.storage.PersistentStorage;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.services.iam.model.OutboundWebIdentityFederation;
|
||||
import jakarta.enterprise.inject.Instance;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* What the wire tests cannot reach for the account-level singletons: that they survive a restart,
|
||||
* that one account cannot see another's, and that two racing enables cannot both succeed.
|
||||
*/
|
||||
class AccountPropertiesStateTest {
|
||||
|
||||
private static final String ACCOUNT_A = "000000000000";
|
||||
private static final String ACCOUNT_B = "111111111111";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Instance<RequestContext> requestContextFor(AtomicReference<String> accountId) {
|
||||
RequestContext rc = mock(RequestContext.class);
|
||||
when(rc.getAccountId()).thenAnswer(invocation -> accountId.get());
|
||||
Instance<RequestContext> inst = mock(Instance.class);
|
||||
when(inst.get()).thenReturn(rc);
|
||||
return inst;
|
||||
}
|
||||
|
||||
private static IamService newService(
|
||||
StorageBackend<String, String> accountProperties,
|
||||
StorageBackend<String, String> stsPreferences,
|
||||
StorageBackend<String, OutboundWebIdentityFederation> federation,
|
||||
String defaultAccount) {
|
||||
return new IamService(
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
accountProperties, stsPreferences, federation,
|
||||
new RegionResolver("us-east-1", defaultAccount), false, null);
|
||||
}
|
||||
|
||||
private static IamService inMemory(String defaultAccount) {
|
||||
return newService(new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), defaultAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* All three singletons survive a restart. The issuer matters most: a relying party has pinned
|
||||
* it, so losing it on restart would break verification with no way to notice from the API.
|
||||
*/
|
||||
@Test
|
||||
void thePropertiesTheTokenVersionAndTheIssuerSurviveARestart(@TempDir Path dir) {
|
||||
Path propertiesFile = dir.resolve("iam-account-properties.json");
|
||||
Path stsFile = dir.resolve("iam-sts-preferences.json");
|
||||
Path federationFile = dir.resolve("iam-outbound-federation.json");
|
||||
|
||||
PersistentStorage<String, String> properties =
|
||||
new PersistentStorage<>(propertiesFile, new TypeReference<>() {});
|
||||
PersistentStorage<String, String> sts =
|
||||
new PersistentStorage<>(stsFile, new TypeReference<>() {});
|
||||
PersistentStorage<String, OutboundWebIdentityFederation> federation =
|
||||
new PersistentStorage<>(federationFile, new TypeReference<>() {});
|
||||
properties.load();
|
||||
sts.load();
|
||||
federation.load();
|
||||
|
||||
IamService before = newService(properties, sts, federation, ACCOUNT_A);
|
||||
before.putAccountProperties(Map.of("RoleManager/Enabled", "true"));
|
||||
before.setSecurityTokenServicePreferences("v2Token");
|
||||
String issuer = before.enableOutboundWebIdentityFederation();
|
||||
|
||||
PersistentStorage<String, String> properties2 =
|
||||
new PersistentStorage<>(propertiesFile, new TypeReference<>() {});
|
||||
PersistentStorage<String, String> sts2 =
|
||||
new PersistentStorage<>(stsFile, new TypeReference<>() {});
|
||||
PersistentStorage<String, OutboundWebIdentityFederation> federation2 =
|
||||
new PersistentStorage<>(federationFile, new TypeReference<>() {});
|
||||
properties2.load();
|
||||
sts2.load();
|
||||
federation2.load();
|
||||
IamService after = newService(properties2, sts2, federation2, ACCOUNT_A);
|
||||
|
||||
assertEquals(Map.of("RoleManager/Enabled", "true"), after.getAccountProperties());
|
||||
assertEquals("v2Token", after.getGlobalEndpointTokenVersion());
|
||||
assertEquals(issuer,
|
||||
after.getOutboundWebIdentityFederationInfo().getIssuerIdentifier());
|
||||
assertTrue(after.getOutboundWebIdentityFederationInfo().isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
void oneAccountCannotSeeAnothersProperties() {
|
||||
AtomicReference<String> account = new AtomicReference<>(ACCOUNT_A);
|
||||
Instance<RequestContext> context = requestContextFor(account);
|
||||
AccountAwareStorageBackend<String> properties = new AccountAwareStorageBackend<>(
|
||||
new InMemoryStorage<>(), context, ACCOUNT_A);
|
||||
AccountAwareStorageBackend<String> sts = new AccountAwareStorageBackend<>(
|
||||
new InMemoryStorage<>(), context, ACCOUNT_A);
|
||||
AccountAwareStorageBackend<OutboundWebIdentityFederation> federation =
|
||||
new AccountAwareStorageBackend<>(new InMemoryStorage<>(), context, ACCOUNT_A);
|
||||
|
||||
IamService inA = newService(properties, sts, federation, ACCOUNT_A);
|
||||
IamService inB = newService(properties, sts, federation, ACCOUNT_B);
|
||||
|
||||
inA.putAccountProperties(Map.of("RoleManager/Mode", "a"));
|
||||
inA.setSecurityTokenServicePreferences("v2Token");
|
||||
String issuerA = inA.enableOutboundWebIdentityFederation();
|
||||
|
||||
account.set(ACCOUNT_B);
|
||||
assertTrue(inB.getAccountProperties().isEmpty(), "B must not see A's properties");
|
||||
assertEquals("v1Token", inB.getGlobalEndpointTokenVersion(),
|
||||
"B falls back to the default rather than reading A's preference");
|
||||
assertThrows(AwsException.class, inB::getOutboundWebIdentityFederationInfo,
|
||||
"B's federation is off, whatever A did");
|
||||
|
||||
// And B enabling mints its own issuer rather than inheriting A's.
|
||||
String issuerB = inB.enableOutboundWebIdentityFederation();
|
||||
assertNotEquals(issuerA, issuerB);
|
||||
|
||||
account.set(ACCOUNT_A);
|
||||
assertEquals(Map.of("RoleManager/Mode", "a"), inA.getAccountProperties());
|
||||
assertEquals(issuerA,
|
||||
inA.getOutboundWebIdentityFederationInfo().getIssuerIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabling is a check-then-act on one switch, so two racing enables must not both mint an
|
||||
* issuer and both report success. Asserted by counting the winners, because an invariant
|
||||
* phrased as "the stored issuer is one of the two" passes with the lock removed too.
|
||||
*/
|
||||
@Test
|
||||
void racingEnablesProduceOneWinner() throws Exception {
|
||||
for (int trial = 0; trial < 60; trial++) {
|
||||
IamService service = inMemory(ACCOUNT_A);
|
||||
int attempts = 8;
|
||||
ExecutorService pool = Executors.newFixedThreadPool(attempts);
|
||||
CountDownLatch start = new CountDownLatch(1);
|
||||
AtomicInteger enabled = new AtomicInteger();
|
||||
try {
|
||||
for (int i = 0; i < attempts; i++) {
|
||||
pool.submit(() -> {
|
||||
start.await();
|
||||
try {
|
||||
service.enableOutboundWebIdentityFederation();
|
||||
enabled.incrementAndGet();
|
||||
} catch (AwsException expected) {
|
||||
// FeatureEnabled for the losers, which is the point.
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
start.countDown();
|
||||
pool.shutdown();
|
||||
assertTrue(pool.awaitTermination(30, TimeUnit.SECONDS), "trial did not finish");
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
assertEquals(1, enabled.get(),
|
||||
"trial " + trial + ": exactly one enable should have succeeded");
|
||||
}
|
||||
}
|
||||
|
||||
/** The issuer is minted once: a disable and re-enable returns the same URL. */
|
||||
@Test
|
||||
void theIssuerIsStableAcrossADisableAndReEnable() {
|
||||
IamService service = inMemory(ACCOUNT_A);
|
||||
String first = service.enableOutboundWebIdentityFederation();
|
||||
service.disableOutboundWebIdentityFederation();
|
||||
assertThrows(AwsException.class, service::getOutboundWebIdentityFederationInfo);
|
||||
assertEquals(first, service.enableOutboundWebIdentityFederation());
|
||||
}
|
||||
|
||||
private static IamService inRegion(String region) {
|
||||
return new IamService(
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver(region, ACCOUNT_A), false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The issuer host comes from the request's partition rather than the commercial literal the
|
||||
* API Reference's example happens to show. This is the test the mistake would survive
|
||||
* otherwise: hardcoding {@code api.aws} passes everything else.
|
||||
*/
|
||||
@Test
|
||||
void theIssuerHostFollowsThePartition() {
|
||||
String commercial = inRegion("us-east-1").enableOutboundWebIdentityFederation();
|
||||
String chinese = inRegion("cn-north-1").enableOutboundWebIdentityFederation();
|
||||
|
||||
assertTrue(commercial.endsWith(".tokens.sts.global.api.aws"), commercial);
|
||||
assertTrue(chinese.startsWith("https://"), chinese);
|
||||
assertNotEquals(commercial.substring(commercial.indexOf(".tokens")),
|
||||
chinese.substring(chinese.indexOf(".tokens")),
|
||||
"the suffix must differ between partitions, but China gave " + chinese);
|
||||
}
|
||||
|
||||
/** A request mixing namespaces is rejected whole, so nothing from it is written. */
|
||||
@Test
|
||||
void aMixedNamespaceRequestWritesNothing() {
|
||||
IamService service = inMemory(ACCOUNT_A);
|
||||
service.putAccountProperties(Map.of("RoleManager/Kept", "yes"));
|
||||
|
||||
Map<String, String> mixed = new LinkedHashMap<>();
|
||||
mixed.put("RoleManager/A", "1");
|
||||
mixed.put("Other/B", "2");
|
||||
assertThrows(AwsException.class, () -> service.putAccountProperties(mixed));
|
||||
|
||||
assertEquals(Map.of("RoleManager/Kept", "yes"), service.getAccountProperties(),
|
||||
"neither key of the rejected request may have landed");
|
||||
}
|
||||
}
|
||||
@@ -234,6 +234,7 @@ class IamServicePersistenceTest {
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", "000000000000"), false, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -2641,6 +2641,7 @@ class IamServiceTest {
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", "000000000000"), false, null);
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class, withExpiredReport::getCredentialReport);
|
||||
@@ -2662,6 +2663,7 @@ class IamServiceTest {
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", "000000000000"), false, null);
|
||||
|
||||
IamService.CredentialReportGeneration generation = withExpiredReport.generateCredentialReport();
|
||||
|
||||
@@ -83,6 +83,7 @@ class ServerCertificateStateTest {
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", defaultAccount), false, null);
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -70,6 +70,7 @@ class ServiceSpecificCredentialStateTest {
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
credentials,
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", defaultAccount), false, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ class SigningCertificateStateTest {
|
||||
certificates,
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", defaultAccount), false, null);
|
||||
}
|
||||
|
||||
@@ -90,6 +91,7 @@ class SigningCertificateStateTest {
|
||||
certificates,
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", defaultAccount), false, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ class SshPublicKeyStateTest {
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
keys,
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", defaultAccount), false, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ class VirtualMfaAccountScopeTest {
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", ACCOUNT_A), false, null);
|
||||
|
||||
VirtualMfaDevice device = service.createVirtualMfaDevice("shared-name", "/", Map.of());
|
||||
@@ -95,6 +96,7 @@ class VirtualMfaAccountScopeTest {
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("us-east-1", ACCOUNT_A), false, null);
|
||||
|
||||
VirtualMfaDevice inA = service.createVirtualMfaDevice("same-name", "/", Map.of());
|
||||
|
||||
@@ -41,6 +41,7 @@ class VirtualMfaConcurrencyTest {
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new RegionResolver("eu-central-1", "000000000000"), false, null);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user