mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(iam): check the EventBridge Scheduler and Pipes routes (#6044)
Under IAM enforcement no Scheduler or Pipes route was mapped to an IAM action, so every call to either went unchecked, and the roles they take with it. - Every Scheduler and Pipes route is mapped, tagging at /tags as well as /tags/<arn>, and IamRestRouteCoverageTest now checks every operation of both models. Each request is checked against the resource the Service Reference gives: schedule/<group>/<name>, the group read where Scheduler reads it (the body's GroupName on a create or an update, groupName otherwise, else default), schedule-group/<name>, pipe/<name>, the ARN a tagging route names, and * where the request names none. Scheduler and Pipes ARNs are minted in the request's partition, as those services mint theirs. - SchedulerController joins the Scheduler descriptor, so a schedule request is checked as Scheduler whatever scope signs it. Otherwise one signed for another service was checked by that service's rules. - The shared tagging routes, /tags and /v1/tags, hand a request to the service its ARN names, so it is checked as that service, against the ARN the controller acts on: the body's resourceArn on POST /tags, the query's on the other bare routes. Otherwise a Pipes grant could tag a schedule group, a scope with no tagging rule went unchecked, and a query ARN could stand in for the body's. - iam:PassRole: CreateSchedule and UpdateSchedule pass the target's RoleArn to scheduler.amazonaws.com, and CreatePipe and UpdatePipe their RoleArn to pipes.amazonaws.com, as the Scheduler user guide's example policies and the EventBridge user guide say.
This commit is contained in:
1 parent
6be05b9cbe
commit
77c5d74a7d
15 files changed
+521
-12
No files matched your search
@@ -17,6 +17,7 @@ import io.github.hectorvent.floci.services.iam.ResourcePolicyProvider;
|
||||
import io.github.hectorvent.floci.services.iam.ScpProvider;
|
||||
import io.github.hectorvent.floci.services.iam.model.CallerContext;
|
||||
import io.github.hectorvent.floci.services.s3.S3Controller;
|
||||
import io.github.hectorvent.floci.services.scheduler.SchedulerController;
|
||||
import io.quarkus.vertx.http.runtime.CurrentVertxRequest;
|
||||
import io.vertx.core.http.HttpServerRequest;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
@@ -338,6 +339,31 @@ class IamEnforcementFilterTest {
|
||||
verify(conditionContextResolver).resolve("apigateway", "apigateway:POST", containerRequest);
|
||||
}
|
||||
|
||||
@Test
|
||||
void schedulerResourcesAreBuiltInTheRequestsPartition() {
|
||||
// A Region no partition publishes takes the deployment's partition, which Scheduler mints its ARNs in.
|
||||
ContainerRequestContext containerRequest = mock(ContainerRequestContext.class);
|
||||
String auth = "AWS4-HMAC-SHA256 Credential=AKIAUSER/20260924/xx-local-1/scheduler/aws4_request, "
|
||||
+ "SignedHeaders=host, Signature=abc";
|
||||
requestContext.setAccountId("000000000000");
|
||||
requestContext.setRegion("xx-local-1");
|
||||
requestContext.setPartition("aws-cn");
|
||||
when(accountResolver.extractAccessKeyId(auth)).thenReturn("AKIAUSER");
|
||||
when(containerRequest.getHeaderString("Authorization")).thenReturn(auth);
|
||||
when(containerRequest.getProperty(AwsProtocolClaimFilter.CLAIM_PROPERTY))
|
||||
.thenReturn(ProtocolClaim.rest());
|
||||
when(catalog.byResourceClass(SchedulerController.class))
|
||||
.thenReturn(Optional.of(descriptor("scheduler", ServiceProtocol.JSON,
|
||||
Set.of("scheduler"), SchedulerController.class)));
|
||||
when(actionRegistry.resolveRoute("scheduler", containerRequest)).thenReturn("scheduler:GetSchedule");
|
||||
when(arnBuilder.buildResources(any(), any(), any(), any(), any())).thenReturn(List.of("*"));
|
||||
when(iamService.resolveCallerContext(eq("AKIAUSER"), any())).thenReturn(CallerContext.of(List.of()));
|
||||
|
||||
newFilter(resourceInfo(SchedulerController.class)).filter(containerRequest);
|
||||
|
||||
verify(arnBuilder).buildResources("scheduler", containerRequest, "xx-local-1", "000000000000", "aws-cn");
|
||||
}
|
||||
|
||||
@Test
|
||||
void s3RouteDoesNotUseApiGatewayRules() {
|
||||
ContainerRequestContext containerRequest = mock(ContainerRequestContext.class);
|
||||
|
||||
@@ -136,6 +136,18 @@ class PassedRolesTest {
|
||||
+ "{\"RoleArn\":\"" + ROLES + "two\"}]}"), LOOKUPS));
|
||||
}
|
||||
|
||||
@Test
|
||||
void schedulerAndPipesPassTheRoleTheyName() {
|
||||
String target = "{\"Target\":{\"RoleArn\":\"" + ROLES + "schedule\"}}";
|
||||
assertEquals(List.of(passed("schedule", "scheduler.amazonaws.com")),
|
||||
PassedRoles.of("scheduler:CreateSchedule", json(target), LOOKUPS));
|
||||
assertEquals(List.of(passed("schedule", "scheduler.amazonaws.com")),
|
||||
PassedRoles.of("scheduler:UpdateSchedule", json(target), LOOKUPS));
|
||||
String pipe = "{\"RoleArn\":\"" + ROLES + "pipe\"}";
|
||||
assertEquals(List.of(passed("pipe", "pipes.amazonaws.com")), PassedRoles.of("pipes:CreatePipe", json(pipe), LOOKUPS));
|
||||
assertEquals(List.of(passed("pipe", "pipes.amazonaws.com")), PassedRoles.of("pipes:UpdatePipe", json(pipe), LOOKUPS));
|
||||
}
|
||||
|
||||
@Test
|
||||
void outsideEcsOnlyARoleArnIsPassed() {
|
||||
assertEquals(List.of(), PassedRoles.of("states:CreateStateMachine", json("{\"roleArn\":\"sm\"}"), LOOKUPS));
|
||||
|
||||
@@ -268,6 +268,21 @@ class IamActionRegistryTest {
|
||||
assertNull(lambdaAction("GET", "/2018-10-31/layers"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void schedulerAndPipesTaggingIsCheckedOnBothTagRoutes() {
|
||||
for (String scope : List.of("scheduler", "pipes")) {
|
||||
for (String path : List.of("/tags/arn:aws:" + scope + ":us-east-1:000000000000:x", "/tags")) {
|
||||
String prefix = scope + ":";
|
||||
assertEquals(prefix + "ListTagsForResource", registry.resolveRoute(scope,
|
||||
mockCtx("GET", path, new MultivaluedHashMap<>(), MediaType.APPLICATION_JSON_TYPE, "{}")), path);
|
||||
assertEquals(prefix + "TagResource", registry.resolveRoute(scope,
|
||||
mockCtx("POST", path, new MultivaluedHashMap<>(), MediaType.APPLICATION_JSON_TYPE, "{}")), path);
|
||||
assertEquals(prefix + "UntagResource", registry.resolveRoute(scope,
|
||||
mockCtx("DELETE", path, new MultivaluedHashMap<>(), MediaType.APPLICATION_JSON_TYPE, "{}")), path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void durableExecutionRoutesResolveToTheirActions() {
|
||||
String arn = "arn%3Aaws%3Alambda%3Aus-east-1%3A000000000000%3Afunction%3Af%3A%24LATEST"
|
||||
|
||||
+67
@@ -47,6 +47,8 @@ class IamPassRoleEnforcementIntegrationTest {
|
||||
private static final String ECS_TASKS = "ecs-tasks.amazonaws.com";
|
||||
private static final String ECS = "ecs.amazonaws.com";
|
||||
private static final String QUEUE_ARN = "arn:aws:sqs:us-east-1:" + ACCOUNT + ":passrole-queue";
|
||||
private static final String SCHEDULER = "scheduler.amazonaws.com";
|
||||
private static final String PIPES = "pipes.amazonaws.com";
|
||||
private static final ObjectMapper CBOR_MAPPER = new ObjectMapper(new CBORFactory());
|
||||
|
||||
@TestHTTPResource("/")
|
||||
@@ -392,6 +394,56 @@ class IamPassRoleEnforcementIntegrationTest {
|
||||
user.json("events", "AWSEvents.PutTargets").body(putTargets).post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aScheduleNeedsTheSchedulerActionOnItsArnAndPassRoleOnItsTargetsRole() {
|
||||
String role = role("scheduler");
|
||||
String other = role("scheduler-other");
|
||||
User user = user("passrole-scheduler");
|
||||
String name = "passrole-schedule-" + suffix();
|
||||
String path = "/schedules/" + name;
|
||||
String arn = "arn:aws:scheduler:us-east-1:" + ACCOUNT + ":schedule/default/" + name;
|
||||
|
||||
// The route is checked as scheduler:CreateSchedule, on the schedule's ARN.
|
||||
user.policy(allow("scheduler:CreateSchedule", arn + "-other") + "," + passRole(role, SCHEDULER));
|
||||
refused(user.rest("scheduler").body(schedule(role)).post(path).then(), "scheduler:CreateSchedule");
|
||||
user.policy(allow("scheduler:CreateSchedule", arn));
|
||||
denied(user.rest("scheduler").body(schedule(role)).post(path).then());
|
||||
user.policy(allow("scheduler:CreateSchedule", arn) + "," + passRole(role, SCHEDULER));
|
||||
user.rest("scheduler").body(schedule(role)).post(path).then().statusCode(200);
|
||||
cleanup.register(() -> admin("scheduler").delete(path));
|
||||
|
||||
user.policy(allow("scheduler:UpdateSchedule", arn) + "," + passRole(role, SCHEDULER));
|
||||
denied(user.rest("scheduler").body(schedule(other)).put(path).then());
|
||||
user.policy(allow("scheduler:UpdateSchedule", arn) + "," + passRole(other, SCHEDULER));
|
||||
user.rest("scheduler").body(schedule(other)).put(path).then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aPipeNeedsThePipesActionOnItsArnAndPassRoleOnItsRole() {
|
||||
String role = role("pipes");
|
||||
String other = role("pipes-other");
|
||||
User user = user("passrole-pipes");
|
||||
String name = "passrole-pipe-" + suffix();
|
||||
String path = "/v1/pipes/" + name;
|
||||
String arn = "arn:aws:pipes:us-east-1:" + ACCOUNT + ":pipe/" + name;
|
||||
String create = "{\"Source\":\"" + QUEUE_ARN + "\",\"Target\":\"" + QUEUE_ARN + "\",\"RoleArn\":\"" + role
|
||||
+ "\",\"DesiredState\":\"STOPPED\"}";
|
||||
|
||||
user.policy(allow("pipes:CreatePipe", arn + "-other") + "," + passRole(role, PIPES));
|
||||
refused(user.rest("pipes").body(create).post(path).then(), "pipes:CreatePipe");
|
||||
user.policy(allow("pipes:CreatePipe", arn));
|
||||
denied(user.rest("pipes").body(create).post(path).then());
|
||||
user.policy(allow("pipes:CreatePipe", arn) + "," + passRole(role, PIPES));
|
||||
user.rest("pipes").body(create).post(path).then().statusCode(200);
|
||||
cleanup.register(() -> admin("pipes").delete(path));
|
||||
|
||||
String update = "{\"RoleArn\":\"" + other + "\",\"DesiredState\":\"STOPPED\"}";
|
||||
user.policy(allow("pipes:UpdatePipe", arn) + "," + passRole(role, PIPES));
|
||||
denied(user.rest("pipes").body(update).put(path).then());
|
||||
user.policy(allow("pipes:UpdatePipe", arn) + "," + passRole(other, PIPES));
|
||||
user.rest("pipes").body(update).put(path).then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aStackNeedsPassRoleOnAServiceRoleTheRequestNames() {
|
||||
String role = role("cloudformation");
|
||||
@@ -553,6 +605,17 @@ class IamPassRoleEnforcementIntegrationTest {
|
||||
return compressed.toByteArray();
|
||||
}
|
||||
|
||||
/** A REST request refused for the operation's own action, which the message names. */
|
||||
private static void refused(ValidatableResponse response, String action) {
|
||||
response.statusCode(403).body(containsString(action)).body(not(containsString("iam:PassRole")));
|
||||
}
|
||||
|
||||
private static String schedule(String role) {
|
||||
return """
|
||||
{"ScheduleExpression":"rate(1 hour)","FlexibleTimeWindow":{"Mode":"OFF"},
|
||||
"Target":{"Arn":"%s","RoleArn":"%s"}}""".formatted(QUEUE_ARN, role);
|
||||
}
|
||||
|
||||
private static void denied(ValidatableResponse response) {
|
||||
response.statusCode(403).body(containsString("iam:PassRole"));
|
||||
}
|
||||
@@ -628,6 +691,10 @@ class IamPassRoleEnforcementIntegrationTest {
|
||||
return json("ecs", "AmazonEC2ContainerServiceV20141113." + action);
|
||||
}
|
||||
|
||||
RequestSpecification rest(String service) {
|
||||
return given().header("Authorization", auth(accessKeyId, service)).contentType("application/json");
|
||||
}
|
||||
|
||||
RequestSpecification json(String service, String target) {
|
||||
return given().header("Authorization", auth(accessKeyId, service)).header("X-Amz-Target", target)
|
||||
.contentType("application/x-amz-json-1.1");
|
||||
|
||||
@@ -51,6 +51,9 @@ class IamRestRouteCoverageTest {
|
||||
"GetBucketMetadataConfiguration", "s3:ListBucket",
|
||||
"DeleteBucketMetadataConfiguration", "s3:DeleteBucket");
|
||||
|
||||
/** Models every operation of which is checked: the services whose routes the registry maps in full. */
|
||||
private static final Set<String> FULLY_ROUTED_MODELS = Set.of("scheduler", "pipes");
|
||||
|
||||
private final IamActionRegistry registry = new IamActionRegistry();
|
||||
|
||||
@TestFactory
|
||||
@@ -75,6 +78,26 @@ class IamRestRouteCoverageTest {
|
||||
return tests.stream();
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Stream<DynamicTest> everyOperationOfAFullyRoutedServiceResolvesToItsAction() throws IOException {
|
||||
JsonNode models = load("/aws/rest-routes.json").path("models");
|
||||
JsonNode authorized = load("/aws/iam-authorized-actions.json").path("authorizedActions");
|
||||
List<DynamicTest> tests = new ArrayList<>();
|
||||
for (String model : FULLY_ROUTED_MODELS) {
|
||||
String scope = models.path(model).path("credentialScope").asText();
|
||||
Iterator<Map.Entry<String, JsonNode>> operations = models.path(model).path("operations").fields();
|
||||
while (operations.hasNext()) {
|
||||
Map.Entry<String, JsonNode> operation = operations.next();
|
||||
Route route = new Route(scope, model, operation.getKey(), operation.getValue().path("method").asText(),
|
||||
operation.getValue().path("requestUri").asText());
|
||||
String expected = authorized.path(scope).path(operation.getKey()).asText(scope + ":" + operation.getKey());
|
||||
tests.add(DynamicTest.dynamicTest(model + " " + operation.getKey(),
|
||||
() -> assertEquals(expected, resolve(route), route.toString())));
|
||||
}
|
||||
}
|
||||
return tests.stream();
|
||||
}
|
||||
|
||||
/** Every model route of {@code operation} among the models Floci authorizes under {@code scope}. */
|
||||
private static List<Route> routesOf(JsonNode models, String scope, String operation) {
|
||||
List<Route> routes = new ArrayList<>();
|
||||
|
||||
+58
@@ -68,6 +68,64 @@ class IamRestRouteEnforcementIntegrationTest {
|
||||
.get("/2018-10-31/layers").then().statusCode(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aScheduleRequestSignedForAnotherServiceIsStillCheckedAsScheduler() {
|
||||
// Checked by the route it reached, not by the credential scope it was signed with: an S3
|
||||
// grant does not let the request through as an S3 request.
|
||||
String user = user("route-scheduler-scope");
|
||||
policy(user, allow("s3:*", "*"));
|
||||
refused(as(user, "s3").get("/schedules/route-schedule-" + suffix()).then(), "scheduler:GetSchedule");
|
||||
}
|
||||
|
||||
@Test
|
||||
void schedulerTaggingIsCheckedOnTheBareTagsRouteToo() {
|
||||
// The shared tagging routes also take the ARN in the body of POST /tags.
|
||||
String user = user("route-scheduler-tags");
|
||||
String group = scheduleGroup("route-group-" + suffix());
|
||||
|
||||
policy(user, allow("scheduler:ListTagsForResource", "*"));
|
||||
refused(as(user, "scheduler").body(tagBody(group)).post("/tags").then(), "scheduler:TagResource");
|
||||
policy(user, allow("scheduler:TagResource", group));
|
||||
// Allowed on that group, the request reaches Scheduler, which has no such group.
|
||||
as(user, "scheduler").body(tagBody(group)).post("/tags").then().statusCode(not(403));
|
||||
}
|
||||
|
||||
@Test
|
||||
void postTagsIsCheckedAgainstTheArnItsBodyNames() {
|
||||
// POST /tags tags the ARN its body names: one named in the query does not move the check.
|
||||
String user = user("route-tags-body");
|
||||
String allowed = scheduleGroup("route-allowed-" + suffix());
|
||||
String other = scheduleGroup("route-other-" + suffix());
|
||||
|
||||
policy(user, allow("scheduler:TagResource", allowed));
|
||||
refused(as(user, "scheduler").queryParam("resourceArn", allowed).body(tagBody(other)).post("/tags").then(),
|
||||
"scheduler:TagResource");
|
||||
}
|
||||
|
||||
@Test
|
||||
void sharedTaggingIsCheckedAsTheServiceItsArnNames() {
|
||||
// The shared tagging routes hand the request to the service its ARN names, whatever scope it is
|
||||
// signed with: a Pipes grant does not let the caller tag a schedule group, and a scope with no
|
||||
// tagging rule does not let the request through unchecked.
|
||||
String user = user("route-tags-scope");
|
||||
String group = scheduleGroup("route-group-" + suffix());
|
||||
String cluster = "arn:aws:eks:us-east-1:" + ACCOUNT + ":cluster/route-cluster-" + suffix();
|
||||
|
||||
// Nor is an ARN of a service with no tagging rule checked as the signing scope's action.
|
||||
as(user, "pipes").body(tagBody(cluster)).post("/tags").then().body(not(containsString("pipes:TagResource")));
|
||||
policy(user, allow("pipes:TagResource", "*"));
|
||||
refused(as(user, "pipes").body(tagBody(group)).post("/tags").then(), "scheduler:TagResource");
|
||||
refused(as(user, "sqs").body(tagBody(group)).post("/tags").then(), "scheduler:TagResource");
|
||||
}
|
||||
|
||||
private static String scheduleGroup(String name) {
|
||||
return "arn:aws:scheduler:us-east-1:" + ACCOUNT + ":schedule-group/" + name;
|
||||
}
|
||||
|
||||
private static String tagBody(String arn) {
|
||||
return "{\"resourceArn\":\"" + arn + "\",\"tags\":[{\"key\":\"team\",\"value\":\"a\"}]}";
|
||||
}
|
||||
|
||||
private static void refused(ValidatableResponse response, String action) {
|
||||
response.statusCode(403).body(containsString(action)).body(not(containsString("iam:PassRole")));
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.util.Optional;
|
||||
|
||||
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.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
@@ -1196,6 +1197,93 @@ class ResourceArnBuilderTest {
|
||||
assertEquals("*", builder.build("lambda", ctx, "us-east-1", "000000000000"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void schedulerRoutesResolveTheScheduleInItsGroupTheGroupOrTheTaggedArn() {
|
||||
when(uriInfo.getPath()).thenReturn("/schedules/nightly");
|
||||
assertEquals("arn:aws:scheduler:us-east-1:000000000000:schedule/default/nightly",
|
||||
builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
queryParams.putSingle("groupName", "reports");
|
||||
assertEquals("arn:aws:scheduler:us-east-1:000000000000:schedule/reports/nightly",
|
||||
builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
// A create or update names its group in the body, which Scheduler reads, not in the query, which
|
||||
// it ignores for them: a groupName there does not move the check to another group.
|
||||
when(ctx.getMethod()).thenReturn("POST");
|
||||
setJsonBody("{\"GroupName\":\"billing\",\"ScheduleExpression\":\"rate(1 hour)\"}");
|
||||
assertEquals("arn:aws:scheduler:us-east-1:000000000000:schedule/billing/nightly",
|
||||
builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
queryParams.putSingle("groupName", "reports");
|
||||
setJsonBody("{\"GroupName\":\"billing\",\"ScheduleExpression\":\"rate(1 hour)\"}");
|
||||
assertEquals("arn:aws:scheduler:us-east-1:000000000000:schedule/billing/nightly",
|
||||
builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
queryParams.clear();
|
||||
when(ctx.getMethod()).thenReturn("PUT");
|
||||
setJsonBody("{\"ScheduleExpression\":\"rate(1 hour)\"}");
|
||||
assertEquals("arn:aws:scheduler:us-east-1:000000000000:schedule/default/nightly",
|
||||
builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
when(ctx.getMethod()).thenReturn("GET");
|
||||
queryParams.clear();
|
||||
when(uriInfo.getPath()).thenReturn("/schedule-groups/reports");
|
||||
assertEquals("arn:aws:scheduler:us-east-1:000000000000:schedule-group/reports",
|
||||
builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
String group = "arn:aws:scheduler:us-east-1:000000000000:schedule-group/reports";
|
||||
when(uriInfo.getPath()).thenReturn("/tags/" + group);
|
||||
assertEquals(group, builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
// The same tagging is served at /tags, the ARN in the resourceArn query parameter or body field.
|
||||
when(uriInfo.getPath()).thenReturn("/tags");
|
||||
queryParams.putSingle("resourceArn", group);
|
||||
assertEquals(group, builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
queryParams.clear();
|
||||
when(ctx.getMethod()).thenReturn("POST");
|
||||
setJsonBody("{\"resourceArn\":\"" + group + "\",\"tags\":[]}");
|
||||
assertEquals(group, builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
// POST /tags tags the body's ARN, so a resourceArn in the query does not move the check.
|
||||
queryParams.putSingle("resourceArn", "arn:aws:scheduler:us-east-1:000000000000:schedule-group/other");
|
||||
setJsonBody("{\"resourceArn\":\"" + group + "\",\"tags\":[]}");
|
||||
assertEquals(group, builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
queryParams.clear();
|
||||
when(uriInfo.getPath()).thenReturn("/schedules");
|
||||
assertEquals("*", builder.build("scheduler", ctx, "us-east-1", "000000000000"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void schedulerAndPipesArnsAreMintedInTheRequestsPartition() {
|
||||
// A Region no partition publishes takes the deployment's partition, as Scheduler and Pipes mint
|
||||
// their ARNs, rather than aws.
|
||||
when(uriInfo.getPath()).thenReturn("/schedules/nightly");
|
||||
assertEquals(List.of("arn:aws-cn:scheduler:xx-local-1:000000000000:schedule/default/nightly"),
|
||||
builder.buildResources("scheduler", ctx, "xx-local-1", "000000000000", "aws-cn"));
|
||||
when(uriInfo.getPath()).thenReturn("/schedule-groups/reports");
|
||||
assertEquals(List.of("arn:aws-cn:scheduler:xx-local-1:000000000000:schedule-group/reports"),
|
||||
builder.buildResources("scheduler", ctx, "xx-local-1", "000000000000", "aws-cn"));
|
||||
when(uriInfo.getPath()).thenReturn("/v1/pipes/orders");
|
||||
assertEquals(List.of("arn:aws-cn:pipes:xx-local-1:000000000000:pipe/orders"),
|
||||
builder.buildResources("pipes", ctx, "xx-local-1", "000000000000", "aws-cn"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theTaggedArnIsReadWhereTheSharedTaggingControllersReadIt() {
|
||||
String arn = "arn:aws:pipes:us-east-1:000000000000:pipe/orders";
|
||||
when(ctx.getMethod()).thenReturn("GET");
|
||||
when(uriInfo.getPath()).thenReturn("/tags/" + arn);
|
||||
assertEquals(arn, builder.taggedArn(ctx));
|
||||
when(uriInfo.getPath()).thenReturn("/v1/tags/" + arn);
|
||||
assertEquals(arn, builder.taggedArn(ctx));
|
||||
when(uriInfo.getPath()).thenReturn("/tags");
|
||||
queryParams.putSingle("resourceArn", arn);
|
||||
assertEquals(arn, builder.taggedArn(ctx));
|
||||
when(ctx.getMethod()).thenReturn("DELETE");
|
||||
assertEquals(arn, builder.taggedArn(ctx));
|
||||
// POST /v1/tags lists the tags of the ARN its query names, and POST /tags tags the one its body names.
|
||||
when(ctx.getMethod()).thenReturn("POST");
|
||||
when(uriInfo.getPath()).thenReturn("/v1/tags");
|
||||
assertEquals(arn, builder.taggedArn(ctx));
|
||||
when(uriInfo.getPath()).thenReturn("/tags");
|
||||
setJsonBody("{\"tags\":[]}");
|
||||
assertNull(builder.taggedArn(ctx));
|
||||
when(uriInfo.getPath()).thenReturn("/v1/pipes/orders");
|
||||
assertNull(builder.taggedArn(ctx));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aStreamingInvokeResolvesItsQualifiedFunctionAsAnInvokeDoes() {
|
||||
// A streaming invoke is an invoke: its qualifier and the account its function ARN names count.
|
||||
@@ -1205,6 +1293,19 @@ class ResourceArnBuilderTest {
|
||||
builder.build("lambda", ctx, "us-east-1", "000000000000"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void pipesRoutesResolveThePipeOrTheTaggedArn() {
|
||||
String pipe = "arn:aws:pipes:us-east-1:000000000000:pipe/orders";
|
||||
when(uriInfo.getPath()).thenReturn("/v1/pipes/orders");
|
||||
assertEquals(pipe, builder.build("pipes", ctx, "us-east-1", "000000000000"));
|
||||
when(uriInfo.getPath()).thenReturn("/v1/pipes/orders/start");
|
||||
assertEquals(pipe, builder.build("pipes", ctx, "us-east-1", "000000000000"));
|
||||
when(uriInfo.getPath()).thenReturn("/tags/" + pipe);
|
||||
assertEquals(pipe, builder.build("pipes", ctx, "us-east-1", "000000000000"));
|
||||
when(uriInfo.getPath()).thenReturn("/v1/pipes");
|
||||
assertEquals("*", builder.build("pipes", ctx, "us-east-1", "000000000000"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void lambdaRoutesOtherThanInvokeAreCheckedAgainstTheCallersUnqualifiedFunction() {
|
||||
when(uriInfo.getPath()).thenReturn(
|
||||
|
||||
Reference in new issue
Block a user