mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(athena): 🐛 align GetWorkGroup with AWS behavior (#1301)
GetWorkGroup previously returned a hardcoded default response for any workgroup name, ignoring workgroups created via CreateWorkGroup and never failing for non-existent ones. - Return stored Name, State, Description, CreationTime and Configuration for created workgroups, scoped by region - Throw InvalidRequestException (400) when the workgroup is not found, matching the AWS error shape and message - Keep the default view for the primary workgroup - Make DeleteWorkGroup actually remove the entry from the store so a deleted workgroup is no longer returned and its name can be reused - Document DeleteWorkGroup in the supported actions table Closes #1128
This commit is contained in:
1 parent
5078cac484
commit
ceb4d84431
4 files changed
+168
-16
No files matched your search
+136
@@ -0,0 +1,136 @@
|
||||
package io.github.hectorvent.floci.services.athena;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
@QuarkusTest
|
||||
class AthenaGetWorkGroupIntegrationTest {
|
||||
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWorkGroupReturnsPrimaryDefaults() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.GetWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{ \"WorkGroup\": \"primary\" }")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("WorkGroup.Name", equalTo("primary"))
|
||||
.body("WorkGroup.State", equalTo("ENABLED"))
|
||||
.body("WorkGroup.Configuration.EngineVersion.EffectiveEngineVersion",
|
||||
equalTo("Athena engine version 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWorkGroupReturnsCreatedWorkGroupDetails() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.CreateWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"Name": "analytics-get",
|
||||
"Description": "analytics workgroup for reporting queries",
|
||||
"Configuration": {
|
||||
"ResultConfiguration": {
|
||||
"OutputLocation": "s3://test-bucket/athena-results/"
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.GetWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{ \"WorkGroup\": \"analytics-get\" }")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("WorkGroup.Name", equalTo("analytics-get"))
|
||||
.body("WorkGroup.State", equalTo("ENABLED"))
|
||||
.body("WorkGroup.Description", equalTo("analytics workgroup for reporting queries"))
|
||||
.body("WorkGroup.CreationTime", notNullValue())
|
||||
.body("WorkGroup.Configuration.ResultConfiguration.OutputLocation",
|
||||
equalTo("s3://test-bucket/athena-results/"))
|
||||
.body("WorkGroup.Configuration.EngineVersion.EffectiveEngineVersion",
|
||||
equalTo("Athena engine version 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWorkGroupNotFoundReturnsInvalidRequestException() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.GetWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{ \"WorkGroup\": \"athena-workgroup-missing\" }")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidRequestException"))
|
||||
.body("message", equalTo("WorkGroup athena-workgroup-missing is not found."));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deletedWorkGroupIsNoLongerReturnedAndNameCanBeReused() {
|
||||
String createRequest = """
|
||||
{
|
||||
"Name": "analytics-delete-get"
|
||||
}
|
||||
""";
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.CreateWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body(createRequest)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.DeleteWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{ \"WorkGroup\": \"analytics-delete-get\" }")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.GetWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{ \"WorkGroup\": \"analytics-delete-get\" }")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidRequestException"));
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonAthena.CreateWorkGroup")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body(createRequest)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user