mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
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:
1 parent
264513650c
commit
f21b371c43
4 files changed
+61
-8
No files matched your search
@@ -78,7 +78,7 @@ Two details worth knowing:
|
||||
`configurationRevision`, which is where the Terraform AWS provider reads it from.
|
||||
- Members AWS defaults server-side are defaulted here too, so a `terraform plan` converges:
|
||||
`enhancedMonitoring` becomes `DEFAULT`, and `encryptionInfo.encryptionInTransit` becomes
|
||||
`clientBroker: TLS_PLAINTEXT` / `inCluster: true` when the request omits them.
|
||||
`clientBroker: TLS` / `inCluster: true` when the request omits them.
|
||||
|
||||
### Serverless clusters
|
||||
|
||||
@@ -116,7 +116,7 @@ Cluster and configuration tags are managed through `/v1/tags/{resourceArn}`
|
||||
Configuration tags are reachable only through the tag endpoints, because AWS's
|
||||
`DescribeConfiguration` response has no tags member.
|
||||
|
||||
### SCRAM Secrets Association
|
||||
### SCRAM Secrets Association
|
||||
|
||||
Manages credentials only: the broker does not enable SASL authentication or
|
||||
validate these users when clients connect. Clients can still connect without
|
||||
|
||||
@@ -52,7 +52,7 @@ public class MskService implements ResourceProvider {
|
||||
private static final Logger LOG = Logger.getLogger(MskService.class);
|
||||
private static final String DEFAULT_KAFKA_VERSION = "3.6.0";
|
||||
private static final String DEFAULT_ENHANCED_MONITORING = "DEFAULT";
|
||||
private static final String DEFAULT_CLIENT_BROKER_ENCRYPTION = "TLS_PLAINTEXT";
|
||||
private static final String DEFAULT_CLIENT_BROKER_ENCRYPTION = "TLS";
|
||||
private static final String PROVISIONED_CLUSTER_TYPE = "PROVISIONED";
|
||||
private static final String SERVERLESS_CLUSTER_TYPE = "SERVERLESS";
|
||||
private static final int MAX_PAGE = 100;
|
||||
@@ -305,7 +305,7 @@ public class MskService implements ResourceProvider {
|
||||
|
||||
/**
|
||||
* Fills in the encryption-in-transit defaults AWS applies when CreateCluster omits them:
|
||||
* {@code clientBroker} defaults to TLS_PLAINTEXT and {@code inCluster} to true. An
|
||||
* {@code clientBroker} defaults to TLS and {@code inCluster} to true. An
|
||||
* explicitly supplied value is never overwritten. {@code encryptionAtRest} is left alone -
|
||||
* real MSK creates a KMS key for you there, which the emulator has no equivalent of, so
|
||||
* inventing an ARN would be worse than omitting the member.
|
||||
|
||||
+27
-2
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user