mirror of
https://github.com/floci-io/floci.git
synced 2026-11-25 06:47:41 -05:00
Add SesV1Requests next to SesV2Requests: AUTH (us-east-1, email scope), authFor(region), and query(action) / query(authorization, action), which build the form-encoded request with the Authorization header and the Action parameter. Replace the per-class email-scope Authorization constants, the inline headers and the local query, req and authorization helpers with it. Classes that also send v2 requests reference SesV1Requests qualified; v1-only classes import it statically. Every request keeps the same header, content type and Action. Headers signed for another account, and the one v1 request that checks the ses scope, are left as they are.
90 lines
3.0 KiB
Java
90 lines
3.0 KiB
Java
package io.floci.aws.services.ses;
|
|
|
|
import io.quarkus.test.junit.QuarkusTest;
|
|
import org.junit.jupiter.api.AfterEach;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static io.restassured.RestAssured.given;
|
|
import static org.hamcrest.Matchers.containsString;
|
|
|
|
/**
|
|
* Verifies that v1 Query SES send actions reject requests when account-level
|
|
* sending is disabled, matching v2 REST JSON behavior and AWS semantics.
|
|
*/
|
|
@QuarkusTest
|
|
class SesV1AccountSendingPausedTest {
|
|
|
|
@BeforeEach
|
|
void disableSending() {
|
|
given()
|
|
.contentType("application/json")
|
|
.body("{\"SendingEnabled\":false}")
|
|
.when()
|
|
.put("/v2/email/account/sending")
|
|
.then()
|
|
.statusCode(200);
|
|
}
|
|
|
|
@AfterEach
|
|
void restoreSending() {
|
|
given()
|
|
.contentType("application/json")
|
|
.body("{\"SendingEnabled\":true}")
|
|
.when()
|
|
.put("/v2/email/account/sending")
|
|
.then()
|
|
.statusCode(200);
|
|
}
|
|
|
|
@Test
|
|
void sendEmail_paused_returnsAccountSendingPausedException() {
|
|
given()
|
|
.contentType("application/x-www-form-urlencoded")
|
|
.header("Authorization", SesV1Requests.AUTH)
|
|
.formParam("Action", "SendEmail")
|
|
.formParam("Source", "sender@example.com")
|
|
.formParam("Destination.ToAddresses.member.1", "recipient@example.com")
|
|
.formParam("Message.Subject.Data", "Subject")
|
|
.formParam("Message.Body.Text.Data", "Body")
|
|
.when()
|
|
.post("/")
|
|
.then()
|
|
.statusCode(400)
|
|
.body(containsString("<Code>AccountSendingPausedException</Code>"));
|
|
}
|
|
|
|
@Test
|
|
void sendRawEmail_paused_returnsAccountSendingPausedException() {
|
|
given()
|
|
.contentType("application/x-www-form-urlencoded")
|
|
.header("Authorization", SesV1Requests.AUTH)
|
|
.formParam("Action", "SendRawEmail")
|
|
.formParam("Source", "sender@example.com")
|
|
.formParam("Destinations.member.1", "recipient@example.com")
|
|
.formParam("RawMessage.Data", "Subject: Hello\r\n\r\nBody")
|
|
.when()
|
|
.post("/")
|
|
.then()
|
|
.statusCode(400)
|
|
.body(containsString("<Code>AccountSendingPausedException</Code>"));
|
|
}
|
|
|
|
@Test
|
|
void sendTemplatedEmail_paused_returnsAccountSendingPausedException() {
|
|
given()
|
|
.contentType("application/x-www-form-urlencoded")
|
|
.header("Authorization", SesV1Requests.AUTH)
|
|
.formParam("Action", "SendTemplatedEmail")
|
|
.formParam("Source", "sender@example.com")
|
|
.formParam("Destination.ToAddresses.member.1", "recipient@example.com")
|
|
.formParam("Template", "any-template")
|
|
.formParam("TemplateData", "{}")
|
|
.when()
|
|
.post("/")
|
|
.then()
|
|
.statusCode(400)
|
|
.body(containsString("<Code>AccountSendingPausedException</Code>"));
|
|
}
|
|
}
|