mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(ses): support v2 dedicated IP (IP-level) and scaling/warmup APIs (#3420)
Add the remaining SES v2 dedicated-IP operations on top of pool management: GetDedicatedIps, GetDedicatedIp, PutDedicatedIpInPool, PutDedicatedIpWarmupAttributes, PutDedicatedIpPoolScalingAttributes, and PutAccountDedicatedIpWarmupAttributes. SES has no API to create a dedicated IP (they are leased out-of-band or auto-provisioned), so Floci models an account with no dedicated IPs: GetDedicatedIps is empty and any IP-targeted operation returns NotFoundException 'Could not find dedicated IP <ip> under this account.', matching real AWS for an account with no leased IPs (verified 2026-06-21). PutDedicatedIpPoolScalingAttributes updates the pool's scaling mode, and PutAccountDedicatedIpWarmupAttributes stores the account-level flag now reflected by GetAccount. Add integration and AWS SDK v2 compatibility tests.
This commit is contained in:
1 parent
d96516dc70
commit
e219ea409f
9 files changed
+604
-3
No files matched your search
@@ -90,4 +90,13 @@ class SesAccountServiceTest {
|
||||
assertThrows(AwsException.class, () -> service.putAccountDetails(REGION, null,
|
||||
null, null, null, null, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void dedicatedIpAutoWarmup_defaultsTrue_thenRoundTrips() {
|
||||
assertTrue(service.isDedicatedIpAutoWarmupEnabled(REGION));
|
||||
|
||||
service.setDedicatedIpAutoWarmup(REGION, false);
|
||||
assertFalse(service.isDedicatedIpAutoWarmupEnabled(REGION));
|
||||
assertTrue(service.isDedicatedIpAutoWarmupEnabled("eu-west-1"));
|
||||
}
|
||||
}
|
||||
@@ -118,4 +118,53 @@ class SesDedicatedIpServiceTest {
|
||||
void delete_missingThrows() {
|
||||
assertThrows(AwsException.class, () -> service.deleteDedicatedIpPool("ghost", REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ipLevelOperations_reportIpNotFound() {
|
||||
// Floci models no leased dedicated IPs, so every IP-targeted op reports not-found.
|
||||
assertThrows(AwsException.class, () -> service.getDedicatedIp("1.2.3.4", REGION));
|
||||
assertThrows(AwsException.class, () -> service.putDedicatedIpInPool("1.2.3.4", "pool-a", REGION));
|
||||
assertThrows(AwsException.class, () -> service.putDedicatedIpWarmupAttributes("1.2.3.4", 50, REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void putWarmupAttributes_validatesPercentageBeforeIp() {
|
||||
// Required and range checks fire before the IP lookup, matching AWS precedence.
|
||||
AwsException missing = assertThrows(AwsException.class,
|
||||
() -> service.putDedicatedIpWarmupAttributes("1.2.3.4", null, REGION));
|
||||
assertEquals("Warmup Percentage can't be null.", missing.getMessage());
|
||||
|
||||
AwsException outOfRange = assertThrows(AwsException.class,
|
||||
() -> service.putDedicatedIpWarmupAttributes("1.2.3.4", 101, REGION));
|
||||
assertEquals("Warmup Percentage must be between 0 and 100.", outOfRange.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void putDedicatedIpInPool_validatesBlankDestinationBeforeIp() {
|
||||
assertThrows(AwsException.class, () -> service.putDedicatedIpInPool("1.2.3.4", " ", REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void putScalingAttributes_rejectsInvalidMode() {
|
||||
service.createDedicatedIpPool("pool-a", "STANDARD", null, REGION);
|
||||
assertThrows(AwsException.class,
|
||||
() -> service.putDedicatedIpPoolScalingAttributes("pool-a", "TURBO", REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void putScalingAttributes_missingPoolThrows() {
|
||||
assertThrows(AwsException.class,
|
||||
() -> service.putDedicatedIpPoolScalingAttributes("ghost", "MANAGED", REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void putScalingAttributes_upgradesStandardToManaged_thenRejectsDowngrade() {
|
||||
service.createDedicatedIpPool("pool-a", "STANDARD", null, REGION);
|
||||
|
||||
service.putDedicatedIpPoolScalingAttributes("pool-a", "MANAGED", REGION);
|
||||
assertEquals("MANAGED", service.getDedicatedIpPool("pool-a", REGION).getScalingMode());
|
||||
|
||||
assertThrows(AwsException.class,
|
||||
() -> service.putDedicatedIpPoolScalingAttributes("pool-a", "STANDARD", REGION));
|
||||
}
|
||||
}
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
|
||||
/**
|
||||
* Integration tests for the SES V2 dedicated-IP (IP-level) endpoints. Floci does
|
||||
* not model leased dedicated IPs, so an account has none: GetDedicatedIps is
|
||||
* empty and any IP-targeted operation reports the IP as not found, matching real
|
||||
* AWS for an account with no leased IPs.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesDedicatedIpV2IntegrationTest {
|
||||
|
||||
private static final String AUTH_HEADER =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String TEST_IP = "192.0.2.1";
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void getDedicatedIps_empty() {
|
||||
given().header("Authorization", AUTH_HEADER)
|
||||
.when().get("/v2/email/dedicated-ips")
|
||||
.then().statusCode(200)
|
||||
.body("DedicatedIps", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void getDedicatedIp_notFound() {
|
||||
given().header("Authorization", AUTH_HEADER)
|
||||
.when().get("/v2/email/dedicated-ips/" + TEST_IP)
|
||||
.then().statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo("Could not find dedicated IP <" + TEST_IP + "> under this account."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void putDedicatedIpInPool_ipNotFound() {
|
||||
// Even with an existing destination pool, the IP is checked first.
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"PoolName\": \"dip-scaling-pool\"}")
|
||||
.when().post("/v2/email/dedicated-ip-pools").then().statusCode(200);
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"DestinationPoolName\": \"dip-scaling-pool\"}")
|
||||
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/pool")
|
||||
.then().statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo("Could not find dedicated IP <" + TEST_IP + "> under this account."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void putDedicatedIpWarmupAttributes_ipNotFound() {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"WarmupPercentage\": 50}")
|
||||
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup")
|
||||
.then().statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo("Could not find dedicated IP <" + TEST_IP + "> under this account."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void putDedicatedIpPoolScalingAttributes_updatesPool() {
|
||||
// The pool from Order 3 starts STANDARD; switch it to MANAGED.
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ScalingMode\": \"MANAGED\"}")
|
||||
.when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling")
|
||||
.then().statusCode(200);
|
||||
given().header("Authorization", AUTH_HEADER)
|
||||
.when().get("/v2/email/dedicated-ip-pools/dip-scaling-pool")
|
||||
.then().statusCode(200)
|
||||
.body("DedicatedIpPool.ScalingMode", equalTo("MANAGED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void putDedicatedIpPoolScalingAttributes_invalidMode_returns400() {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ScalingMode\": \"NONSENSE\"}")
|
||||
.when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("The ScalingMode parameter is invalid."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void putDedicatedIpPoolScalingAttributes_unknownPool_returns404() {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ScalingMode\": \"STANDARD\"}")
|
||||
.when().put("/v2/email/dedicated-ip-pools/dip-ghost-pool/scaling")
|
||||
.then().statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"))
|
||||
.body("message", equalTo("The requested pool <dip-ghost-pool> does not exist."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void accountDedicatedIpAutoWarmup_defaultsTrue_andTogglable() {
|
||||
given().header("Authorization", AUTH_HEADER)
|
||||
.when().get("/v2/email/account")
|
||||
.then().statusCode(200)
|
||||
.body("DedicatedIpAutoWarmupEnabled", equalTo(true));
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"AutoWarmupEnabled\": false}")
|
||||
.when().put("/v2/email/account/dedicated-ips/warmup")
|
||||
.then().statusCode(200);
|
||||
|
||||
given().header("Authorization", AUTH_HEADER)
|
||||
.when().get("/v2/email/account")
|
||||
.then().statusCode(200)
|
||||
.body("DedicatedIpAutoWarmupEnabled", equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void putDedicatedIpInPool_missingDestinationPoolName_returns400() {
|
||||
// A missing required member is validated before the IP lookup.
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{}")
|
||||
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/pool")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("Pool name can't be blank."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void putDedicatedIpPoolScalingAttributes_missingModeUnknownPool_returns400() {
|
||||
// ScalingMode is validated before the pool-existence check, so a missing mode on an
|
||||
// unknown pool is a BadRequestException, not NotFoundException.
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{}")
|
||||
.when().put("/v2/email/dedicated-ip-pools/dip-ghost-pool/scaling")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("The ScalingMode parameter is invalid."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void putDedicatedIpPoolScalingAttributes_managedToStandard_returns400() {
|
||||
// dip-scaling-pool was switched to MANAGED in Order 5; AWS forbids downgrading to STANDARD.
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ScalingMode\": \"STANDARD\"}")
|
||||
.when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("The ScalingMode parameter is invalid."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
void putDedicatedIpWarmupAttributes_missingPercentage_returns400() {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{}")
|
||||
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("Warmup Percentage can't be null."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void putDedicatedIpWarmupAttributes_outOfRange_returns400() {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"WarmupPercentage\": 150}")
|
||||
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("Warmup Percentage must be between 0 and 100."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void putDedicatedIpWarmupAttributes_nonInteger_returnsSerializationException() {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"WarmupPercentage\": \"abc\"}")
|
||||
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void putAccountAutoWarmup_stringCoercesToTrue() {
|
||||
// AWS's Jackson layer coerces a JSON string to true for SES v2 booleans.
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"AutoWarmupEnabled\": \"nonsense\"}")
|
||||
.when().put("/v2/email/account/dedicated-ips/warmup")
|
||||
.then().statusCode(200);
|
||||
|
||||
given().header("Authorization", AUTH_HEADER)
|
||||
.when().get("/v2/email/account")
|
||||
.then().statusCode(200)
|
||||
.body("DedicatedIpAutoWarmupEnabled", equalTo(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
void putAccountAutoWarmup_explicitNull_returnsSerializationException() {
|
||||
// Only an omitted member falls back to the @default(false); an explicit null does not.
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"AutoWarmupEnabled\": null}")
|
||||
.when().put("/v2/email/account/dedicated-ips/warmup")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
void putAccountAutoWarmup_number_returnsSerializationException() {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"AutoWarmupEnabled\": 1}")
|
||||
.when().put("/v2/email/account/dedicated-ips/warmup")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"))
|
||||
.body("message", equalTo("NUMBER_VALUE can not be converted to a Boolean"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user