mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(glue): add security configuration CRUD (#3870)
* feat(glue): add security configuration CRUD Implement AWS Glue security configuration create, get, list, and delete operations with encrypted configuration round trips, account and region isolation, persistence, and integration coverage. * fix(glue): close catalog encryption handler case Close the PutDataCatalogEncryptionSettings switch arm so the merged security configuration cases compile. * test(glue): cover empty security configuration lists Restore coverage for the empty GetSecurityConfigurations response and keep the test setup aligned with the rebased GlueService constructor. * refactor(glue): name security configuration length limit Use a named constant for the documented 255-character security configuration name limit. * fix(glue): serialize security configuration timestamps
This commit is contained in:
1 parent
cde8f48084
commit
e8b03538e6
7 files changed
+341
-9
No files matched your search
@@ -124,6 +124,15 @@ was switched on keep their plaintext: the developer guide ("Encrypting connectio
|
||||
password is encrypted "was determined when the connection was created or updated", so the setting is not applied
|
||||
retroactively.
|
||||
|
||||
#### Security configurations
|
||||
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateSecurityConfiguration | Creates a named security configuration. |
|
||||
| GetSecurityConfiguration | Returns a named security configuration. |
|
||||
| GetSecurityConfigurations | Lists stored security configurations. `MaxResults` and `NextToken` are currently ignored, so the complete list is returned. |
|
||||
| DeleteSecurityConfiguration | Deletes a named security configuration. |
|
||||
|
||||
#### Jobs
|
||||
|
||||
| Action | Description |
|
||||
|
||||
@@ -328,11 +328,28 @@ public class GlueJsonHandler {
|
||||
glueService.putDataCatalogEncryptionSettings(settings);
|
||||
yield Response.ok(Map.of()).build();
|
||||
}
|
||||
case "CreateSecurityConfiguration" -> {
|
||||
SecurityConfiguration configuration = glueService.createSecurityConfiguration(
|
||||
request.path("Name").asText(null), request.get("EncryptionConfiguration"), region);
|
||||
yield Response.ok(Map.of(
|
||||
"Name", configuration.getName(),
|
||||
"CreatedTimestamp", configuration.getCreatedTimeStamp().getEpochSecond())).build();
|
||||
}
|
||||
case "GetSecurityConfiguration" -> {
|
||||
SecurityConfiguration configuration = glueService.getSecurityConfiguration(
|
||||
request.path("Name").asText(null), region);
|
||||
yield Response.ok(Map.of("SecurityConfiguration", configuration)).build();
|
||||
}
|
||||
case "DeleteSecurityConfiguration" -> {
|
||||
glueService.deleteSecurityConfiguration(request.path("Name").asText(null), region);
|
||||
yield Response.ok(Map.of()).build();
|
||||
}
|
||||
// Read-only Glue actions for resources the emulator does not model. The AWS SDK
|
||||
// expects each to return a 200 with its result key present (empty), so we emit the
|
||||
// documented empty shape rather than an InvalidAction 400 that callers can't read.
|
||||
case "ListDataQualityRulesets" -> Response.ok(Map.of("Rulesets", List.of())).build();
|
||||
case "GetSecurityConfigurations" -> Response.ok(Map.of("SecurityConfigurations", List.of())).build();
|
||||
case "GetSecurityConfigurations" -> Response.ok(Map.of(
|
||||
"SecurityConfigurations", glueService.getSecurityConfigurations(region))).build();
|
||||
default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.github.hectorvent.floci.services.glue.model.Partition;
|
||||
import io.github.hectorvent.floci.services.glue.model.PartitionIndex;
|
||||
import io.github.hectorvent.floci.services.glue.model.PartitionIndexDescriptor;
|
||||
import io.github.hectorvent.floci.services.glue.model.SchemaReference;
|
||||
import io.github.hectorvent.floci.services.glue.model.SecurityConfiguration;
|
||||
import io.github.hectorvent.floci.services.glue.model.StorageDescriptor;
|
||||
import io.github.hectorvent.floci.services.glue.model.Table;
|
||||
import io.github.hectorvent.floci.services.glue.model.UserDefinedFunction;
|
||||
@@ -65,6 +66,7 @@ public class GlueService {
|
||||
private static final Logger LOG = Logger.getLogger(GlueService.class);
|
||||
private static final int MAX_FUNCTION_PATTERN_LENGTH = 255;
|
||||
private static final int MAX_FUNCTION_RESULTS = 100;
|
||||
private static final int MAX_SECURITY_CONFIGURATION_NAME_LENGTH = 255;
|
||||
private static final Set<String> CSV_HEADER_VALUES = Set.of("UNKNOWN", "PRESENT", "ABSENT");
|
||||
private static final Set<String> CSV_SERDE_VALUES = Set.of("OpenCSVSerDe", "LazySimpleSerDe", "None");
|
||||
private static final Set<String> CSV_CUSTOM_DATATYPES = Set.of(
|
||||
@@ -160,6 +162,7 @@ public class GlueService {
|
||||
private final StorageBackend<String, Connection> connectionStore;
|
||||
private final StorageBackend<String, GluePolicy> resourcePolicyStore;
|
||||
private final StorageBackend<String, DataCatalogEncryptionSettings> encryptionSettingsStore;
|
||||
private final StorageBackend<String, SecurityConfiguration> securityConfigurationStore;
|
||||
private final GlueSchemaRegistryService schemaRegistryService;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ResourceGroupsTaggingService resourceGroupsTaggingService;
|
||||
@@ -188,6 +191,8 @@ public class GlueService {
|
||||
this.resourcePolicyStore = storageFactory.create("glue", "resource_policy.json", new TypeReference<>() {});
|
||||
this.encryptionSettingsStore = storageFactory.create(
|
||||
"glue", "catalog_encryption_settings.json", new TypeReference<>() {});
|
||||
this.securityConfigurationStore = storageFactory.create(
|
||||
"glue", "security_configurations.json", new TypeReference<>() {});
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.resourceGroupsTaggingService = resourceGroupsTaggingService;
|
||||
@@ -208,6 +213,7 @@ public class GlueService {
|
||||
StorageBackend<String, Connection> connectionStore,
|
||||
StorageBackend<String, GluePolicy> resourcePolicyStore,
|
||||
StorageBackend<String, DataCatalogEncryptionSettings> encryptionSettingsStore,
|
||||
StorageBackend<String, SecurityConfiguration> securityConfigurationStore,
|
||||
GlueSchemaRegistryService schemaRegistryService,
|
||||
RegionResolver regionResolver,
|
||||
ResourceGroupsTaggingService resourceGroupsTaggingService,
|
||||
@@ -226,12 +232,68 @@ public class GlueService {
|
||||
this.connectionStore = connectionStore;
|
||||
this.resourcePolicyStore = resourcePolicyStore;
|
||||
this.encryptionSettingsStore = encryptionSettingsStore;
|
||||
this.securityConfigurationStore = securityConfigurationStore;
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.resourceGroupsTaggingService = resourceGroupsTaggingService;
|
||||
this.kmsService = kmsService;
|
||||
}
|
||||
|
||||
public SecurityConfiguration createSecurityConfiguration(String name, JsonNode encryptionConfiguration,
|
||||
String region) {
|
||||
validateSecurityConfigurationName(name);
|
||||
if (encryptionConfiguration == null || encryptionConfiguration.isNull()) {
|
||||
throw new AwsException("InvalidInputException", "EncryptionConfiguration is required.", 400);
|
||||
}
|
||||
String key = securityConfigurationKey(region, name);
|
||||
if (securityConfigurationStore.get(key).isPresent()) {
|
||||
throw new AwsException("AlreadyExistsException",
|
||||
"Security configuration already exists: " + name, 400);
|
||||
}
|
||||
SecurityConfiguration configuration = new SecurityConfiguration();
|
||||
configuration.setName(name);
|
||||
configuration.setCreatedTimeStamp(Instant.now());
|
||||
configuration.setEncryptionConfiguration(encryptionConfiguration.deepCopy());
|
||||
securityConfigurationStore.put(key, configuration);
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public SecurityConfiguration getSecurityConfiguration(String name, String region) {
|
||||
validateSecurityConfigurationName(name);
|
||||
return securityConfigurationStore.get(securityConfigurationKey(region, name))
|
||||
.orElseThrow(() -> new AwsException("EntityNotFoundException",
|
||||
"Security configuration not found: " + name, 400));
|
||||
}
|
||||
|
||||
public void deleteSecurityConfiguration(String name, String region) {
|
||||
validateSecurityConfigurationName(name);
|
||||
String key = securityConfigurationKey(region, name);
|
||||
if (securityConfigurationStore.get(key).isEmpty()) {
|
||||
throw new AwsException("EntityNotFoundException",
|
||||
"Security configuration not found: " + name, 400);
|
||||
}
|
||||
securityConfigurationStore.delete(key);
|
||||
}
|
||||
|
||||
public List<SecurityConfiguration> getSecurityConfigurations(String region) {
|
||||
String prefix = region + ":";
|
||||
return securityConfigurationStore.scan(key -> key.startsWith(prefix));
|
||||
}
|
||||
|
||||
private static String securityConfigurationKey(String region, String name) {
|
||||
return region + ":" + name;
|
||||
}
|
||||
|
||||
private static void validateSecurityConfigurationName(String name) {
|
||||
if (name == null || name.isBlank()) {
|
||||
throw new AwsException("InvalidInputException", "Name is required.", 400);
|
||||
}
|
||||
if (name.length() > MAX_SECURITY_CONFIGURATION_NAME_LENGTH) {
|
||||
throw new AwsException("InvalidInputException",
|
||||
"Name must be between 1 and " + MAX_SECURITY_CONFIGURATION_NAME_LENGTH + " characters.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
public void createDatabase(Database database) {
|
||||
createDatabase(database, null, regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@RegisterForReflection
|
||||
public class SecurityConfiguration {
|
||||
|
||||
private String name;
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant createdTimeStamp;
|
||||
private JsonNode encryptionConfiguration;
|
||||
|
||||
public SecurityConfiguration() {}
|
||||
|
||||
@JsonProperty("Name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@JsonProperty("CreatedTimeStamp")
|
||||
public Instant getCreatedTimeStamp() {
|
||||
return createdTimeStamp;
|
||||
}
|
||||
|
||||
public void setCreatedTimeStamp(Instant createdTimeStamp) {
|
||||
this.createdTimeStamp = createdTimeStamp;
|
||||
}
|
||||
|
||||
@JsonProperty("EncryptionConfiguration")
|
||||
public JsonNode getEncryptionConfiguration() {
|
||||
return encryptionConfiguration;
|
||||
}
|
||||
|
||||
public void setEncryptionConfiguration(JsonNode encryptionConfiguration) {
|
||||
this.encryptionConfiguration = encryptionConfiguration;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -22,9 +22,9 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Verifies the wire-accurate empty-list responses for the read-only Glue actions on resources
|
||||
* the emulator does not model (ListDataQualityRulesets, GetSecurityConfigurations).
|
||||
* Each must return HTTP 200, an empty list under its result key, and omit NextToken.
|
||||
* Verifies the wire-accurate empty-list responses for an unmodeled Glue action and an
|
||||
* empty newly modeled resource collection. Each must return HTTP 200, an empty list
|
||||
* under its result key, and omit NextToken.
|
||||
*/
|
||||
class GlueJsonHandlerEmptyListTest {
|
||||
|
||||
@@ -42,8 +42,8 @@ class GlueJsonHandlerEmptyListTest {
|
||||
GlueSchemaRegistryService schemaRegistryService =
|
||||
new GlueSchemaRegistryService(storageFactory, regionResolver);
|
||||
GlueService glueService = new GlueService(
|
||||
storageFactory, schemaRegistryService, regionResolver, new ResourceGroupsTaggingService(storageFactory),
|
||||
new KmsService(storageFactory, regionResolver));
|
||||
storageFactory, schemaRegistryService, regionResolver,
|
||||
new ResourceGroupsTaggingService(storageFactory), new KmsService(storageFactory, regionResolver));
|
||||
handler = new GlueJsonHandler(glueService, schemaRegistryService, mapper);
|
||||
}
|
||||
|
||||
@@ -82,4 +82,4 @@ class GlueJsonHandlerEmptyListTest {
|
||||
return AccountAwareStorageBackend.inMemory("000000000000");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.storage.PersistentStorage;
|
||||
import io.github.hectorvent.floci.services.glue.model.SecurityConfiguration;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(GlueSecurityConfigurationIntegrationTest.PersistentStorageProfile.class)
|
||||
class GlueSecurityConfigurationIntegrationTest {
|
||||
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
private static final String STORAGE_DIR = "target/glue-security-configuration-it";
|
||||
private static final Path STORAGE_FILE = Path.of(STORAGE_DIR, "security_configurations.json");
|
||||
private static final String NAME = "security-" + UUID.randomUUID().toString().substring(0, 8);
|
||||
private static final String ENCRYPTION = """
|
||||
{"S3Encryption":[{"S3EncryptionMode":"SSE-KMS","KmsKeyArn":"arn:aws:kms:us-east-1:000000000000:key/test"}],
|
||||
"JobBookmarksEncryption":{"JobBookmarksEncryptionMode":"CSE-KMS"}}
|
||||
""";
|
||||
|
||||
@BeforeAll
|
||||
static void setup() throws Exception {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
Files.deleteIfExists(STORAGE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void securityConfigurationCrudAndEncryptionRoundTrip() {
|
||||
create(NAME, "us-east-1", "000000000000");
|
||||
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.GetSecurityConfiguration")
|
||||
.body("{\"Name\":\"" + NAME + "\"}")
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body("SecurityConfiguration.Name", equalTo(NAME))
|
||||
.body("SecurityConfiguration.CreatedTimeStamp", instanceOf(Number.class))
|
||||
.body("SecurityConfiguration.EncryptionConfiguration.S3Encryption[0].S3EncryptionMode",
|
||||
equalTo("SSE-KMS"))
|
||||
.body("SecurityConfiguration.EncryptionConfiguration.JobBookmarksEncryption.JobBookmarksEncryptionMode",
|
||||
equalTo("CSE-KMS"));
|
||||
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.GetSecurityConfigurations")
|
||||
.body("{}")
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body("SecurityConfigurations", hasSize(1))
|
||||
.body("SecurityConfigurations[0].Name", equalTo(NAME))
|
||||
.body("SecurityConfigurations[0].CreatedTimeStamp", instanceOf(Number.class));
|
||||
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.DeleteSecurityConfiguration")
|
||||
.body("{\"Name\":\"" + NAME + "\"}")
|
||||
.when().post("/")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void duplicateAndMissingConfigurationsUseAwsErrors() {
|
||||
create(NAME, "us-east-1", "000000000000");
|
||||
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.CreateSecurityConfiguration")
|
||||
.body("{\"Name\":\"" + NAME + "\",\"EncryptionConfiguration\":{} }")
|
||||
.when().post("/")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("AlreadyExistsException"));
|
||||
|
||||
delete(NAME, "us-east-1", "000000000000");
|
||||
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.GetSecurityConfiguration")
|
||||
.body("{\"Name\":\"" + NAME + "\"}")
|
||||
.when().post("/")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("EntityNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountAndRegionAreIsolatedAndConfigurationIsPersisted() throws Exception {
|
||||
create(NAME, "us-east-1", "000000000001");
|
||||
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.GetSecurityConfiguration")
|
||||
.header("Authorization", authorization("000000000002", "us-east-1"))
|
||||
.body("{\"Name\":\"" + NAME + "\"}")
|
||||
.when().post("/")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("EntityNotFoundException"));
|
||||
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.GetSecurityConfiguration")
|
||||
.header("Authorization", authorization("000000000001", "us-west-2"))
|
||||
.body("{\"Name\":\"" + NAME + "\"}")
|
||||
.when().post("/")
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("EntityNotFoundException"));
|
||||
|
||||
PersistentStorage<String, SecurityConfiguration> store = new PersistentStorage<>(
|
||||
STORAGE_FILE, new TypeReference<Map<String, SecurityConfiguration>>() {});
|
||||
store.load();
|
||||
assertTrue(store.get("000000000001/us-east-1:" + NAME).isPresent());
|
||||
assertEquals(NAME, store.get("000000000001/us-east-1:" + NAME).orElseThrow().getName());
|
||||
}
|
||||
|
||||
private static void create(String name, String region, String account) {
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.CreateSecurityConfiguration")
|
||||
.header("Authorization", authorization(account, region))
|
||||
.body("{\"Name\":\"" + name + "\",\"EncryptionConfiguration\":" + ENCRYPTION + "}")
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body("Name", equalTo(name))
|
||||
.body("CreatedTimestamp", instanceOf(Number.class));
|
||||
}
|
||||
|
||||
private static void delete(String name, String region, String account) {
|
||||
given().contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSGlue.DeleteSecurityConfiguration")
|
||||
.header("Authorization", authorization(account, region))
|
||||
.body("{\"Name\":\"" + name + "\"}")
|
||||
.when().post("/")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
|
||||
private static String authorization(String account, String region) {
|
||||
return "AWS4-HMAC-SHA256 Credential=" + account
|
||||
+ "/20260918/" + region + "/glue/aws4_request, SignedHeaders=host, Signature=abc";
|
||||
}
|
||||
|
||||
public static final class PersistentStorageProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of(
|
||||
"floci.storage.mode", "persistent",
|
||||
"floci.storage.persistent-path", STORAGE_DIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
@@ -28,6 +30,7 @@ import io.github.hectorvent.floci.services.glue.model.PartitionIndex;
|
||||
import io.github.hectorvent.floci.services.glue.model.PartitionIndexDescriptor;
|
||||
import io.github.hectorvent.floci.services.glue.model.S3Target;
|
||||
import io.github.hectorvent.floci.services.glue.model.SchemaReference;
|
||||
import io.github.hectorvent.floci.services.glue.model.SecurityConfiguration;
|
||||
import io.github.hectorvent.floci.services.glue.model.StorageDescriptor;
|
||||
import io.github.hectorvent.floci.services.glue.model.Table;
|
||||
import io.github.hectorvent.floci.services.glue.model.UserDefinedFunction;
|
||||
@@ -106,8 +109,8 @@ class GlueServiceTest {
|
||||
new InMemoryStorage<String, Connection>(),
|
||||
new InMemoryStorage<String, GluePolicy>(),
|
||||
new InMemoryStorage<String, DataCatalogEncryptionSettings>(),
|
||||
schemaRegistryService, regionResolver, new ResourceGroupsTaggingService(null),
|
||||
kmsService);
|
||||
new InMemoryStorage<String, SecurityConfiguration>(),
|
||||
schemaRegistryService, regionResolver, new ResourceGroupsTaggingService(null), kmsService);
|
||||
glueService.createDatabase(new Database("db1"));
|
||||
}
|
||||
|
||||
@@ -117,6 +120,43 @@ class GlueServiceTest {
|
||||
assertEquals(ACCOUNT_ID, glueService.getDatabase("db1").getCatalogId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void securityConfigurationCrudPreservesEncryptionAndIsRegionScoped() throws Exception {
|
||||
JsonNode encryption = new ObjectMapper().readTree("""
|
||||
{"S3Encryption":[{"S3EncryptionMode":"SSE-KMS","KmsKeyArn":"arn:aws:kms:us-east-1:000000000000:key/a"}],
|
||||
"CloudWatchEncryption":{"CloudWatchEncryptionMode":"SSE-KMS"}}
|
||||
""");
|
||||
|
||||
SecurityConfiguration created = glueService.createSecurityConfiguration("secure", encryption, REGION);
|
||||
|
||||
assertEquals(encryption, created.getEncryptionConfiguration());
|
||||
assertEquals(encryption, glueService.getSecurityConfiguration("secure", REGION).getEncryptionConfiguration());
|
||||
assertEquals(1, glueService.getSecurityConfigurations(REGION).size());
|
||||
assertTrue(glueService.getSecurityConfigurations("us-west-2").isEmpty());
|
||||
|
||||
AwsException duplicate = assertThrows(AwsException.class,
|
||||
() -> glueService.createSecurityConfiguration("secure", encryption, REGION));
|
||||
assertEquals("AlreadyExistsException", duplicate.getErrorCode());
|
||||
glueService.deleteSecurityConfiguration("secure", REGION);
|
||||
AwsException missingGet = assertThrows(AwsException.class,
|
||||
() -> glueService.getSecurityConfiguration("secure", REGION));
|
||||
assertEquals("EntityNotFoundException", missingGet.getErrorCode());
|
||||
AwsException missingDelete = assertThrows(AwsException.class,
|
||||
() -> glueService.deleteSecurityConfiguration("secure", REGION));
|
||||
assertEquals("EntityNotFoundException", missingDelete.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsSecurityConfigurationNamesLongerThan255Characters() throws Exception {
|
||||
JsonNode encryption = new ObjectMapper().readTree("{\"EncryptionConfiguration\":{}}");
|
||||
String name = "a".repeat(256);
|
||||
|
||||
AwsException exception = assertThrows(AwsException.class,
|
||||
() -> glueService.createSecurityConfiguration(name, encryption, REGION));
|
||||
|
||||
assertEquals("InvalidInputException", exception.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void databasePersistedBeforeCatalogIdWasModelledIsBackfilledOnRead() {
|
||||
Database legacy = new Database("legacy-db");
|
||||
|
||||
Reference in new issue
Block a user