mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(cloudtrail): keep a trail's KMS key and CloudWatch Logs delivery (#6989)
This commit is contained in:
1 parent
02852f0e67
commit
5ad2f64840
7 files changed
+269
-6
No files matched your search
@@ -10,6 +10,7 @@ import software.amazon.awssdk.services.cloudtrail.model.TrailNotFoundException;
|
||||
import software.amazon.awssdk.services.cloudtrail.model.UpdateTrailResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
||||
|
||||
@DisplayName("CloudTrail")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@@ -109,4 +110,33 @@ class CloudTrailTest {
|
||||
assertThatThrownBy(() -> cloudTrail.getTrailStatus(r -> r.name(trailName)))
|
||||
.isInstanceOf(TrailNotFoundException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void encryptionAndCloudWatchLogsRoundTrip() {
|
||||
assumeFalse(TestFixtures.isRealAws(), "Uses placeholder KMS key, log group and role ARNs");
|
||||
String key = "arn:aws:kms:us-east-1:000000000000:key/0f1e2d3c-4b5a-6978-8091-a2b3c4d5e6f7";
|
||||
String group = "arn:aws:logs:us-east-1:000000000000:log-group:/trail:*";
|
||||
String role = "arn:aws:iam::000000000000:role/trail-to-logs";
|
||||
String name = TestFixtures.uniqueName("ct-enc");
|
||||
try {
|
||||
CreateTrailResponse created = cloudTrail.createTrail(r -> r.name(name).s3BucketName(bucketName)
|
||||
.kmsKeyId(key).cloudWatchLogsLogGroupArn(group).cloudWatchLogsRoleArn(role));
|
||||
assertThat(created.kmsKeyId()).isEqualTo(key);
|
||||
assertThat(created.cloudWatchLogsLogGroupArn()).isEqualTo(group);
|
||||
assertThat(created.cloudWatchLogsRoleArn()).isEqualTo(role);
|
||||
|
||||
Trail described = cloudTrail.describeTrails(r -> r.trailNameList(name)).trailList().get(0);
|
||||
assertThat(described.kmsKeyId()).isEqualTo(key);
|
||||
assertThat(described.cloudWatchLogsLogGroupArn()).isEqualTo(group);
|
||||
assertThat(described.cloudWatchLogsRoleArn()).isEqualTo(role);
|
||||
|
||||
UpdateTrailResponse updated = cloudTrail.updateTrail(r -> r.name(name).kmsKeyId(""));
|
||||
assertThat(updated.kmsKeyId()).isNull();
|
||||
assertThat(updated.cloudWatchLogsRoleArn()).isEqualTo(role);
|
||||
assertThat(cloudTrail.describeTrails(r -> r.trailNameList(name)).trailList().get(0).kmsKeyId()).isNull();
|
||||
} finally {
|
||||
cloudTrail.deleteTrail(r -> r.name(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,10 @@ and `AWS::S3::Object` data resource ARNs in any of these forms:
|
||||
- `arn:aws:s3:::bucket/prefix` — keys with the given prefix
|
||||
- `arn:aws:s3:::bucket/prefix/key` — exact key match
|
||||
|
||||
## Encryption and CloudWatch Logs settings
|
||||
|
||||
`CreateTrail` and `UpdateTrail` record `KmsKeyId`, `CloudWatchLogsLogGroupArn` and `CloudWatchLogsRoleArn`, and `DescribeTrails` returns them, so a Terraform `aws_cloudtrail` with encryption or log delivery reads back what it declared. `UpdateTrail` with an empty value clears one, as on AWS. A log group without a role is refused with `InvalidCloudWatchLogsRoleArnException`, and a role without a log group with `InvalidCloudWatchLogsLogGroupArnException`. The settings are recorded only: log files are not encrypted, events are not delivered to the log group, and `KmsKeyId` is stored as sent (an alias is not resolved to the key ARN, and an unknown key is not refused).
|
||||
|
||||
## S3 Hook Coverage
|
||||
|
||||
Floci emits a CloudTrail data event whenever any of these S3 ops runs
|
||||
|
||||
@@ -95,7 +95,8 @@ public record CloudTrailEntry(
|
||||
trail.name(), trail.trailArn(), trail.s3BucketName(), trail.s3KeyPrefix(),
|
||||
trail.snsTopicArn(), trail.includeGlobalServiceEvents(), trail.isMultiRegionTrail(),
|
||||
trail.homeRegion(), trail.logFileValidationEnabled(), hasCustomSelectors,
|
||||
trail.hasInsightSelectors(), trail.isOrganizationTrail());
|
||||
trail.hasInsightSelectors(), trail.isOrganizationTrail(), trail.kmsKeyId(),
|
||||
trail.cloudWatchLogsLogGroupArn(), trail.cloudWatchLogsRoleArn());
|
||||
}
|
||||
|
||||
/** Returns a mutable copy suitable for merging in new tags. */
|
||||
|
||||
+23
-2
@@ -65,7 +65,9 @@ public class CloudTrailJsonHandler {
|
||||
Map<String, String> tags = parseTagsList(req.path("TagsList"));
|
||||
|
||||
Trail trail = service.createTrail(region, name, s3BucketName, s3KeyPrefix, snsTopicArn,
|
||||
includeGlobal, isMultiRegion, enableLogFileValidation, isOrganizationTrail, tags);
|
||||
includeGlobal, isMultiRegion, enableLogFileValidation, isOrganizationTrail, tags,
|
||||
textOrNull(req, "KmsKeyId"), textOrNull(req, "CloudWatchLogsLogGroupArn"),
|
||||
textOrNull(req, "CloudWatchLogsRoleArn"));
|
||||
|
||||
ObjectNode resp = mapper.createObjectNode();
|
||||
resp.put("Name", trail.name());
|
||||
@@ -80,6 +82,9 @@ public class CloudTrailJsonHandler {
|
||||
resp.put("TrailARN", trail.trailArn());
|
||||
resp.put("LogFileValidationEnabled", trail.logFileValidationEnabled());
|
||||
resp.put("IsOrganizationTrail", trail.isOrganizationTrail());
|
||||
putIfSet(resp, "KmsKeyId", trail.kmsKeyId());
|
||||
putIfSet(resp, "CloudWatchLogsLogGroupArn", trail.cloudWatchLogsLogGroupArn());
|
||||
putIfSet(resp, "CloudWatchLogsRoleArn", trail.cloudWatchLogsRoleArn());
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -89,6 +94,17 @@ public class CloudTrailJsonHandler {
|
||||
return Response.ok(mapper.createObjectNode()).build();
|
||||
}
|
||||
|
||||
/** The member's text when present (an empty string included: UpdateTrail uses it to clear a setting). */
|
||||
private static String textOrNull(JsonNode req, String field) {
|
||||
return req.has(field) && !req.get(field).isNull() ? req.get(field).asText() : null;
|
||||
}
|
||||
|
||||
private static void putIfSet(ObjectNode node, String field, String value) {
|
||||
if (value != null) {
|
||||
node.put(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
private Response updateTrail(JsonNode req, String region) {
|
||||
String name = req.path("Name").asText(null);
|
||||
String s3BucketName = req.has("S3BucketName") ? req.path("S3BucketName").asText(null) : null;
|
||||
@@ -105,7 +121,9 @@ public class CloudTrailJsonHandler {
|
||||
? req.path("IsOrganizationTrail").asBoolean() : null;
|
||||
|
||||
Trail trail = service.updateTrail(region, name, s3BucketName, s3KeyPrefix, snsTopicName,
|
||||
includeGlobal, isMultiRegion, enableLogFileValidation, isOrganizationTrail);
|
||||
includeGlobal, isMultiRegion, enableLogFileValidation, isOrganizationTrail,
|
||||
textOrNull(req, "KmsKeyId"), textOrNull(req, "CloudWatchLogsLogGroupArn"),
|
||||
textOrNull(req, "CloudWatchLogsRoleArn"));
|
||||
|
||||
ObjectNode resp = mapper.createObjectNode();
|
||||
resp.put("Name", trail.name());
|
||||
@@ -120,6 +138,9 @@ public class CloudTrailJsonHandler {
|
||||
resp.put("TrailARN", trail.trailArn());
|
||||
resp.put("LogFileValidationEnabled", trail.logFileValidationEnabled());
|
||||
resp.put("IsOrganizationTrail", trail.isOrganizationTrail());
|
||||
putIfSet(resp, "KmsKeyId", trail.kmsKeyId());
|
||||
putIfSet(resp, "CloudWatchLogsLogGroupArn", trail.cloudWatchLogsLogGroupArn());
|
||||
putIfSet(resp, "CloudWatchLogsRoleArn", trail.cloudWatchLogsRoleArn());
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
|
||||
+56
-2
@@ -98,7 +98,23 @@ public class CloudTrailService {
|
||||
String snsTopicArn, boolean includeGlobalServiceEvents,
|
||||
boolean isMultiRegionTrail, boolean enableLogFileValidation,
|
||||
boolean isOrganizationTrail, Map<String, String> tags) {
|
||||
return createTrail(region, name, s3BucketName, s3KeyPrefix, snsTopicArn, includeGlobalServiceEvents,
|
||||
isMultiRegionTrail, enableLogFileValidation, isOrganizationTrail, tags, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param kmsKeyId the key the trail's log files are encrypted with, recorded and
|
||||
* reported back; Floci writes the files unencrypted
|
||||
* @param cloudWatchLogsLogGroupArn the log group events are also delivered to, recorded only
|
||||
* @param cloudWatchLogsRoleArn the role CloudTrail assumes for that delivery
|
||||
*/
|
||||
public Trail createTrail(String region, String name, String s3BucketName, String s3KeyPrefix,
|
||||
String snsTopicArn, boolean includeGlobalServiceEvents,
|
||||
boolean isMultiRegionTrail, boolean enableLogFileValidation,
|
||||
boolean isOrganizationTrail, Map<String, String> tags, String kmsKeyId,
|
||||
String cloudWatchLogsLogGroupArn, String cloudWatchLogsRoleArn) {
|
||||
validateTrailName(name);
|
||||
validateCloudWatchLogs(cloudWatchLogsLogGroupArn, cloudWatchLogsRoleArn);
|
||||
if (s3BucketName == null || s3BucketName.isEmpty()) {
|
||||
throw new AwsException("S3BucketDoesNotExistException", "S3 bucket name is required.", 400);
|
||||
}
|
||||
@@ -118,12 +134,31 @@ public class CloudTrailService {
|
||||
Trail trail = new Trail(
|
||||
name, arn, s3BucketName, s3KeyPrefix, snsTopicArn,
|
||||
includeGlobalServiceEvents, isMultiRegionTrail, region,
|
||||
enableLogFileValidation, false, false, isOrganizationTrail);
|
||||
enableLogFileValidation, false, false, isOrganizationTrail,
|
||||
blankToNull(kmsKeyId), blankToNull(cloudWatchLogsLogGroupArn), blankToNull(cloudWatchLogsRoleArn));
|
||||
store.put(key, new CloudTrailEntry(trail, List.of(), List.of(), false, null, null,
|
||||
initialTags, null, null));
|
||||
return trail;
|
||||
}
|
||||
|
||||
/** CloudTrail needs both halves of CloudWatch Logs delivery, or neither. */
|
||||
private static void validateCloudWatchLogs(String logGroupArn, String roleArn) {
|
||||
boolean group = logGroupArn != null && !logGroupArn.isBlank();
|
||||
boolean role = roleArn != null && !roleArn.isBlank();
|
||||
if (group && !role) {
|
||||
throw new AwsException("InvalidCloudWatchLogsRoleArnException",
|
||||
"You must specify a role ARN when you specify a CloudWatch Logs log group.", 400);
|
||||
}
|
||||
if (role && !group) {
|
||||
throw new AwsException("InvalidCloudWatchLogsLogGroupArnException",
|
||||
"You must specify a log group ARN when you specify a CloudWatch Logs role.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private static String blankToNull(String value) {
|
||||
return value == null || value.isBlank() ? null : value;
|
||||
}
|
||||
|
||||
public void deleteTrail(String region, String trailNameOrArn) {
|
||||
Trail trail = findTrailOrThrow(region, trailNameOrArn);
|
||||
String key = regionKey(trail.homeRegion(), trail.name());
|
||||
@@ -136,6 +171,20 @@ public class CloudTrailService {
|
||||
String s3BucketName, String s3KeyPrefix, String snsTopicArn,
|
||||
Boolean includeGlobalServiceEvents, Boolean isMultiRegionTrail,
|
||||
Boolean enableLogFileValidation, Boolean isOrganizationTrail) {
|
||||
return updateTrail(region, trailNameOrArn, s3BucketName, s3KeyPrefix, snsTopicArn,
|
||||
includeGlobalServiceEvents, isMultiRegionTrail, enableLogFileValidation, isOrganizationTrail,
|
||||
null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* A null KMS or CloudWatch Logs argument leaves the setting as it is; an empty one removes it,
|
||||
* as UpdateTrail does on AWS.
|
||||
*/
|
||||
public Trail updateTrail(String region, String trailNameOrArn,
|
||||
String s3BucketName, String s3KeyPrefix, String snsTopicArn,
|
||||
Boolean includeGlobalServiceEvents, Boolean isMultiRegionTrail,
|
||||
Boolean enableLogFileValidation, Boolean isOrganizationTrail,
|
||||
String kmsKeyId, String cloudWatchLogsLogGroupArn, String cloudWatchLogsRoleArn) {
|
||||
Trail resolved = findTrailOrThrow(region, trailNameOrArn);
|
||||
String key = regionKey(resolved.homeRegion(), resolved.name());
|
||||
return withTrailLock(key, () -> {
|
||||
@@ -154,7 +203,12 @@ public class CloudTrailService {
|
||||
enableLogFileValidation != null ? enableLogFileValidation : existing.logFileValidationEnabled(),
|
||||
existing.hasCustomEventSelectors(),
|
||||
existing.hasInsightSelectors(),
|
||||
isOrganizationTrail != null ? isOrganizationTrail : existing.isOrganizationTrail());
|
||||
isOrganizationTrail != null ? isOrganizationTrail : existing.isOrganizationTrail(),
|
||||
kmsKeyId != null ? blankToNull(kmsKeyId) : existing.kmsKeyId(),
|
||||
cloudWatchLogsLogGroupArn != null
|
||||
? blankToNull(cloudWatchLogsLogGroupArn) : existing.cloudWatchLogsLogGroupArn(),
|
||||
cloudWatchLogsRoleArn != null ? blankToNull(cloudWatchLogsRoleArn) : existing.cloudWatchLogsRoleArn());
|
||||
validateCloudWatchLogs(updated.cloudWatchLogsLogGroupArn(), updated.cloudWatchLogsRoleArn());
|
||||
store.put(key, entry.withTrail(updated));
|
||||
return updated;
|
||||
});
|
||||
|
||||
@@ -20,5 +20,18 @@ public record Trail(
|
||||
@JsonProperty("LogFileValidationEnabled") boolean logFileValidationEnabled,
|
||||
@JsonProperty("HasCustomEventSelectors") boolean hasCustomEventSelectors,
|
||||
@JsonProperty("HasInsightSelectors") boolean hasInsightSelectors,
|
||||
@JsonProperty("IsOrganizationTrail") boolean isOrganizationTrail) {
|
||||
@JsonProperty("IsOrganizationTrail") boolean isOrganizationTrail,
|
||||
@JsonProperty("KmsKeyId") String kmsKeyId,
|
||||
@JsonProperty("CloudWatchLogsLogGroupArn") String cloudWatchLogsLogGroupArn,
|
||||
@JsonProperty("CloudWatchLogsRoleArn") String cloudWatchLogsRoleArn) {
|
||||
|
||||
/** A trail without encryption or CloudWatch Logs delivery. */
|
||||
public Trail(String name, String trailArn, String s3BucketName, String s3KeyPrefix, String snsTopicArn,
|
||||
boolean includeGlobalServiceEvents, boolean isMultiRegionTrail, String homeRegion,
|
||||
boolean logFileValidationEnabled, boolean hasCustomEventSelectors, boolean hasInsightSelectors,
|
||||
boolean isOrganizationTrail) {
|
||||
this(name, trailArn, s3BucketName, s3KeyPrefix, snsTopicArn, includeGlobalServiceEvents, isMultiRegionTrail,
|
||||
homeRegion, logFileValidationEnabled, hasCustomEventSelectors, hasInsightSelectors,
|
||||
isOrganizationTrail, null, null, null);
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package io.github.hectorvent.floci.services.cloudtrail;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
/**
|
||||
* KmsKeyId and CloudWatch Logs delivery round-trip through CreateTrail, DescribeTrails and
|
||||
* UpdateTrail. Terraform's aws_cloudtrail reads them back on every refresh, so a dropped value is
|
||||
* a perpetual diff.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class CloudTrailEncryptionAndLogsIntegrationTest {
|
||||
|
||||
private static final String CT_TARGET = "CloudTrail_20131101.";
|
||||
private static final String JSON11 = "application/x-amz-json-1.1";
|
||||
private static final String KEY = "arn:aws:kms:us-east-1:000000000000:key/0f1e2d3c-4b5a-6978-8091-a2b3c4d5e6f7";
|
||||
private static final String GROUP = "arn:aws:logs:us-east-1:000000000000:log-group:/trail:*";
|
||||
private static final String ROLE = "arn:aws:iam::000000000000:role/trail-to-logs";
|
||||
private static final String KEY2 = "arn:aws:kms:us-east-1:000000000000:key/9a8b7c6d-5e4f-3a2b-1c0d-e9f8a7b6c5d4";
|
||||
private static final String GROUP2 = "arn:aws:logs:us-east-1:000000000000:log-group:/trail-2:*";
|
||||
private static final String ROLE2 = "arn:aws:iam::000000000000:role/trail-to-logs-2";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
private static ValidatableResponse call(String action, String body) {
|
||||
return given().header("X-Amz-Target", CT_TARGET + action).contentType(JSON11).body(body)
|
||||
.when().post("/").then();
|
||||
}
|
||||
|
||||
@Test
|
||||
void encryptionAndCloudWatchLogsRoundTrip() {
|
||||
call("CreateTrail", "{\"Name\":\"enc-trail\",\"S3BucketName\":\"b\",\"KmsKeyId\":\"" + KEY
|
||||
+ "\",\"CloudWatchLogsLogGroupArn\":\"" + GROUP + "\",\"CloudWatchLogsRoleArn\":\"" + ROLE + "\"}")
|
||||
.statusCode(200)
|
||||
.body("KmsKeyId", equalTo(KEY))
|
||||
.body("CloudWatchLogsLogGroupArn", equalTo(GROUP));
|
||||
|
||||
// Selectors rebuild the stored trail; the settings must survive that.
|
||||
call("PutEventSelectors", "{\"TrailName\":\"enc-trail\",\"EventSelectors\":[{\"ReadWriteType\":\"All\","
|
||||
+ "\"IncludeManagementEvents\":true}]}").statusCode(200);
|
||||
call("DescribeTrails", "{\"trailNameList\":[\"enc-trail\"]}")
|
||||
.statusCode(200)
|
||||
.body("trailList[0].KmsKeyId", equalTo(KEY))
|
||||
.body("trailList[0].CloudWatchLogsLogGroupArn", equalTo(GROUP))
|
||||
.body("trailList[0].CloudWatchLogsRoleArn", equalTo(ROLE));
|
||||
|
||||
call("UpdateTrail", "{\"Name\":\"enc-trail\",\"KmsKeyId\":\"\"}")
|
||||
.statusCode(200)
|
||||
.body("KmsKeyId", nullValue())
|
||||
.body("CloudWatchLogsRoleArn", equalTo(ROLE));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cloudWatchLogsNeedsBothTheGroupAndTheRole() {
|
||||
call("CreateTrail", "{\"Name\":\"half-trail\",\"S3BucketName\":\"b\",\"CloudWatchLogsLogGroupArn\":\""
|
||||
+ GROUP + "\"}")
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidCloudWatchLogsRoleArnException"));
|
||||
}
|
||||
|
||||
private static ValidatableResponse describe(String name) {
|
||||
return call("DescribeTrails", "{\"trailNameList\":[\"" + name + "\"]}").statusCode(200);
|
||||
}
|
||||
|
||||
private static void createWithEverything(String name) {
|
||||
call("CreateTrail", "{\"Name\":\"" + name + "\",\"S3BucketName\":\"b\",\"KmsKeyId\":\"" + KEY
|
||||
+ "\",\"CloudWatchLogsLogGroupArn\":\"" + GROUP + "\",\"CloudWatchLogsRoleArn\":\"" + ROLE + "\"}")
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTrailSetsThenReplacesTheKmsKey() {
|
||||
call("CreateTrail", "{\"Name\":\"kms-upd\",\"S3BucketName\":\"b\"}").statusCode(200);
|
||||
|
||||
call("UpdateTrail", "{\"Name\":\"kms-upd\",\"KmsKeyId\":\"" + KEY + "\"}").statusCode(200);
|
||||
describe("kms-upd").body("trailList[0].KmsKeyId", equalTo(KEY));
|
||||
|
||||
call("UpdateTrail", "{\"Name\":\"kms-upd\",\"KmsKeyId\":\"" + KEY2 + "\"}").statusCode(200);
|
||||
describe("kms-upd").body("trailList[0].KmsKeyId", equalTo(KEY2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTrailSetsThenReplacesCloudWatchLogsDelivery() {
|
||||
call("CreateTrail", "{\"Name\":\"cwl-upd\",\"S3BucketName\":\"b\"}").statusCode(200);
|
||||
|
||||
call("UpdateTrail", "{\"Name\":\"cwl-upd\",\"CloudWatchLogsLogGroupArn\":\"" + GROUP
|
||||
+ "\",\"CloudWatchLogsRoleArn\":\"" + ROLE + "\"}").statusCode(200);
|
||||
describe("cwl-upd")
|
||||
.body("trailList[0].CloudWatchLogsLogGroupArn", equalTo(GROUP))
|
||||
.body("trailList[0].CloudWatchLogsRoleArn", equalTo(ROLE));
|
||||
|
||||
call("UpdateTrail", "{\"Name\":\"cwl-upd\",\"CloudWatchLogsLogGroupArn\":\"" + GROUP2
|
||||
+ "\",\"CloudWatchLogsRoleArn\":\"" + ROLE2 + "\"}").statusCode(200);
|
||||
describe("cwl-upd")
|
||||
.body("trailList[0].CloudWatchLogsLogGroupArn", equalTo(GROUP2))
|
||||
.body("trailList[0].CloudWatchLogsRoleArn", equalTo(ROLE2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTrailClearsBothCloudWatchLogsSettings() {
|
||||
createWithEverything("cwl-clear");
|
||||
|
||||
call("UpdateTrail", "{\"Name\":\"cwl-clear\",\"CloudWatchLogsLogGroupArn\":\"\","
|
||||
+ "\"CloudWatchLogsRoleArn\":\"\"}").statusCode(200);
|
||||
describe("cwl-clear")
|
||||
.body("trailList[0].CloudWatchLogsLogGroupArn", nullValue())
|
||||
.body("trailList[0].CloudWatchLogsRoleArn", nullValue())
|
||||
.body("trailList[0].KmsKeyId", equalTo(KEY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTrailRefusesAHalfClearedPairAndKeepsTheTrail() {
|
||||
createWithEverything("cwl-half");
|
||||
|
||||
call("UpdateTrail", "{\"Name\":\"cwl-half\",\"CloudWatchLogsLogGroupArn\":\"\","
|
||||
+ "\"CloudWatchLogsRoleArn\":\"" + ROLE2 + "\",\"KmsKeyId\":\"" + KEY2 + "\"}")
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidCloudWatchLogsLogGroupArnException"));
|
||||
call("UpdateTrail", "{\"Name\":\"cwl-half\",\"CloudWatchLogsLogGroupArn\":\"" + GROUP2
|
||||
+ "\",\"CloudWatchLogsRoleArn\":\"\",\"KmsKeyId\":\"" + KEY2 + "\"}")
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidCloudWatchLogsRoleArnException"));
|
||||
|
||||
describe("cwl-half")
|
||||
.body("trailList[0].KmsKeyId", equalTo(KEY))
|
||||
.body("trailList[0].CloudWatchLogsLogGroupArn", equalTo(GROUP))
|
||||
.body("trailList[0].CloudWatchLogsRoleArn", equalTo(ROLE));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user