mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(ec2): support VPC peering connections (#2654)
* feat(ec2): support VPC peering connections CreateVpcPeeringConnection was entirely unimplemented, returning UnsupportedOperation and blocking all three VPC-peering examples in terraform-aws-vpc (vpc-peering, vpc-peering-cross-accounts, vpc-peering-external). Adds CreateVpcPeeringConnection, AcceptVpcPeeringConnection, DescribeVpcPeeringConnections, ModifyVpcPeeringConnectionOptions and DeleteVpcPeeringConnection, matching the resources those examples actually use (aws_vpc_peering_connection, aws_vpc_peering_connection_accepter, aws_vpc_peering_connection_options). Connections start pending-acceptance and only move to active via an explicit accept, same as real AWS; Terraform's auto_accept convenience is provider-side, not API-side, so no same-account special-casing is needed here. CreateRoute now also accepts VpcPeeringConnectionId as a target and reports it back on DescribeRouteTables - every one of the three examples routes traffic through the peering connection via aws_route, and without this the provider would see permanent drift on the route resource it just created. * fix(ec2): enforce cross-account peering identity and fix route target bugs Addresses Greptile's 0/5 review of #2654: - AcceptVpcPeeringConnection now resolves the connection across every account's storage partition (findAnyAccountEntry, same pattern as Ec2IpamService's RAM-shared IPAM lookups) and rejects a caller that is not the connection's accepter, instead of only ever finding a connection the accepting account itself created. - DescribeVpcPeeringConnections, ModifyVpcPeeringConnectionOptions and DeleteVpcPeeringConnection get the same cross-account resolution, and Describe now filters to connections visible from the caller's account and region instead of leaking every account's connections in every region. - CreateRoute rejects a VpcPeeringConnectionId combined with another target, matching the existing EgressOnlyInternetGatewayId check. - ReplaceRoute accepts VpcPeeringConnectionId as a target, so a peering route created by CreateRoute can actually be repointed. Adds a cross-account integration test covering acceptance identity, region-scoped visibility, and the two route-target fixes. * fix(ec2): record the actual caller as peering requester, enforce region on mutations Two more issues from Greptile's re-review of #2654: - CreateVpcPeeringConnection recorded requesterVpcInfo.ownerId as the emulator's configured default account rather than the account that actually made the request. A non-default requester could never describe, modify or delete its own connection, while the unrelated default account was treated as the requester and granted those operations. Same fix applied to the accepter-owner fallback when PeerOwnerId is omitted (same-account peering). - AcceptVpcPeeringConnection, ModifyVpcPeeringConnectionOptions and DeleteVpcPeeringConnection now enforce the same regional-visibility invariant Describe already did: an endpoint in a region belonging to neither side of the connection reports it as absent instead of acting on it. Extends the cross-account integration test to cover both: the actual requester managing its own connection while the default account cannot, and mutations issued from an unrelated region being rejected. * fix(ec2): enforce per-endpoint ownership on ModifyVpcPeeringConnectionOptions Greptile's third pass on #2654: a participant that is legitimately part of a connection could still set the *other* side's DNS-resolution option, e.g. the requester setting AccepterPeeringConnectionOptions. AWS scopes each option block to that side's own VPC owner, not to participation in the connection generally. ModifyVpcPeeringConnectionOptions now checks the caller against the specific side's owner for whichever option block(s) the request actually sets, and rejects a cross-endpoint attempt with OperationNotPermitted. Adds a test covering both directions (requester setting the accepter's option and vice versa). * fix(ec2): resolve the peer VPC's real owner instead of trusting PeerOwnerId Greptile's fourth pass on #2654: CreateVpcPeeringConnection recorded the requester-supplied PeerOwnerId as the accepter's identity without checking it against the peer VPC's actual owner. Since AcceptVpcPeeringConnection authorizes against that recorded value, a requester could name another account's real VPC while claiming itself (or anyone) as PeerOwnerId and self-authorize acceptance of a connection it doesn't actually control. The peer VPC is now resolved across every account's partition, same as a peering connection's own id lookup. When it's known locally, that storage partition is authoritative and overrides any conflicting PeerOwnerId; the claim is trusted only for a genuinely external/cross-account peer this store never seeded, where there's nothing to validate against. Adds a test creating the peer VPC under a real "victim" account and confirming the forging account can't accept the connection while the real owner can. * fix(ec2): take the per-connection lock in DeleteVpcPeeringConnection Greptile's fifth pass on #2654: accept and modify already synchronized on lockFor(vpcPeeringConnectionId) before loading and saving the connection, but delete did not take that lock at all. A delete could run between one of those mutations' load and its unconditional save, and that save would resurrect the row delete just removed. Wraps delete's lookup, visibility check, and removal in the same lock. * fix(ec2): surface peeringOptions in VPC peering connection responses CreateVpcPeeringConnection, AcceptVpcPeeringConnection, and DescribeVpcPeeringConnections never echoed the DNS-resolution setting under requesterVpcInfo/accepterVpcInfo, even though it's a real field there in AWS's own examples. ModifyVpcPeeringConnectionOptions stored it correctly, but Terraform's aws_vpc_peering_connection_options resource reads the value back via Describe on every plan, not by re-issuing Modify, so a config setting DNS resolution would show permanent drift. Flagged in review: https://github.com/floci-io/floci/pull/2654#pullrequestreview-5054115075 * fix(ec2): reject a peer VPC named with the wrong PeerRegion CreateVpcPeeringConnection resolved the peer VPC only within the region the requester supplied, and treated a miss as "external peer, trust PeerOwnerId". That left the ownership forgery closed on the previous commit reachable again: name another account's real VPC, point PeerRegion at a region that VPC is not in, and the requester's own claimed PeerOwnerId is recorded unchallenged -- after which AcceptVpcPeeringConnection authorizes the requester against it. Real AWS resolves the peer VPC globally and answers InvalidVpcID.NotFound when the named region is not the one it lives in, so a lookup miss now falls back to trusting PeerOwnerId only when the id is absent from every region. A genuinely external peer VPC -- one this emulator has never seen -- behaves as before.
This commit is contained in:
1 parent
b4aab999f7
commit
14f99a5123
11 files changed
+1559
-18
No files matched your search
+2
-2
@@ -225,12 +225,12 @@ class Ec2ServicePersistenceTest {
|
||||
// (b) CreateRoute with an equivalent-but-differently-spelled destination is a duplicate,
|
||||
// not a new route, of the legacy one.
|
||||
AwsException duplicate = assertThrows(AwsException.class, () -> restarted.createRoute(
|
||||
REGION, routeTableId, "100.68.63.255/18", null, null, "igw-other00000000000", null, null));
|
||||
REGION, routeTableId, "100.68.63.255/18", null, null, "igw-other00000000000", null, null, null));
|
||||
assertEquals("RouteAlreadyExists", duplicate.getErrorCode());
|
||||
|
||||
// (c) ReplaceRoute against the legacy route's original, non-canonical spelling finds the
|
||||
// same route rather than throwing InvalidRoute.NotFound.
|
||||
restarted.replaceRoute(REGION, routeTableId, "100.68.0.18/18", null, null, "igw-replaced0000000", null);
|
||||
restarted.replaceRoute(REGION, routeTableId, "100.68.0.18/18", null, null, "igw-replaced0000000", null, null);
|
||||
RouteTable afterReplace =
|
||||
restarted.describeRouteTables(REGION, List.of(routeTableId), Map.of()).getFirst();
|
||||
assertEquals(1, afterReplace.getRoutes().size(), "replace must update the existing route in place");
|
||||
|
||||
+533
@@ -0,0 +1,533 @@
|
||||
package io.github.hectorvent.floci.services.ec2;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.emptyOrNullString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
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 io.quarkus.test.junit.QuarkusTest;
|
||||
|
||||
/**
|
||||
* Covers the cross-account and multi-target scenarios the same-account lifecycle test
|
||||
* (Ec2VpcPeeringConnectionIntegrationTest) cannot exercise on its own: only the actual accepter
|
||||
* account may accept a connection, a describe issued from an unrelated region must not see it,
|
||||
* ReplaceRoute must accept a peering connection as a target, and CreateRoute must reject a
|
||||
* peering connection combined with another target.
|
||||
*
|
||||
* <p>Uses 12-digit numeric access key IDs so they resolve directly to distinct account IDs
|
||||
* (see AccountIsolationIntegrationTest for the same pattern).
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class Ec2VpcPeeringConnectionCrossAccountIntegrationTest {
|
||||
|
||||
// 000000000000 is the emulator's configured default account — distinct from every account
|
||||
// below, so it stands in for "an unrelated account that happens to be the default".
|
||||
private static final String DEFAULT_ACCOUNT = "000000000000";
|
||||
private static final String REQUESTER_ACCOUNT = "000000000101";
|
||||
private static final String ACCEPTER_ACCOUNT = "000000000102";
|
||||
private static final String OTHER_ACCOUNT = "000000000103";
|
||||
|
||||
private static final String DEFAULT_ACCOUNT_AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=" + DEFAULT_ACCOUNT + "/20260215/us-east-1/ec2/aws4_request";
|
||||
private static final String REQUESTER_AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=" + REQUESTER_ACCOUNT + "/20260215/us-east-1/ec2/aws4_request";
|
||||
private static final String ACCEPTER_AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=" + ACCEPTER_ACCOUNT + "/20260215/us-east-1/ec2/aws4_request";
|
||||
private static final String OTHER_ACCOUNT_AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=" + OTHER_ACCOUNT + "/20260215/us-east-1/ec2/aws4_request";
|
||||
// Same requester account, different region — used to prove a describe (and, below, a
|
||||
// mutation) issued from a region unrelated to either side of the connection does not see it.
|
||||
private static final String REQUESTER_AUTH_OTHER_REGION =
|
||||
"AWS4-HMAC-SHA256 Credential=" + REQUESTER_ACCOUNT + "/20260215/us-west-2/ec2/aws4_request";
|
||||
|
||||
private static String requesterVpcId;
|
||||
private static String pcxId;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void requesterCreatesAConnectionAddressedToTheAccepterAccount() {
|
||||
requesterVpcId = given()
|
||||
.formParam("Action", "CreateVpc")
|
||||
.formParam("CidrBlock", "10.40.0.0/16")
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateVpcResponse.vpc.vpcId");
|
||||
|
||||
pcxId = given()
|
||||
.formParam("Action", "CreateVpcPeeringConnection")
|
||||
.formParam("VpcId", requesterVpcId)
|
||||
.formParam("PeerVpcId", "vpc-accepter00000000")
|
||||
.formParam("PeerOwnerId", ACCEPTER_ACCOUNT)
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.ownerId",
|
||||
equalTo(ACCEPTER_ACCOUNT))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.status.code",
|
||||
equalTo("pending-acceptance"))
|
||||
.extract().path("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.vpcPeeringConnectionId");
|
||||
}
|
||||
|
||||
/** The requester created the connection but is not the accepter and cannot activate it. */
|
||||
@Test
|
||||
@Order(2)
|
||||
void requesterCannotAcceptItsOwnConnection() {
|
||||
given()
|
||||
.formParam("Action", "AcceptVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcPeeringConnectionID.NotFound"));
|
||||
}
|
||||
|
||||
/** An unrelated third account cannot see or accept the connection either. */
|
||||
@Test
|
||||
@Order(3)
|
||||
void anUnrelatedAccountCannotSeeOrAcceptTheConnection() {
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", OTHER_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet", emptyOrNullString());
|
||||
|
||||
given()
|
||||
.formParam("Action", "AcceptVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", OTHER_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcPeeringConnectionID.NotFound"));
|
||||
}
|
||||
|
||||
/** A describe issued from a region that is neither side of the connection must not see it. */
|
||||
@Test
|
||||
@Order(4)
|
||||
void describeFromAnUnrelatedRegionDoesNotSeeTheConnection() {
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", REQUESTER_AUTH_OTHER_REGION)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet", emptyOrNullString());
|
||||
}
|
||||
|
||||
/** The actual accepter account can see and accept it. */
|
||||
@Test
|
||||
@Order(5)
|
||||
void theAccepterAccountCanAcceptTheConnection() {
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", ACCEPTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet.item.vpcPeeringConnectionId",
|
||||
equalTo(pcxId));
|
||||
|
||||
given()
|
||||
.formParam("Action", "AcceptVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", ACCEPTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("AcceptVpcPeeringConnectionResponse.vpcPeeringConnection.status.code", equalTo("active"));
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateRoute must reject a route that names both a peering connection and another target
|
||||
* (here: GatewayId) — AWS accepts exactly one target per route.
|
||||
*/
|
||||
@Test
|
||||
@Order(6)
|
||||
void createRouteRejectsAPeeringConnectionCombinedWithAnotherTarget() {
|
||||
String routeTableId = given()
|
||||
.formParam("Action", "CreateRouteTable")
|
||||
.formParam("VpcId", requesterVpcId)
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateRouteTableResponse.routeTable.routeTableId");
|
||||
|
||||
given()
|
||||
.formParam("Action", "CreateRoute")
|
||||
.formParam("RouteTableId", routeTableId)
|
||||
.formParam("DestinationCidrBlock", "10.50.0.0/16")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("GatewayId", "igw-conflicting00000")
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidParameterCombination"));
|
||||
}
|
||||
|
||||
/**
|
||||
* ReplaceRoute must accept a peering connection as the replacement target — the peering
|
||||
* examples repoint a route at the connection after it goes active, same as CreateRoute.
|
||||
*/
|
||||
@Test
|
||||
@Order(7)
|
||||
void replaceRouteAcceptsThePeeringConnectionAsTheTarget() {
|
||||
String routeTableId = given()
|
||||
.formParam("Action", "CreateRouteTable")
|
||||
.formParam("VpcId", requesterVpcId)
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateRouteTableResponse.routeTable.routeTableId");
|
||||
|
||||
given()
|
||||
.formParam("Action", "CreateRoute")
|
||||
.formParam("RouteTableId", routeTableId)
|
||||
.formParam("DestinationCidrBlock", "10.60.0.0/16")
|
||||
.formParam("GatewayId", "igw-replaceable00000")
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.formParam("Action", "ReplaceRoute")
|
||||
.formParam("RouteTableId", routeTableId)
|
||||
.formParam("DestinationCidrBlock", "10.60.0.0/16")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ReplaceRouteResponse.return", equalTo("true"));
|
||||
|
||||
given()
|
||||
.formParam("Action", "DescribeRouteTables")
|
||||
.formParam("RouteTableId.1", routeTableId)
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeRouteTablesResponse.routeTableSet.item.routeSet.item"
|
||||
+ ".find { it.destinationCidrBlock == '10.60.0.0/16' }.vpcPeeringConnectionId",
|
||||
equalTo(pcxId));
|
||||
}
|
||||
|
||||
/**
|
||||
* The requester account (not the emulator's configured default account) must be able to
|
||||
* describe and modify the connection it created. Recording requesterVpcInfo.ownerId as the
|
||||
* fixed default account, rather than the account that actually made the request, would deny
|
||||
* the real requester while handing an unrelated account participant-level access.
|
||||
*/
|
||||
@Test
|
||||
@Order(8)
|
||||
void theRequesterAccountCanManageItsOwnConnectionButTheDefaultAccountCannot() {
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet.item.vpcPeeringConnectionId",
|
||||
equalTo(pcxId));
|
||||
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", DEFAULT_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet", emptyOrNullString());
|
||||
|
||||
given()
|
||||
.formParam("Action", "ModifyVpcPeeringConnectionOptions")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("RequesterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "true")
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ModifyVpcPeeringConnectionOptionsResponse.requesterPeeringConnectionOptions"
|
||||
+ ".allowDnsResolutionFromRemoteVpc", equalTo("true"));
|
||||
|
||||
given()
|
||||
.formParam("Action", "ModifyVpcPeeringConnectionOptions")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("RequesterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "false")
|
||||
.header("Authorization", DEFAULT_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcPeeringConnectionID.NotFound"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Each side's DNS-resolution option is that side's own setting: being a legitimate
|
||||
* participant in the connection is not enough to change the *other* side's option, only
|
||||
* your own — same as AWS, where accepterPeeringConnectionOptions is the accepter VPC
|
||||
* owner's setting and requesterPeeringConnectionOptions is the requester VPC owner's.
|
||||
*/
|
||||
@Test
|
||||
@Order(9)
|
||||
void aParticipantCannotModifyTheOppositeEndpointsOptions() {
|
||||
// The requester may set its own side...
|
||||
given()
|
||||
.formParam("Action", "ModifyVpcPeeringConnectionOptions")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("RequesterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "true")
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// ...but not the accepter's side, even though it is a legitimate participant.
|
||||
given()
|
||||
.formParam("Action", "ModifyVpcPeeringConnectionOptions")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("AccepterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "true")
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("OperationNotPermitted"));
|
||||
|
||||
// Symmetrically, the accepter may set its own side but not the requester's.
|
||||
given()
|
||||
.formParam("Action", "ModifyVpcPeeringConnectionOptions")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("AccepterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "true")
|
||||
.header("Authorization", ACCEPTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.formParam("Action", "ModifyVpcPeeringConnectionOptions")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("RequesterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "false")
|
||||
.header("Authorization", ACCEPTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("OperationNotPermitted"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept, modify and delete must enforce the same regional-visibility invariant Describe
|
||||
* does: an endpoint in a region belonging to neither side must not be able to act on the
|
||||
* connection, even when the caller's account is a legitimate participant.
|
||||
*/
|
||||
@Test
|
||||
@Order(10)
|
||||
void mutationsFromAnUnrelatedRegionAreRejected() {
|
||||
given()
|
||||
.formParam("Action", "ModifyVpcPeeringConnectionOptions")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("RequesterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "true")
|
||||
.header("Authorization", REQUESTER_AUTH_OTHER_REGION)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcPeeringConnectionID.NotFound"));
|
||||
|
||||
given()
|
||||
.formParam("Action", "DeleteVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", REQUESTER_AUTH_OTHER_REGION)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcPeeringConnectionID.NotFound"));
|
||||
|
||||
// Still there, and still manageable from the correct region.
|
||||
given()
|
||||
.formParam("Action", "DeleteVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", REQUESTER_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DeleteVpcPeeringConnectionResponse.return", equalTo("true"));
|
||||
}
|
||||
|
||||
/**
|
||||
* A requester cannot forge accepter ownership by naming another account's real VPC while
|
||||
* claiming a different PeerOwnerId (e.g. its own account) — the peer VPC's actual storage
|
||||
* partition must win, or the requester could self-authorize AcceptVpcPeeringConnection for a
|
||||
* connection it does not actually control.
|
||||
*/
|
||||
@Test
|
||||
@Order(11)
|
||||
void creationCannotForgeAccepterOwnershipForALocallyKnownPeerVpc() {
|
||||
String victimAccount = "000000000199";
|
||||
String victimAuth =
|
||||
"AWS4-HMAC-SHA256 Credential=" + victimAccount + "/20260215/us-east-1/ec2/aws4_request";
|
||||
|
||||
String victimVpcId = given()
|
||||
.formParam("Action", "CreateVpc")
|
||||
.formParam("CidrBlock", "10.70.0.0/16")
|
||||
.header("Authorization", victimAuth)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateVpcResponse.vpc.vpcId");
|
||||
|
||||
String forgingVpcId = given()
|
||||
.formParam("Action", "CreateVpc")
|
||||
.formParam("CidrBlock", "10.71.0.0/16")
|
||||
.header("Authorization", OTHER_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateVpcResponse.vpc.vpcId");
|
||||
|
||||
// OTHER_ACCOUNT names the victim's real VPC but falsely claims itself as PeerOwnerId.
|
||||
String forgedPcxId = given()
|
||||
.formParam("Action", "CreateVpcPeeringConnection")
|
||||
.formParam("VpcId", forgingVpcId)
|
||||
.formParam("PeerVpcId", victimVpcId)
|
||||
.formParam("PeerOwnerId", OTHER_ACCOUNT)
|
||||
.header("Authorization", OTHER_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
// The recorded accepter owner is the VPC's real account, not the claimed one.
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.ownerId",
|
||||
equalTo(victimAccount))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.cidrBlock",
|
||||
equalTo("10.70.0.0/16"))
|
||||
.extract().path("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.vpcPeeringConnectionId");
|
||||
|
||||
// The requester cannot self-authorize acceptance despite its false claim.
|
||||
given()
|
||||
.formParam("Action", "AcceptVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", forgedPcxId)
|
||||
.header("Authorization", OTHER_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcPeeringConnectionID.NotFound"));
|
||||
|
||||
// The real owner of the peer VPC can accept it.
|
||||
given()
|
||||
.formParam("Action", "AcceptVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", forgedPcxId)
|
||||
.header("Authorization", victimAuth)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("AcceptVpcPeeringConnectionResponse.vpcPeeringConnection.status.code", equalTo("active"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The same forgery, hidden behind a mismatched PeerRegion: naming another account's real VPC
|
||||
* but pointing PeerRegion at a region that VPC is absent from must not degrade into trusting
|
||||
* the requester-supplied PeerOwnerId. Real AWS resolves the peer VPC globally and answers
|
||||
* InvalidVpcID.NotFound, so nothing is created for the requester to then self-accept.
|
||||
*/
|
||||
@Test
|
||||
@Order(12)
|
||||
void creationCannotForgeAccepterOwnershipByNamingTheWrongPeerRegion() {
|
||||
String victimAccount = "000000000198";
|
||||
String victimAuth =
|
||||
"AWS4-HMAC-SHA256 Credential=" + victimAccount + "/20260215/us-east-1/ec2/aws4_request";
|
||||
|
||||
String victimVpcId = given()
|
||||
.formParam("Action", "CreateVpc")
|
||||
.formParam("CidrBlock", "10.72.0.0/16")
|
||||
.header("Authorization", victimAuth)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateVpcResponse.vpc.vpcId");
|
||||
|
||||
String forgingVpcId = given()
|
||||
.formParam("Action", "CreateVpc")
|
||||
.formParam("CidrBlock", "10.73.0.0/16")
|
||||
.header("Authorization", OTHER_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateVpcResponse.vpc.vpcId");
|
||||
|
||||
// The victim's VPC is in us-east-1; PeerRegion names eu-west-1, where it does not exist.
|
||||
given()
|
||||
.formParam("Action", "CreateVpcPeeringConnection")
|
||||
.formParam("VpcId", forgingVpcId)
|
||||
.formParam("PeerVpcId", victimVpcId)
|
||||
.formParam("PeerRegion", "eu-west-1")
|
||||
.formParam("PeerOwnerId", OTHER_ACCOUNT)
|
||||
.header("Authorization", OTHER_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcID.NotFound"));
|
||||
|
||||
// A genuinely external peer VPC — one this emulator has never seen in any region — is
|
||||
// still accepted on the requester's word, as before.
|
||||
given()
|
||||
.formParam("Action", "CreateVpcPeeringConnection")
|
||||
.formParam("VpcId", forgingVpcId)
|
||||
.formParam("PeerVpcId", "vpc-0f00d0f00d0f00d00")
|
||||
.formParam("PeerRegion", "eu-west-1")
|
||||
.formParam("PeerOwnerId", "000000000197")
|
||||
.header("Authorization", OTHER_ACCOUNT_AUTH)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.ownerId",
|
||||
equalTo("000000000197"));
|
||||
}
|
||||
}
|
||||
+325
@@ -0,0 +1,325 @@
|
||||
package io.github.hectorvent.floci.services.ec2;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.emptyOrNullString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
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 io.quarkus.test.junit.QuarkusTest;
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
/**
|
||||
* CreateVpcPeeringConnection was entirely unimplemented (floci-k41), blocking all three VPC-peering
|
||||
* examples in terraform-aws-vpc (vpc-peering, vpc-peering-cross-accounts, vpc-peering-external).
|
||||
* These tests walk the lifecycle those examples actually exercise: create -> accept -> describe ->
|
||||
* route via the peering connection -> options -> delete.
|
||||
*
|
||||
* <p>Real AWS never auto-accepts a connection (same-account or not); every connection starts
|
||||
* "pending-acceptance" until an explicit AcceptVpcPeeringConnection. Terraform's own `auto_accept`
|
||||
* convenience is implemented by the *provider* re-issuing that call, not by the API — so that is
|
||||
* what these tests pin at the API layer.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class Ec2VpcPeeringConnectionIntegrationTest {
|
||||
|
||||
private static final String AUTH_HEADER =
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260205/us-east-1/ec2/aws4_request";
|
||||
|
||||
private static String requesterVpcId;
|
||||
private static String accepterVpcId;
|
||||
private static String pcxId;
|
||||
private static String routeTableId;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void createVpcPeeringConnectionStartsPendingAcceptance() {
|
||||
requesterVpcId = given()
|
||||
.formParam("Action", "CreateVpc")
|
||||
.formParam("CidrBlock", "10.20.0.0/16")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateVpcResponse.vpc.vpcId");
|
||||
|
||||
accepterVpcId = given()
|
||||
.formParam("Action", "CreateVpc")
|
||||
.formParam("CidrBlock", "10.30.0.0/16")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateVpcResponse.vpc.vpcId");
|
||||
|
||||
pcxId = given()
|
||||
.formParam("Action", "CreateVpcPeeringConnection")
|
||||
.formParam("VpcId", requesterVpcId)
|
||||
.formParam("PeerVpcId", accepterVpcId)
|
||||
.formParam("TagSpecification.1.ResourceType", "vpc-peering-connection")
|
||||
.formParam("TagSpecification.1.Tag.1.Key", "Name")
|
||||
.formParam("TagSpecification.1.Tag.1.Value", "pcx-example")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.requesterVpcInfo.vpcId",
|
||||
equalTo(requesterVpcId))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.requesterVpcInfo.cidrBlock",
|
||||
equalTo("10.20.0.0/16"))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.vpcId",
|
||||
equalTo(accepterVpcId))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.cidrBlock",
|
||||
equalTo("10.30.0.0/16"))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.status.code",
|
||||
equalTo("pending-acceptance"))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.tagSet.item.value",
|
||||
equalTo("pcx-example"))
|
||||
.extract().path("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.vpcPeeringConnectionId");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void describeReflectsThePendingConnection() {
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet.item.vpcPeeringConnectionId",
|
||||
equalTo(pcxId))
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet.item.status.code",
|
||||
equalTo("pending-acceptance"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void acceptTransitionsTheConnectionToActive() {
|
||||
given()
|
||||
.formParam("Action", "AcceptVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("AcceptVpcPeeringConnectionResponse.vpcPeeringConnection.status.code", equalTo("active"));
|
||||
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet.item.status.code",
|
||||
equalTo("active"));
|
||||
}
|
||||
|
||||
/** Accepting an already-active connection is not a valid state transition. */
|
||||
@Test
|
||||
@Order(4)
|
||||
void acceptingAnAlreadyActiveConnectionIsRejected() {
|
||||
given()
|
||||
.formParam("Action", "AcceptVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidStateTransition"));
|
||||
}
|
||||
|
||||
/**
|
||||
* aws_vpc_peering_connection_options: both modules/vpc-peering and
|
||||
* modules/vpc-peering-cross-accounts-accepter set allow_remote_vpc_dns_resolution on one or
|
||||
* both sides.
|
||||
*/
|
||||
@Test
|
||||
@Order(5)
|
||||
void modifyPeeringConnectionOptionsSetsDnsResolutionPerSide() {
|
||||
given()
|
||||
.formParam("Action", "ModifyVpcPeeringConnectionOptions")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.formParam("AccepterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "true")
|
||||
.formParam("RequesterPeeringConnectionOptions.AllowDnsResolutionFromRemoteVpc", "true")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ModifyVpcPeeringConnectionOptionsResponse.accepterPeeringConnectionOptions"
|
||||
+ ".allowDnsResolutionFromRemoteVpc", equalTo("true"))
|
||||
.body("ModifyVpcPeeringConnectionOptionsResponse.requesterPeeringConnectionOptions"
|
||||
+ ".allowDnsResolutionFromRemoteVpc", equalTo("true"));
|
||||
|
||||
// Terraform's aws_vpc_peering_connection_options resource reads this back via Describe on
|
||||
// every plan, not by re-issuing Modify — it must round-trip here or the provider sees
|
||||
// permanent drift on a value it just set.
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet.item"
|
||||
+ ".accepterVpcInfo.peeringOptions.allowDnsResolutionFromRemoteVpc", equalTo("true"))
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet.item"
|
||||
+ ".requesterVpcInfo.peeringOptions.allowDnsResolutionFromRemoteVpc", equalTo("true"));
|
||||
}
|
||||
|
||||
/**
|
||||
* modules/vpc-peering routes traffic to the peer over the connection via aws_route with
|
||||
* vpc_peering_connection_id as the target — this must round-trip on DescribeRouteTables or the
|
||||
* provider sees permanent drift on the route resource it just created.
|
||||
*/
|
||||
@Test
|
||||
@Order(6)
|
||||
void createRouteWithThePeeringConnectionAsTargetRoundTrips() {
|
||||
routeTableId = given()
|
||||
.formParam("Action", "CreateRouteTable")
|
||||
.formParam("VpcId", requesterVpcId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateRouteTableResponse.routeTable.routeTableId");
|
||||
|
||||
given()
|
||||
.formParam("Action", "CreateRoute")
|
||||
.formParam("RouteTableId", routeTableId)
|
||||
.formParam("DestinationCidrBlock", "10.30.0.0/16")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("CreateRouteResponse.return", equalTo("true"));
|
||||
|
||||
given()
|
||||
.formParam("Action", "DescribeRouteTables")
|
||||
.formParam("RouteTableId.1", routeTableId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeRouteTablesResponse.routeTableSet.item.routeSet.item"
|
||||
+ ".find { it.destinationCidrBlock == '10.30.0.0/16' }.vpcPeeringConnectionId",
|
||||
equalTo(pcxId));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void deleteRemovesTheConnection() {
|
||||
given()
|
||||
.formParam("Action", "DeleteVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", pcxId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DeleteVpcPeeringConnectionResponse.return", equalTo("true"));
|
||||
|
||||
given()
|
||||
.formParam("Action", "DescribeVpcPeeringConnections")
|
||||
.formParam("VpcPeeringConnectionId.1", pcxId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVpcPeeringConnectionsResponse.vpcPeeringConnectionSet", emptyOrNullString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void deletingAnUnknownConnectionIsRejected() {
|
||||
given()
|
||||
.formParam("Action", "DeleteVpcPeeringConnection")
|
||||
.formParam("VpcPeeringConnectionId", "pcx-0000000000000dead")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcPeeringConnectionID.NotFound"));
|
||||
}
|
||||
|
||||
/**
|
||||
* vpc-peering-cross-accounts and vpc-peering-external both peer against a VPC id this account
|
||||
* never seeded (a different account/region's VPC). The accepter side must still be reported —
|
||||
* without a fabricated CIDR — rather than the request failing outright.
|
||||
*/
|
||||
@Test
|
||||
@Order(9)
|
||||
void peeringToAnUnknownAccepterVpcSucceedsWithNoAccepterCidr() {
|
||||
String vpcId = given()
|
||||
.formParam("Action", "CreateVpc")
|
||||
.formParam("CidrBlock", "10.2.0.0/16")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("CreateVpcResponse.vpc.vpcId");
|
||||
|
||||
String response = given()
|
||||
.formParam("Action", "CreateVpcPeeringConnection")
|
||||
.formParam("VpcId", vpcId)
|
||||
.formParam("PeerVpcId", "vpc-external0000000")
|
||||
.formParam("PeerOwnerId", "999999999999")
|
||||
.formParam("PeerRegion", "us-west-2")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.vpcId",
|
||||
equalTo("vpc-external0000000"))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.ownerId",
|
||||
equalTo("999999999999"))
|
||||
.body("CreateVpcPeeringConnectionResponse.vpcPeeringConnection.accepterVpcInfo.region",
|
||||
equalTo("us-west-2"))
|
||||
.extract().asString();
|
||||
|
||||
// The requester side (a VPC this account did seed) does carry a cidrBlock; only the
|
||||
// accepter side — a VPC never seeded here — must not have one fabricated.
|
||||
String accepterInfo = response.substring(response.indexOf("<accepterVpcInfo>"));
|
||||
assertThat(accepterInfo, not(containsString("<cidrBlock>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void createOnAnUnknownVpcIsRejected() {
|
||||
given()
|
||||
.formParam("Action", "CreateVpcPeeringConnection")
|
||||
.formParam("VpcId", "vpc-0000000000000dead")
|
||||
.formParam("PeerVpcId", "vpc-0000000000000beef")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVpcID.NotFound"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user