mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 17:33:03 -05:00
fix(iam): check seven more services on the resources their requests name (#6976)
Under IAM enforcement, Athena, Data Exports, Pricing Calculator, Cost
Explorer, CloudTrail, Global Accelerator and Timestream for InfluxDB
requests were checked on `*`, so a grant scoped to a workgroup, an
export, a workload estimate, an anomaly monitor, a trail, an
accelerator or a parameter group was refused, and a deny scoped to one
never applied.
The generated table of the resources requests name now reads them, 305
operations, from AWS's Service Reference and botocore as it reads the
first four batches: their namespaces move from the generator's
NOT_COVERED to NAMESPACES and the table is regenerated, nothing in it
edited by hand; 1022 operations over 24 namespaces. Each resource
type's ARN format is the one Floci mints or reads: Athena's
`workgroup/<name>` and `datacatalog/<name>` (its tag handler parses
them), `export/<name>`, Cost Explorer's `anomalymonitor/<id>` and
Global Accelerator's `accelerator/<id>` with no Region, listeners and
endpoint groups under the accelerator's, `trail/<name>`, and Timestream
for InfluxDB's `<type>/<id>`.
Corrections, each with its reason:
- Athena's StartQueryExecution, ListQueryExecutions and ListNamedQueries
naming no workgroup are checked on the primary one, where Athena runs
and lists them ("If a workgroup is not specified, returns a list of
query execution IDs for the primary workgroup"), and so is
GetWorkGroup, which Floci answers with the primary one then. Floci's
StartQueryExecution and GetWorkGroup handlers now read a JSON null
WorkGroup as none, as ListQueryExecutions does, rather than as a
workgroup named "null", so the workgroup checked is the one acted on.
- Athena's ListDatabases, ListTableMetadata and GetTableMetadata are
checked on AwsDataCatalog, the Glue Data Catalog Floci reads
whichever catalog they name, as well as on the one their CatalogName
names.
- Cost Explorer's nine cost and usage reads are checked on `*`, not on
their BillingViewArn: Floci serves no billing views and answers the
account's costs whichever view is named, so a grant scoped to one
must not reach them.
- Data Exports' CreateExport is not checked on its Export.ExportArn,
the ARN "for this export", which the request creates; its pattern
takes a table's, so a caller could choose the table checked.
- CloudTrail's StartLogging, StopLogging and GetTrailStatus name their
trail by a bare Name, a name or an ARN, AddTags, RemoveTags and
ListTags their resources by the ARNs in ResourceId and
ResourceIdList, members whose names do not end in Arn, and the
dashboard operations their dashboard by DashboardId, a name or an
ARN.
- Cost Explorer's GetAnomalyMonitors and GetAnomalySubscriptions name
their monitors and subscriptions by the ARNs in MonitorArnList and
SubscriptionArnList; GetAnomalySubscriptions' MonitorArn, a
monitor's ARN, is not read as a subscription's.
- Timestream for InfluxDB's RebootDbCluster is checked on each member
instance its instanceIds names as well as on the cluster.
- Global Accelerator's ListCustomRoutingPortMappings is checked on its
accelerator alone: its EndpointGroupArn extends the accelerator's ARN
and so matched the accelerator's format.
Not read yet, each with its reason in NOT_COVERED: CodeDeploy, whose
on-premises instance format the Service Reference gives as
`instance:${InstanceName}` while the CodeDeploy permissions reference
gives `instance/instance-ID` and AWS's GetOnPremisesInstance example
answers `instance/<name>_<id>`; Redshift Data, whose serverless
workgroup's ARN ends in an id the service mints while its requests name
the workgroup by WorkgroupName; and Service Catalog, whose
*PortfolioShare requests give in AccountId the account a portfolio is
shared with, whose imported portfolios and products keep their owner's
account while requests name them by id, and whose AppRegistry half is
named in the path.
This commit is contained in:
1 parent
931b2d26a7
commit
ca3599f8c9
7 files changed
+703
-24
No files matched your search
+13
@@ -35,6 +35,19 @@ class AthenaGetWorkGroupIntegrationTest {
|
||||
equalTo("Athena engine version 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWorkGroupNamingNullReturnsPrimary() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.GetWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{ \"WorkGroup\": null }")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("WorkGroup.Name", equalTo("primary"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWorkGroupReturnsCreatedWorkGroupDetails() {
|
||||
given()
|
||||
|
||||
@@ -554,4 +554,28 @@ class AthenaIntegrationTest {
|
||||
.statusCode(200)
|
||||
.body("QueryExecution.Status.State", equalTo("SUCCEEDED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
void startQueryExecutionNamingNullRunsInPrimary() {
|
||||
String id = given()
|
||||
.header("X-Amz-Target", "AmazonAthena.StartQueryExecution")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{ \"QueryString\": \"SELECT 1\", \"WorkGroup\": null }")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("QueryExecutionId");
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.GetQueryExecution")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{ \"QueryExecutionId\": \"" + id + "\" }")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("QueryExecution.WorkGroup", equalTo("primary"));
|
||||
}
|
||||
}
|
||||
+261
-1
@@ -778,6 +778,247 @@ class IamRequestResourceEnforcementIntegrationTest {
|
||||
refusedJson(describeApplication(user, name + "-other"), "kinesisanalytics:DescribeApplication");
|
||||
}
|
||||
|
||||
/**
|
||||
* An Athena query is checked on the workgroup its request names, the primary one when it names none, where Athena
|
||||
* runs and lists it.
|
||||
*/
|
||||
@Test
|
||||
void aQueryNamingNoWorkgroupIsCheckedOnThePrimaryOne() {
|
||||
String primary = "arn:aws:athena:" + REGION + ":" + ACCOUNT + ":workgroup/primary";
|
||||
User user = user("res-athena");
|
||||
user.policy(allowOn("athena:ListQueryExecutions", primary) + "," + allowOn("athena:GetWorkGroup", primary) + ","
|
||||
+ allowOn("athena:StartQueryExecution", "*") + ",{\"Effect\":\"Deny\",\"Action\":"
|
||||
+ "\"athena:StartQueryExecution\",\"Resource\":\"" + primary + "\"}");
|
||||
send(user, "athena", "AmazonAthena.ListQueryExecutions", "1.1", "{}").statusCode(200);
|
||||
send(user, "athena", "AmazonAthena.GetWorkGroup", "1.1", "{}").statusCode(200);
|
||||
send(user, "athena", "AmazonAthena.GetWorkGroup", "1.1", "{\"WorkGroup\":null}").statusCode(200)
|
||||
.body("WorkGroup.Name", equalTo("primary"));
|
||||
refusedJson(send(user, "athena", "AmazonAthena.ListQueryExecutions", "1.1", "{\"WorkGroup\":\"res-other\"}"),
|
||||
"athena:ListQueryExecutions");
|
||||
refusedJson(send(user, "athena", "AmazonAthena.StartQueryExecution", "1.1", "{\"QueryString\":\"SELECT 1\"}"),
|
||||
"athena:StartQueryExecution");
|
||||
}
|
||||
|
||||
/**
|
||||
* An Athena catalog read is checked on the catalog its {@code CatalogName} names and on {@code AwsDataCatalog},
|
||||
* the Glue Data Catalog Floci reads whichever it names, so a grant on another catalog alone does not reach it.
|
||||
*/
|
||||
@Test
|
||||
void aCatalogReadIsCheckedOnTheGlueCatalogFlociReads() {
|
||||
String catalogs = "arn:aws:athena:" + REGION + ":" + ACCOUNT + ":datacatalog/";
|
||||
User both = user("res-catalogs");
|
||||
both.policy(allowOn("athena:ListDatabases", catalogs + "AwsDataCatalog") + ","
|
||||
+ allowOn("athena:ListDatabases", catalogs + "res-allowed"));
|
||||
send(both, "athena", "AmazonAthena.ListDatabases", "1.1", "{\"CatalogName\":\"res-allowed\"}").statusCode(200);
|
||||
refusedJson(send(both, "athena", "AmazonAthena.ListDatabases", "1.1", "{\"CatalogName\":\"res-other\"}"),
|
||||
"athena:ListDatabases");
|
||||
User named = user("res-catalog");
|
||||
named.policy(allowOn("athena:ListDatabases", catalogs + "res-allowed"));
|
||||
refusedJson(send(named, "athena", "AmazonAthena.ListDatabases", "1.1", "{\"CatalogName\":\"res-allowed\"}"),
|
||||
"athena:ListDatabases");
|
||||
}
|
||||
|
||||
/**
|
||||
* A Data Exports export is checked on its ARN, and a create not on the ARN its {@code Export.ExportArn} gives,
|
||||
* which is the new export's own, so a table's there checks nothing.
|
||||
*/
|
||||
@Test
|
||||
void anExportIsCheckedOnItsArnNotOnATableItsExportArnGives() {
|
||||
String name = "res-export-" + suffix();
|
||||
String arn = adminJson("bcm-data-exports", "AWSBillingAndCostManagementDataExports.CreateExport")
|
||||
.body("{\"Export\":" + export(name, null) + "}").post("/").then().statusCode(200).extract()
|
||||
.path("ExportArn");
|
||||
cleanup.register(() -> adminJson("bcm-data-exports", "AWSBillingAndCostManagementDataExports.DeleteExport")
|
||||
.body("{\"ExportArn\":\"" + arn + "\"}").post("/"));
|
||||
String table = "arn:aws:bcm-data-exports:" + REGION + ":" + ACCOUNT + ":table/COST_AND_USAGE_REPORT";
|
||||
|
||||
User user = user("res-export");
|
||||
user.policy(allowOn("bcm-data-exports:GetExport", arn) + "," + allowOn("bcm-data-exports:CreateExport", table));
|
||||
send(user, "bcm-data-exports", "AWSBillingAndCostManagementDataExports.GetExport", "1.1",
|
||||
"{\"ExportArn\":\"" + arn + "\"}").statusCode(200);
|
||||
refusedJson(send(user, "bcm-data-exports", "AWSBillingAndCostManagementDataExports.GetExport", "1.1",
|
||||
"{\"ExportArn\":\"" + arn + "-other\"}"), "bcm-data-exports:GetExport");
|
||||
refusedJson(send(user, "bcm-data-exports", "AWSBillingAndCostManagementDataExports.CreateExport", "1.1",
|
||||
"{\"Export\":" + export(name + "-other", table) + "}"), "bcm-data-exports:CreateExport");
|
||||
}
|
||||
|
||||
/** A Pricing Calculator workload estimate is checked on {@code workload-estimate/<id>}, with no Region. */
|
||||
@Test
|
||||
void aWorkloadEstimateIsCheckedOnTheArnItsIdGives() {
|
||||
String id = adminJson("bcm-pricing-calculator", "AWSBCMPricingCalculator.CreateWorkloadEstimate", "1.0")
|
||||
.body("{\"name\":\"res-estimate\",\"clientToken\":\"" + suffix() + "\"}").post("/").then()
|
||||
.statusCode(200).extract().path("id");
|
||||
cleanup.register(() -> adminJson("bcm-pricing-calculator", "AWSBCMPricingCalculator.DeleteWorkloadEstimate",
|
||||
"1.0").body("{\"identifier\":\"" + id + "\"}").post("/"));
|
||||
|
||||
User user = user("res-estimate");
|
||||
user.policy(allowOn("bcm-pricing-calculator:GetWorkloadEstimate",
|
||||
"arn:aws:bcm-pricing-calculator::" + ACCOUNT + ":workload-estimate/" + id));
|
||||
send(user, "bcm-pricing-calculator", "AWSBCMPricingCalculator.GetWorkloadEstimate", "1.0",
|
||||
"{\"identifier\":\"" + id + "\"}").statusCode(200);
|
||||
refusedJson(send(user, "bcm-pricing-calculator", "AWSBCMPricingCalculator.GetWorkloadEstimate", "1.0",
|
||||
"{\"identifier\":\"" + UUID.randomUUID() + "\"}"), "bcm-pricing-calculator:GetWorkloadEstimate");
|
||||
}
|
||||
|
||||
/**
|
||||
* A Cost Explorer anomaly monitor or subscription is checked on its ARN, which carries no Region, and a list of
|
||||
* them on each ARN its list gives.
|
||||
*/
|
||||
@Test
|
||||
void anAnomalyMonitorOrSubscriptionIsCheckedOnItsArn() {
|
||||
String arn = adminJson("ce", "AWSInsightsIndexService.CreateAnomalyMonitor").body("{\"AnomalyMonitor\":"
|
||||
+ "{\"MonitorName\":\"res-monitor\",\"MonitorType\":\"DIMENSIONAL\",\"MonitorDimension\":\"SERVICE\"}}")
|
||||
.post("/").then().statusCode(200).extract().path("MonitorArn");
|
||||
cleanup.register(() -> adminJson("ce", "AWSInsightsIndexService.DeleteAnomalyMonitor")
|
||||
.body("{\"MonitorArn\":\"" + arn + "\"}").post("/"));
|
||||
assertTrue(arn.startsWith("arn:aws:ce::" + ACCOUNT + ":anomalymonitor/"), arn);
|
||||
String subscription = adminJson("ce", "AWSInsightsIndexService.CreateAnomalySubscription")
|
||||
.body("{\"AnomalySubscription\":{\"SubscriptionName\":\"res-subscription\",\"Frequency\":\"DAILY\","
|
||||
+ "\"MonitorArnList\":[\"" + arn + "\"],\"Subscribers\":[{\"Address\":\"alerts@example.com\","
|
||||
+ "\"Type\":\"EMAIL\"}],\"ThresholdExpression\":{\"Dimensions\":{\"Key\":"
|
||||
+ "\"ANOMALY_TOTAL_IMPACT_ABSOLUTE\",\"Values\":[\"100\"],\"MatchOptions\":"
|
||||
+ "[\"GREATER_THAN_OR_EQUAL\"]}}}}")
|
||||
.post("/").then().statusCode(200).extract().path("SubscriptionArn");
|
||||
cleanup.register(() -> adminJson("ce", "AWSInsightsIndexService.DeleteAnomalySubscription")
|
||||
.body("{\"SubscriptionArn\":\"" + subscription + "\"}").post("/"));
|
||||
String otherMonitor = arn.substring(0, arn.lastIndexOf('/') + 1) + UUID.randomUUID();
|
||||
String otherSubscription = subscription.substring(0, subscription.lastIndexOf('/') + 1) + UUID.randomUUID();
|
||||
|
||||
User user = user("res-monitor");
|
||||
user.policy(allowOn("ce:UpdateAnomalyMonitor", arn) + "," + allowOn("ce:GetAnomalyMonitors", arn) + ","
|
||||
+ allowOn("ce:GetAnomalySubscriptions", subscription));
|
||||
send(user, "ce", "AWSInsightsIndexService.UpdateAnomalyMonitor", "1.1", "{\"MonitorArn\":\"" + arn
|
||||
+ "\",\"MonitorName\":\"res-renamed\"}").statusCode(200);
|
||||
refusedJson(send(user, "ce", "AWSInsightsIndexService.UpdateAnomalyMonitor", "1.1", "{\"MonitorArn\":\""
|
||||
+ otherMonitor + "\",\"MonitorName\":\"res-renamed\"}"), "ce:UpdateAnomalyMonitor");
|
||||
send(user, "ce", "AWSInsightsIndexService.GetAnomalyMonitors", "1.1", "{\"MonitorArnList\":[\"" + arn
|
||||
+ "\"]}").statusCode(200);
|
||||
refusedJson(send(user, "ce", "AWSInsightsIndexService.GetAnomalyMonitors", "1.1", "{\"MonitorArnList\":[\""
|
||||
+ arn + "\",\"" + otherMonitor + "\"]}"), "ce:GetAnomalyMonitors");
|
||||
send(user, "ce", "AWSInsightsIndexService.GetAnomalySubscriptions", "1.1", "{\"SubscriptionArnList\":[\""
|
||||
+ subscription + "\"]}").statusCode(200);
|
||||
refusedJson(send(user, "ce", "AWSInsightsIndexService.GetAnomalySubscriptions", "1.1",
|
||||
"{\"SubscriptionArnList\":[\"" + otherSubscription + "\"]}"), "ce:GetAnomalySubscriptions");
|
||||
}
|
||||
|
||||
/**
|
||||
* A Cost Explorer cost read is checked on {@code *}, not on the billing view its {@code BillingViewArn} gives:
|
||||
* Floci serves no billing views and answers the account's costs whichever it names.
|
||||
*/
|
||||
@Test
|
||||
void aBillingViewGrantDoesNotReachTheAccountsCosts() {
|
||||
String view = "arn:aws:billing::" + ACCOUNT + ":billingview/res-view";
|
||||
User user = user("res-view");
|
||||
user.policy(allowOn("ce:GetCostAndUsage", view));
|
||||
refusedJson(send(user, "ce", "AWSInsightsIndexService.GetCostAndUsage", "1.1", "{\"TimePeriod\":{\"Start\":"
|
||||
+ "\"2026-01-01\",\"End\":\"2026-02-01\"},\"Granularity\":\"MONTHLY\",\"Metrics\":[\"UnblendedCost\"],"
|
||||
+ "\"BillingViewArn\":\"" + view + "\"}"), "ce:GetCostAndUsage");
|
||||
}
|
||||
|
||||
/**
|
||||
* A trail is checked on {@code trail/<name>}: its status on the one its bare {@code Name} names, by its name or its
|
||||
* ARN, and its tags on the one the ARN in its {@code ResourceId} gives.
|
||||
*/
|
||||
@Test
|
||||
void aTrailIsCheckedOnTheArnItsNameGives() {
|
||||
String name = "res-trail-" + suffix();
|
||||
String other = name + "-other";
|
||||
for (String trail : List.of(name, other)) {
|
||||
adminJson("cloudtrail", "CloudTrail_20131101.CreateTrail")
|
||||
.body("{\"Name\":\"" + trail + "\",\"S3BucketName\":\"res-trail-logs\"}").post("/").then()
|
||||
.statusCode(200);
|
||||
cleanup.register(() -> adminJson("cloudtrail", "CloudTrail_20131101.DeleteTrail")
|
||||
.body("{\"Name\":\"" + trail + "\"}").post("/"));
|
||||
}
|
||||
String arn = "arn:aws:cloudtrail:" + REGION + ":" + ACCOUNT + ":trail/" + name;
|
||||
|
||||
User user = user("res-trail");
|
||||
user.policy(allowOn("cloudtrail:GetTrailStatus", arn) + "," + allowOn("cloudtrail:AddTags", arn));
|
||||
send(user, "cloudtrail", "CloudTrail_20131101.GetTrailStatus", "1.1", "{\"Name\":\"" + name + "\"}")
|
||||
.statusCode(200);
|
||||
send(user, "cloudtrail", "CloudTrail_20131101.GetTrailStatus", "1.1", "{\"Name\":\"" + arn + "\"}")
|
||||
.statusCode(200);
|
||||
refusedJson(send(user, "cloudtrail", "CloudTrail_20131101.GetTrailStatus", "1.1",
|
||||
"{\"Name\":\"" + other + "\"}"), "cloudtrail:GetTrailStatus");
|
||||
String tags = "\",\"TagsList\":[{\"Key\":\"a\",\"Value\":\"b\"}]}";
|
||||
send(user, "cloudtrail", "CloudTrail_20131101.AddTags", "1.1", "{\"ResourceId\":\"" + arn + tags)
|
||||
.statusCode(200);
|
||||
refusedJson(send(user, "cloudtrail", "CloudTrail_20131101.AddTags", "1.1",
|
||||
"{\"ResourceId\":\"" + arn + "-other" + tags), "cloudtrail:AddTags");
|
||||
}
|
||||
|
||||
/** A CloudTrail dashboard is checked on the one its {@code DashboardId}, a name or an ARN, names. */
|
||||
@Test
|
||||
void aDashboardIsCheckedOnTheOneItsIdNames() {
|
||||
String dashboard = "arn:aws:cloudtrail:" + REGION + ":" + ACCOUNT + ":dashboard/res-denied";
|
||||
User user = user("res-dashboard");
|
||||
user.policy(allowOn("cloudtrail:GetDashboard", "*") + ",{\"Effect\":\"Deny\",\"Action\":"
|
||||
+ "\"cloudtrail:GetDashboard\",\"Resource\":\"" + dashboard + "\"}");
|
||||
refusedJson(send(user, "cloudtrail", "CloudTrail_20131101.GetDashboard", "1.1",
|
||||
"{\"DashboardId\":\"res-denied\"}"), "cloudtrail:GetDashboard");
|
||||
refusedJson(send(user, "cloudtrail", "CloudTrail_20131101.GetDashboard", "1.1",
|
||||
"{\"DashboardId\":\"" + dashboard + "\"}"), "cloudtrail:GetDashboard");
|
||||
send(user, "cloudtrail", "CloudTrail_20131101.GetDashboard", "1.1", "{\"DashboardId\":\"res-other\"}")
|
||||
.body(not(containsString("not authorized")));
|
||||
}
|
||||
|
||||
/**
|
||||
* A Global Accelerator accelerator is checked on its ARN, which carries no Region, and listing its custom routing
|
||||
* port mappings on it alone, not on the endpoint group whose ARN extends it.
|
||||
*/
|
||||
@Test
|
||||
void anAcceleratorIsCheckedOnItsArnNotOnAnEndpointGroupOfIt() {
|
||||
String arn = adminJson("globalaccelerator", "GlobalAccelerator_V20180706.CreateAccelerator")
|
||||
.body("{\"Name\":\"res-accelerator\",\"IdempotencyToken\":\"" + suffix() + "\",\"Enabled\":false}")
|
||||
.post("/").then().statusCode(200).extract().path("Accelerator.AcceleratorArn");
|
||||
cleanup.register(() -> adminJson("globalaccelerator", "GlobalAccelerator_V20180706.DeleteAccelerator")
|
||||
.body("{\"AcceleratorArn\":\"" + arn + "\"}").post("/"));
|
||||
assertTrue(arn.startsWith("arn:aws:globalaccelerator::" + ACCOUNT + ":accelerator/"), arn);
|
||||
|
||||
User user = user("res-accelerator");
|
||||
user.policy(allowOn("globalaccelerator:DescribeAccelerator", arn) + ","
|
||||
+ allowOn("globalaccelerator:ListCustomRoutingPortMappings", arn));
|
||||
send(user, "globalaccelerator", "GlobalAccelerator_V20180706.DescribeAccelerator", "1.1",
|
||||
"{\"AcceleratorArn\":\"" + arn + "\"}").statusCode(200);
|
||||
refusedJson(send(user, "globalaccelerator", "GlobalAccelerator_V20180706.DescribeAccelerator", "1.1",
|
||||
"{\"AcceleratorArn\":\"" + arn + "-other\"}"), "globalaccelerator:DescribeAccelerator");
|
||||
send(user, "globalaccelerator", "GlobalAccelerator_V20180706.ListCustomRoutingPortMappings", "1.1",
|
||||
"{\"AcceleratorArn\":\"" + arn + "\",\"EndpointGroupArn\":\"" + arn
|
||||
+ "/listener/0123abcd/endpoint-group/0123456789ab\"}")
|
||||
.body(not(containsString("not authorized")));
|
||||
}
|
||||
|
||||
/** A Timestream for InfluxDB parameter group is checked on {@code db-parameter-group/<id>}, the id it was given. */
|
||||
@Test
|
||||
void aParameterGroupIsCheckedOnTheArnItsIdGives() {
|
||||
String id = adminJson("timestream-influxdb", "AmazonTimestreamInfluxDB.CreateDbParameterGroup", "1.0")
|
||||
.body("{\"name\":\"res-group-" + suffix() + "\"}").post("/").then().statusCode(200).extract()
|
||||
.path("id");
|
||||
String arn = "arn:aws:timestream-influxdb:" + REGION + ":" + ACCOUNT + ":db-parameter-group/" + id;
|
||||
|
||||
User user = user("res-group");
|
||||
user.policy(allowOn("timestream-influxdb:GetDbParameterGroup", arn));
|
||||
send(user, "timestream-influxdb", "AmazonTimestreamInfluxDB.GetDbParameterGroup", "1.0",
|
||||
"{\"identifier\":\"" + id + "\"}").statusCode(200).body("arn", equalTo(arn));
|
||||
refusedJson(send(user, "timestream-influxdb", "AmazonTimestreamInfluxDB.GetDbParameterGroup", "1.0",
|
||||
"{\"identifier\":\"res" + suffix() + "\"}"), "timestream-influxdb:GetDbParameterGroup");
|
||||
}
|
||||
|
||||
/** A Timestream for InfluxDB cluster reboot is checked on each member instance its {@code instanceIds} names. */
|
||||
@Test
|
||||
void aClusterRebootIsCheckedOnTheInstancesItNames() {
|
||||
User user = user("res-reboot");
|
||||
user.policy(allowOn("timestream-influxdb:RebootDbCluster", "*") + ",{\"Effect\":\"Deny\",\"Action\":"
|
||||
+ "\"timestream-influxdb:RebootDbCluster\",\"Resource\":\"arn:aws:timestream-influxdb:" + REGION + ":"
|
||||
+ ACCOUNT + ":db-instance/resdenied\"}");
|
||||
refusedJson(send(user, "timestream-influxdb", "AmazonTimestreamInfluxDB.RebootDbCluster", "1.0",
|
||||
"{\"dbClusterId\":\"rescluster\",\"instanceIds\":[\"resallowed\",\"resdenied\"]}"),
|
||||
"timestream-influxdb:RebootDbCluster");
|
||||
send(user, "timestream-influxdb", "AmazonTimestreamInfluxDB.RebootDbCluster", "1.0",
|
||||
"{\"dbClusterId\":\"rescluster\",\"instanceIds\":[\"resallowed\"]}")
|
||||
.body(containsString("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
/**
|
||||
* A budget is checked on {@code budget/<name>}, with no Region, the ARN Budgets tags it under, and an update on the
|
||||
* budget its {@code NewBudget} names, not on one its billing view ARN gives.
|
||||
@@ -907,8 +1148,27 @@ class IamRequestResourceEnforcementIntegrationTest {
|
||||
.body("{\"ApplicationName\":\"" + name + "\"}").post("/").then();
|
||||
}
|
||||
|
||||
/** The user's JSON-protocol request to the target, {@code <prefix>.<operation>}, with the body. */
|
||||
private static ValidatableResponse send(User user, String service, String target, String version, String body) {
|
||||
return user.json(service, target, version).body(body).post("/").then();
|
||||
}
|
||||
|
||||
/** A Data Exports export of the name reading the cost and usage table, with an export ARN when one is given. */
|
||||
private static String export(String name, String exportArn) {
|
||||
return "{\"Name\":\"" + name + "\"," + (exportArn == null ? "" : "\"ExportArn\":\"" + exportArn + "\",")
|
||||
+ "\"DataQuery\":{\"QueryStatement\":\"SELECT * FROM COST_AND_USAGE_REPORT\"},"
|
||||
+ "\"DestinationConfigurations\":{\"S3Destination\":{\"S3Bucket\":\"my-bucket\",\"S3Prefix\":\"out/\","
|
||||
+ "\"S3Region\":\"" + REGION + "\",\"S3OutputConfigurations\":{\"Format\":\"PARQUET\",\"Compression\":"
|
||||
+ "\"PARQUET\",\"OutputType\":\"CUSTOM\",\"Overwrite\":\"OVERWRITE_REPORT\"}}},"
|
||||
+ "\"RefreshCadence\":{\"Frequency\":\"SYNCHRONOUS\"}}";
|
||||
}
|
||||
|
||||
private static RequestSpecification adminJson(String service, String target) {
|
||||
return admin(service).header("X-Amz-Target", target).contentType("application/x-amz-json-1.1");
|
||||
return adminJson(service, target, "1.1");
|
||||
}
|
||||
|
||||
private static RequestSpecification adminJson(String service, String target, String version) {
|
||||
return admin(service).header("X-Amz-Target", target).contentType("application/x-amz-json-" + version);
|
||||
}
|
||||
|
||||
private static ValidatableResponse describeDeliveryStream(User user, String name) {
|
||||
|
||||
Reference in new issue
Block a user