mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test: use generic tag and key fixtures instead of a downstream project's names (#4119)
* test: use generic tag and key fixtures instead of a downstream project's names Four test files used a particular consumer's project name and its own tag keys as arbitrary fixture values. The names carry no meaning for anyone reading these tests, and a reviewer flagged the same thing on #3944. No behaviour changes. The values are only ever compared against themselves. * test(s3): point the truncated-key guard at the key the rename produces The guard asked for ".store-sentinel", the tail of the old key. After the rename the tail is ".sentinel", so it requested a key neither behaviour ever stores and would have passed with a 404 even if the truncation bug returned. Derives the truncated key from the key under test and pins the derivation, so renaming the key cannot quietly empty the guard again.
This commit is contained in:
1 parent
2c8f43b600
commit
9e1e974712
4 files changed
+22
-15
No files matched your search
@@ -165,7 +165,7 @@ class EcrServiceTest {
|
||||
when(registryManager.tryEnsureStarted()).thenReturn(false);
|
||||
|
||||
Repository repo = service.createRepository(REPO, null, "IMMUTABLE", true, null, null,
|
||||
Map.of("Project", "choudoufu"), REGION);
|
||||
Map.of("Project", "platform"), REGION);
|
||||
|
||||
assertEquals(REPO, repo.getRepositoryName());
|
||||
assertEquals(ACCOUNT, repo.getRegistryId());
|
||||
@@ -173,7 +173,7 @@ class EcrServiceTest {
|
||||
repo.getRepositoryArn());
|
||||
assertTrue(repo.getRepositoryUri().endsWith("/" + REPO), repo.getRepositoryUri());
|
||||
assertEquals("IMMUTABLE", repo.getImageTagMutability());
|
||||
assertEquals("choudoufu", repo.getTags().get("Project"));
|
||||
assertEquals("platform", repo.getTags().get("Project"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1058,13 +1058,13 @@ class EksServiceTest {
|
||||
CreateClusterRequest request = new CreateClusterRequest();
|
||||
request.setName("probe-eks");
|
||||
request.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
|
||||
request.setTags(Map.of("tofu-estate", "probe1"));
|
||||
request.setTags(Map.of("team", "probe1"));
|
||||
|
||||
Cluster cluster = service.createCluster(request);
|
||||
|
||||
assertEquals(ClusterStatus.ACTIVE, cluster.getStatus());
|
||||
assertEquals("https://localhost:6500", cluster.getEndpoint());
|
||||
assertEquals("probe1", cluster.getTags().get("tofu-estate"));
|
||||
assertEquals("probe1", cluster.getTags().get("team"));
|
||||
// No k3s API server exists. The empty CA is what says so.
|
||||
assertEquals("", cluster.getCertificateAuthority().getData());
|
||||
assertNull(cluster.getContainerId());
|
||||
@@ -1079,12 +1079,12 @@ class EksServiceTest {
|
||||
CreateClusterRequest request = new CreateClusterRequest();
|
||||
request.setName("probe-eks");
|
||||
request.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
|
||||
request.setTags(Map.of("tofu-estate", "probe1"));
|
||||
request.setTags(Map.of("team", "probe1"));
|
||||
String arn = service.createCluster(request).getArn();
|
||||
|
||||
assertEquals(ClusterStatus.ACTIVE, service.describeCluster("probe-eks").getStatus());
|
||||
assertEquals(List.of("probe-eks"), service.listClusters());
|
||||
assertEquals("probe1", service.listTagsForResource(arn).get("tofu-estate"));
|
||||
assertEquals("probe1", service.listTagsForResource(arn).get("team"));
|
||||
|
||||
service.tagResource(arn, Map.of("Name", "probe-eks"));
|
||||
assertEquals("probe-eks", service.listTagsForResource(arn).get("Name"));
|
||||
|
||||
@@ -1714,12 +1714,12 @@ class RdsServiceTest {
|
||||
DbInstance instance = rdsService.createDbInstance("probe-db", "postgres", "16.3",
|
||||
"probeadmin", "ProbePassw0rd!", "dbname", "db.t3.micro",
|
||||
20, false, null, null, null, false, null,
|
||||
Map.of("tofu-estate", "probe1"));
|
||||
Map.of("team", "probe1"));
|
||||
|
||||
assertEquals(DbInstanceStatus.AVAILABLE, instance.getStatus());
|
||||
assertEquals("arn:aws:rds:us-east-1:123456789012:db:probe-db", instance.getDbInstanceArn());
|
||||
assertNotNull(instance.getEndpoint());
|
||||
assertEquals("probe1", instance.getTags().get("tofu-estate"));
|
||||
assertEquals("probe1", instance.getTags().get("team"));
|
||||
// Nothing was started, so no runtime is claimed; the storage identity is kept for the retry.
|
||||
assertNull(instance.getContainerId());
|
||||
assertNull(instance.getContainerHost());
|
||||
@@ -1737,10 +1737,10 @@ class RdsServiceTest {
|
||||
DbInstance created = rdsService.createDbInstance("probe-db", "postgres", "16.3",
|
||||
"probeadmin", "ProbePassw0rd!", "dbname", "db.t3.micro",
|
||||
20, false, null, null, null, false, null,
|
||||
Map.of("tofu-estate", "probe1"));
|
||||
Map.of("team", "probe1"));
|
||||
|
||||
assertEquals(1, rdsService.listDbInstances("probe-db").size());
|
||||
assertEquals("probe1", rdsService.listTagsForResource(created.getDbInstanceArn()).get("tofu-estate"));
|
||||
assertEquals("probe1", rdsService.listTagsForResource(created.getDbInstanceArn()).get("team"));
|
||||
|
||||
rdsService.addTagsToResource(created.getDbInstanceArn(), Map.of("Name", "probe-db"), "us-east-1");
|
||||
assertEquals("probe-db", rdsService.listTagsForResource(created.getDbInstanceArn()).get("Name"));
|
||||
|
||||
+12
-5
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
@@ -417,7 +418,7 @@ class S3VirtualHostIntegrationTest {
|
||||
}
|
||||
|
||||
// A key may contain the bucket's own name as a path segment, for example
|
||||
// "tofu-records/<bucket>/...". The raw request path of a virtual-hosted request is the key
|
||||
// "archive/<bucket>/...". The raw request path of a virtual-hosted request is the key
|
||||
// alone, so the "/<bucket>/" inside it is part of the key and not the path-style bucket
|
||||
// prefix.
|
||||
@Test
|
||||
@@ -429,7 +430,7 @@ class S3VirtualHostIntegrationTest {
|
||||
String segmentHost = segmentBucket + ".localhost";
|
||||
given().header("Host", segmentHost).when().put("/").then().statusCode(200);
|
||||
|
||||
String key = "tofu-records/" + segmentBucket + "/.store-sentinel";
|
||||
String key = "archive/" + segmentBucket + "/.sentinel";
|
||||
given()
|
||||
.header("Host", segmentHost)
|
||||
.contentType("text/plain")
|
||||
@@ -442,7 +443,7 @@ class S3VirtualHostIntegrationTest {
|
||||
given()
|
||||
.header("Host", segmentHost)
|
||||
.queryParam("list-type", "2")
|
||||
.queryParam("prefix", "tofu-records/" + segmentBucket + "/")
|
||||
.queryParam("prefix", "archive/" + segmentBucket + "/")
|
||||
.when()
|
||||
.get("/")
|
||||
.then()
|
||||
@@ -457,11 +458,17 @@ class S3VirtualHostIntegrationTest {
|
||||
.statusCode(200)
|
||||
.body(equalTo("sentinel"));
|
||||
|
||||
// And nothing was stored under the truncated key.
|
||||
// And nothing was stored under the truncated key: what would remain if the "/<bucket>/"
|
||||
// inside the key were mistaken for the path-style bucket prefix and stripped. Derived from
|
||||
// the key rather than written out, so renaming the key cannot leave this asking for a
|
||||
// third key that neither behaviour ever stores.
|
||||
String truncated = key.substring(key.indexOf("/" + segmentBucket + "/")
|
||||
+ segmentBucket.length() + 2);
|
||||
assertEquals(".sentinel", truncated, "the guard below must name the truncation, not a third key");
|
||||
given()
|
||||
.header("Host", segmentHost)
|
||||
.when()
|
||||
.get("/.store-sentinel")
|
||||
.get("/" + truncated)
|
||||
.then()
|
||||
.statusCode(404);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user