fix(msk): default EncryptionInTransit clientBroker to TLS (#7054)

CreateCluster that omit EncryptionInfo or clientBroker described
TLS_PLAINTEXT, but the MSK API and CloudFormation schema both name the
default as TLS. An explicitly supplied value still echoes as shipped.

Closes #6968

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
Co-authored-by: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
This commit is contained in:
Matheus OliveiraandPriamo Germosen authored and GitHub committed 2026-10-31 11:31:27 -04:00
1 parent 264513650c
commit f21b371c43
4 files changed
+61 -8

No files matched your search

@@ -228,10 +228,35 @@ class MskControllerIntegrationTest {
.then()
.statusCode(200)
.body("clusterInfo.enhancedMonitoring", equalTo("DEFAULT"))
.body("clusterInfo.encryptionInfo.encryptionInTransit.clientBroker", equalTo("TLS_PLAINTEXT"))
.body("clusterInfo.encryptionInfo.encryptionInTransit.clientBroker", equalTo("TLS"))
.body("clusterInfo.encryptionInfo.encryptionInTransit.inCluster", equalTo(true));
}
// An explicitly requested clientBroker is echoed as-is, including TLS_PLAINTEXT, which is
// now different from the default rather than the default itself.
@Test
void createClusterV1EchoesAnExplicitEncryptionInTransitClientBroker() {
String clusterArn = given()
.contentType("application/json")
.body("""
{"clusterName": "v1-explicit-client-broker-test", "kafkaVersion": "3.6.0",
"numberOfBrokerNodes": 1,
"encryptionInfo": {"encryptionInTransit": {"clientBroker": "TLS_PLAINTEXT"}}}
""")
.when()
.post("/v1/clusters")
.then()
.statusCode(200)
.extract().path("clusterArn");
given()
.when()
.get("/v1/clusters/{clusterArn}", clusterArn)
.then()
.statusCode(200)
.body("clusterInfo.encryptionInfo.encryptionInTransit.clientBroker", equalTo("TLS_PLAINTEXT"));
}
// The v2 ClusterInfo is not the flat v1 shape: everything provisioned-specific nests under
// "provisioned", which is the only place an AWS SDK v2 client looks for it.
@Test
@@ -1345,7 +1370,7 @@ class MskControllerIntegrationTest {
.header("X-Amz-Target", "secretsmanager.CreateSecret")
.body(Map.of(
"Name", "AmazonMSK_" + UUID.randomUUID(),
"KmsKeyId", createScramKey(),
"KmsKeyId", createScramKey(),
"SecretString", "{\"username\":\"alice\",\"password\":\"password\"}")
)
.when()
@@ -81,7 +81,7 @@ class MskServiceTest {
config = Mockito.mock(EmulatorConfig.class);
EmulatorConfig.ServicesConfig servicesConfig = Mockito.mock(EmulatorConfig.ServicesConfig.class);
EmulatorConfig.MskServiceConfig mskConfig = Mockito.mock(EmulatorConfig.MskServiceConfig.class);
when(config.services()).thenReturn(servicesConfig);
when(servicesConfig.msk()).thenReturn(mskConfig);
when(mskConfig.mock()).thenReturn(true);
@@ -373,10 +373,38 @@ class MskServiceTest {
MskCluster cluster = mskService.createCluster(request);
assertEquals("DEFAULT", cluster.getEnhancedMonitoring());
assertEquals("TLS_PLAINTEXT", cluster.getEncryptionInfo().getEncryptionInTransit().getClientBroker());
assertEquals("TLS", cluster.getEncryptionInfo().getEncryptionInTransit().getClientBroker());
assertTrue(cluster.getEncryptionInfo().getEncryptionInTransit().getInCluster());
}
@Test
void createClusterDefaultsClientBrokerWhenOnlySomeEncryptionMembersAreAbsent() {
EncryptionInfo onlyEncryptionInfo = new EncryptionInfo();
CreateClusterRequest withoutTransit = new CreateClusterRequest();
withoutTransit.setClusterName("partial-encryption-no-transit-cluster");
withoutTransit.setKafkaVersion("3.6.0");
withoutTransit.setEncryptionInfo(onlyEncryptionInfo);
MskCluster withoutTransitCluster = mskService.createCluster(withoutTransit);
assertEquals("TLS", withoutTransitCluster.getEncryptionInfo().getEncryptionInTransit().getClientBroker());
assertTrue(withoutTransitCluster.getEncryptionInfo().getEncryptionInTransit().getInCluster());
EncryptionInTransit onlyInCluster = new EncryptionInTransit();
onlyInCluster.setInCluster(false);
EncryptionInfo withoutClientBroker = new EncryptionInfo();
withoutClientBroker.setEncryptionInTransit(onlyInCluster);
CreateClusterRequest noClientBroker = new CreateClusterRequest();
noClientBroker.setClusterName("partial-encryption-no-client-broker-cluster");
noClientBroker.setKafkaVersion("3.6.0");
noClientBroker.setEncryptionInfo(withoutClientBroker);
MskCluster withoutClientBrokerCluster = mskService.createCluster(noClientBroker);
assertEquals("TLS", withoutClientBrokerCluster.getEncryptionInfo().getEncryptionInTransit().getClientBroker());
assertFalse(withoutClientBrokerCluster.getEncryptionInfo().getEncryptionInTransit().getInCluster());
}
@Test
void createClusterDoesNotOverrideExplicitlyRequestedEncryptionInTransit() {
CreateClusterRequest request = new CreateClusterRequest();