mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(ses): sign SES v2 test requests with the ses credential scope (#9238)
Several SES v2 REST JSON requests in the integration tests were signed with the v1 email scope. Floci routes v2 by path, so the tests passed either way, but a real v2 SDK signs with ses. Move those requests to SesV2Requests, and drop AUTH and authFor from SesV2SerializationErrors so v2 tests no longer read the scope from the v1 helper. Content type, body and path are unchanged.
This commit is contained in:
1 parent
bc3a7aaaaf
commit
806b822576
8 files changed
+28
-43
No files matched your search
@@ -9,13 +9,13 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.authFor;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.EXPECTED_MAP;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.LIST;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.NUMBER;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.STRING_FOR_INTEGER;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.assertError;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.assertSerializationException;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.authFor;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
+1
-1
@@ -8,6 +8,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.authFor;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.EXPECTED_LIST;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.EXPECTED_MAP;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.EXPECTED_NULL;
|
||||
@@ -15,7 +16,6 @@ import static io.floci.aws.services.ses.SesV2SerializationErrors.LIST;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.NUMBER;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.STRUCTURE;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.assertSerializationException;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.authFor;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class SesSendAddressLengthIntegrationTest {
|
||||
void v2SendEmail_fromOverLimit_returnsBadRequestException() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -77,7 +77,7 @@ class SesSendAddressLengthIntegrationTest {
|
||||
void v2SendEmail_feedbackForwardingOverLimit_returnsBadRequestException() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
@@ -101,7 +101,7 @@ class SesSendAddressLengthIntegrationTest {
|
||||
.getBytes(StandardCharsets.UTF_8));
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"Destination": {"ToAddresses": ["success@simulator.amazonses.com"], "CcAddresses": ["%s"]},
|
||||
@@ -120,7 +120,7 @@ class SesSendAddressLengthIntegrationTest {
|
||||
void v2SendBulkEmail_fromOverLimit_returnsInvalidEmailAddress() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
|
||||
@@ -74,7 +74,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
void v2SendEmail_nonAsciiLocalRecipient_returnsBadRequestException() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
@@ -94,7 +94,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
void v2SendBulkEmail_fromWithEmptyDomain_returnsInvalidEmailAddress() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@",
|
||||
@@ -117,7 +117,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
verifySender();
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%2$s",
|
||||
@@ -211,7 +211,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
void v2SendBulkEmail_malformedFromIsReportedBeforeMissingTemplate() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender.example.com",
|
||||
@@ -231,7 +231,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
void v2SendEmail_newlineInQuotedLocalPart_returnsInvalidEmailAddress() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "\\"a\\nb\\"@example.com",
|
||||
@@ -251,7 +251,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
void v2SendBulkEmail_malformedFeedbackForwarding_rejectsTheRequest() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
@@ -299,7 +299,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
void v2SendEmailRaw_malformedFromHeaderWithoutFromEmailAddress(String from, String message) {
|
||||
given()
|
||||
.contentType("application/json; charset=UTF-8")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"Destination": {"ToAddresses": ["%s"]},
|
||||
@@ -320,7 +320,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
verifySender();
|
||||
given()
|
||||
.contentType("application/json; charset=UTF-8")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -342,7 +342,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
|
||||
given()
|
||||
.contentType("application/json; charset=UTF-8")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -368,7 +368,7 @@ class SesSendAddressSyntaxIntegrationTest {
|
||||
|
||||
given()
|
||||
.contentType("application/json; charset=UTF-8")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{"Content": {"Raw": {"Data": "%s"}}}
|
||||
""".formatted(raw))
|
||||
|
||||
@@ -28,22 +28,13 @@ class SesSendNullAddressIntegrationTest {
|
||||
private static final String NULL_ADDRESS = "Invalid email address null.";
|
||||
private static final String EMPTY_DESTINATION = "Destination cannot be empty";
|
||||
|
||||
private static ValidatableResponse post(String path, String body) {
|
||||
return given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.body(body)
|
||||
.when()
|
||||
.post(path)
|
||||
.then();
|
||||
}
|
||||
|
||||
private static ValidatableResponse send(String body) {
|
||||
return post("/v2/email/outbound-emails", body);
|
||||
return SesV2Requests.post("/v2/email/outbound-emails", body);
|
||||
}
|
||||
|
||||
private static ValidatableResponse bulk(String members, String entries) {
|
||||
return post("/v2/email/outbound-bulk-emails", "{\"FromEmailAddress\": \"" + SENDER + "\", " + members
|
||||
return SesV2Requests.post("/v2/email/outbound-bulk-emails",
|
||||
"{\"FromEmailAddress\": \"" + SENDER + "\", " + members
|
||||
+ "\"DefaultContent\": " + INLINE_TEMPLATE + ", \"BulkEmailEntries\": [" + entries + "]}");
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class SesSendRawNoDestinationIntegrationTest {
|
||||
|
||||
String messageId = given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -65,7 +65,7 @@ class SesSendRawNoDestinationIntegrationTest {
|
||||
void v2SendEmail_rawWithoutAnyRecipient_returnsMissingToHeader() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
@@ -84,7 +84,7 @@ class SesSendRawNoDestinationIntegrationTest {
|
||||
void v2SendEmail_rawWithoutAnyRecipient_reportsUnknownConfigurationSetFirst() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"ConfigurationSetName": "no-destination-missing-cs",
|
||||
@@ -103,7 +103,7 @@ class SesSendRawNoDestinationIntegrationTest {
|
||||
void v2SendEmail_rawWithEmptyDestination_returnsMissingToHeader() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
@@ -123,7 +123,7 @@ class SesSendRawNoDestinationIntegrationTest {
|
||||
void v2SendEmail_rawWithNonArrayDestinationMember_returnsSerializationException() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
@@ -142,7 +142,7 @@ class SesSendRawNoDestinationIntegrationTest {
|
||||
void v2SendEmail_rawWithoutDestination_checksHeaderRecipientSyntax() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
@@ -161,7 +161,7 @@ class SesSendRawNoDestinationIntegrationTest {
|
||||
void v2SendEmail_rawWithoutDestination_checksCcHeaderRecipientSyntax() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", SesV1Requests.AUTH)
|
||||
.header("Authorization", SesV2Requests.AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.AUTH;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
|
||||
import static io.floci.aws.services.ses.SesV2SerializationErrors.assertSerializationException;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@@ -15,7 +15,6 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
*/
|
||||
final class SesV2SerializationErrors {
|
||||
|
||||
static final String AUTH = authFor("us-east-1");
|
||||
static final String STRUCTURE = "Start of structure or map found where not expected.";
|
||||
static final String LIST = "Start of list found where not expected";
|
||||
static final String NUMBER = "NUMBER_VALUE can not be converted to a String";
|
||||
@@ -35,13 +34,8 @@ final class SesV2SerializationErrors {
|
||||
Arguments.of("\"hello\"", null));
|
||||
}
|
||||
|
||||
/** An Authorization header signed for {@code region}, for a test that needs its own region state. */
|
||||
static String authFor(String region) {
|
||||
return SesV1Requests.authFor(region);
|
||||
}
|
||||
|
||||
static void assertError(String method, String path, String body, String type, String message) {
|
||||
assertError(AUTH, method, path, body, type, message);
|
||||
assertError(SesV2Requests.AUTH, method, path, body, type, message);
|
||||
}
|
||||
|
||||
static void assertError(String auth, String method, String path, String body, String type, String message) {
|
||||
|
||||
Reference in new issue
Block a user