mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(route53resolver): add TagResource, UntagResource and ListTagsForResource (#6035)
* feat(route53resolver): add TagResource, UntagResource and ListTagsForResource The Terraform provider lists tags after creating any aws_route53_resolver_* resource, and Route 53 Resolver had no tagging operations, so the apply failed right after the create succeeded. Tags are kept per ARN in their own store, because none of the modelled resource shapes carries a Tags member. Resolver endpoints, resolver rules and custom firewall domain lists are taggable; tags passed to their Create calls are stored, and validated before anything is allocated. Lookup resolves the id in the caller's account and requires the stored ARN to match exactly, so an ARN naming another account, region or partition is ResourceNotFoundException. ListTagsForResource pages with MaxResults (1-100, default 100) and NextToken. * fix(route53resolver): scope tagging lookups to the caller and type-check tag input TagResource, UntagResource and ListTagsForResource now require the ARN to name the caller's own partition, region and account before reading any store, and fetch the resource with getForAccountMigratingLegacy, so an unprefixed pre-multi-account entry is migrated only into the account its stored ARN names. Before, a plain get() moved such an entry into whichever account looked it up first, and that account could then tag it by naming its original ARN. Tag Key and Value, and each UntagResource TagKeys entry, must be JSON strings (TagKey/TagValue are string shapes) instead of being coerced with asText(). MaxResults must be an integral number before its 1-100 range is checked, so 1.5 or true is InvalidParameterException rather than 1. ListTagsForResource copies the stored tag node under the monitor that TagResource and UntagResource mutate it under, so a concurrent tag change can no longer break the iteration or show a half-applied page. * fix(route53resolver): page tags through Pagination and cap tag lists at 200 ListTagsForResource now pages through the shared Pagination.paginate with an opaque, namespaced cursor on the tag key instead of a raw offset, so a forged or stale offset token is InvalidNextTokenException. MaxResults stays type-checked against the JSON value (integer 1-100, InvalidParameterException). TagResource Tags, UntagResource TagKeys and the Tags on CreateResolverEndpoint, CreateResolverRule and CreateFirewallDomainList are capped at the modelled 200 entries per request (TagList/TagKeyList max 200). Over the cap is the operation's parameter error: InvalidParameterException, or ValidationException on CreateFirewallDomainList. No per-resource total is enforced; the model does not state one.
This commit is contained in:
1 parent
37717537a4
commit
2f6f3a8f86
10 files changed
+717
-2
No files matched your search
+2
-1
@@ -37,7 +37,8 @@ class Route53ResolverReplayFallbackTest {
|
||||
void setUp() {
|
||||
endpointIpRequests = new InMemoryStorage<>();
|
||||
service = new Route53ResolverService(new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), endpointIpRequests, objectMapper);
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), endpointIpRequests, new InMemoryStorage<>(),
|
||||
objectMapper);
|
||||
}
|
||||
|
||||
private JsonNode createRequest(String token, String ip) {
|
||||
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
package io.github.hectorvent.floci.services.route53resolver;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
/**
|
||||
* TagResource / UntagResource / ListTagsForResource for the Route 53 Resolver resources Floci
|
||||
* stores: resolver endpoints, resolver rules and custom firewall domain lists. Tags given to
|
||||
* a Create call must be readable back through ListTagsForResource, which is how the Terraform
|
||||
* provider reads them after every create.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class Route53ResolverTaggingIntegrationTest {
|
||||
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
private static final String AUTH_HEADER =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/route53resolver/aws4_request";
|
||||
private static final String OTHER_ACCOUNT_AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=000000000077/20260101/us-east-1/route53resolver/aws4_request";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
private static ValidatableResponse call(String action, String body) {
|
||||
return call(AUTH_HEADER, action, body);
|
||||
}
|
||||
|
||||
private static ValidatableResponse call(String auth, String action, String body) {
|
||||
return given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "Route53Resolver." + action)
|
||||
.header("Authorization", auth)
|
||||
.body(body)
|
||||
.when()
|
||||
.post("/")
|
||||
.then();
|
||||
}
|
||||
|
||||
private static String createEndpoint(String tagsJson) {
|
||||
return call("CreateResolverEndpoint", """
|
||||
{"Name":"tagged","Direction":"OUTBOUND","SecurityGroupIds":["sg-1"],
|
||||
"IpAddresses":[{"SubnetId":"subnet-a"},{"SubnetId":"subnet-b"}],
|
||||
"Tags":%s}""".formatted(tagsJson))
|
||||
.statusCode(200)
|
||||
.extract().path("ResolverEndpoint.Arn");
|
||||
}
|
||||
|
||||
private static ValidatableResponse listTags(String arn) {
|
||||
return call("ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createResolverEndpoint_tagsAreListed_andNotOnTheEndpointShape() {
|
||||
String arn = createEndpoint("[{\"Key\":\"env\",\"Value\":\"dev\"},{\"Key\":\"team\",\"Value\":\"net\"}]");
|
||||
|
||||
listTags(arn)
|
||||
.statusCode(200)
|
||||
.body("Tags.Key", containsInAnyOrder("env", "team"))
|
||||
.body("Tags.find { it.Key == 'env' }.Value", equalTo("dev"));
|
||||
|
||||
String id = arn.substring(arn.lastIndexOf('/') + 1);
|
||||
call("GetResolverEndpoint", "{\"ResolverEndpointId\":\"" + id + "\"}")
|
||||
.statusCode(200)
|
||||
.body("ResolverEndpoint.Tags", nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void tagUntagLifecycle_onResolverEndpoint() {
|
||||
String arn = createEndpoint("[]");
|
||||
listTags(arn).statusCode(200).body("Tags", empty());
|
||||
|
||||
call("TagResource", """
|
||||
{"ResourceArn":"%s","Tags":[{"Key":"a","Value":"1"},{"Key":"b","Value":"2"}]}""".formatted(arn))
|
||||
.statusCode(200);
|
||||
call("TagResource", """
|
||||
{"ResourceArn":"%s","Tags":[{"Key":"a","Value":"changed"}]}""".formatted(arn))
|
||||
.statusCode(200);
|
||||
listTags(arn)
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(2))
|
||||
.body("Tags.find { it.Key == 'a' }.Value", equalTo("changed"));
|
||||
|
||||
call("UntagResource", "{\"ResourceArn\":\"" + arn + "\",\"TagKeys\":[\"a\",\"absent\"]}")
|
||||
.statusCode(200);
|
||||
listTags(arn)
|
||||
.statusCode(200)
|
||||
.body("Tags.Key", containsInAnyOrder("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolverRule_isTaggable() {
|
||||
String arn = call("CreateResolverRule", """
|
||||
{"Name":"r","RuleType":"FORWARD","DomainName":"example.com",
|
||||
"TargetIps":[{"Ip":"10.0.0.2","Port":53}],
|
||||
"Tags":[{"Key":"k","Value":"v"}]}""")
|
||||
.statusCode(200)
|
||||
.extract().path("ResolverRule.Arn");
|
||||
|
||||
listTags(arn).statusCode(200).body("Tags.Key", containsInAnyOrder("k"));
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\",\"Tags\":[{\"Key\":\"k2\",\"Value\":\"\"}]}")
|
||||
.statusCode(200);
|
||||
listTags(arn).statusCode(200).body("Tags.Key", containsInAnyOrder("k", "k2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void firewallDomainList_isTaggable() {
|
||||
String arn = call("CreateFirewallDomainList", """
|
||||
{"Name":"fdl","Tags":[{"Key":"k","Value":"v"}]}""")
|
||||
.statusCode(200)
|
||||
.extract().path("FirewallDomainList.Arn");
|
||||
|
||||
listTags(arn).statusCode(200).body("Tags.Key", containsInAnyOrder("k"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listTags_pagesWithMaxResults() {
|
||||
String arn = createEndpoint("[{\"Key\":\"a\",\"Value\":\"1\"},{\"Key\":\"b\",\"Value\":\"2\"}]");
|
||||
|
||||
String token = call("ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\",\"MaxResults\":1}")
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(1))
|
||||
.body("NextToken", notNullValue())
|
||||
.extract().path("NextToken");
|
||||
call("ListTagsForResource",
|
||||
"{\"ResourceArn\":\"" + arn + "\",\"MaxResults\":1,\"NextToken\":\"" + token + "\"}")
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(1))
|
||||
.body("NextToken", nullValue());
|
||||
|
||||
for (String malformed : new String[] {"1.5", "true", "\"1\"", "0", "101"}) {
|
||||
call("ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\",\"MaxResults\":" + malformed + "}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
}
|
||||
|
||||
// The token is an opaque cursor, not an offset a caller can forge.
|
||||
for (String forged : new String[] {"bogus", "1", "0"}) {
|
||||
call("ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\",\"NextToken\":\"" + forged + "\"}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidNextTokenException"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void tagListsAreCappedAt200EntriesPerRequest() {
|
||||
String arn = createEndpoint("[]");
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\",\"Tags\":" + tags(200) + "}").statusCode(200);
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\",\"Tags\":" + tags(201) + "}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
call("UntagResource", "{\"ResourceArn\":\"" + arn + "\",\"TagKeys\":" + keys(201) + "}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
listTags(arn).statusCode(200).body("Tags", hasSize(100));
|
||||
call("UntagResource", "{\"ResourceArn\":\"" + arn + "\",\"TagKeys\":" + keys(200) + "}").statusCode(200);
|
||||
listTags(arn).statusCode(200).body("Tags", empty());
|
||||
|
||||
createEndpoint(tags(200));
|
||||
call("CreateResolverEndpoint", """
|
||||
{"Name":"over","Direction":"OUTBOUND","SecurityGroupIds":["sg-1"],
|
||||
"IpAddresses":[{"SubnetId":"subnet-a"},{"SubnetId":"subnet-b"}],"Tags":%s}""".formatted(tags(201)))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
call("CreateResolverRule", """
|
||||
{"Name":"ok","RuleType":"SYSTEM","DomainName":"ok.example","Tags":%s}""".formatted(tags(200)))
|
||||
.statusCode(200);
|
||||
call("CreateResolverRule", """
|
||||
{"Name":"over","RuleType":"SYSTEM","DomainName":"over.example","Tags":%s}""".formatted(tags(201)))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
call("CreateFirewallDomainList", "{\"Name\":\"ok\",\"Tags\":" + tags(200) + "}").statusCode(200);
|
||||
call("CreateFirewallDomainList", "{\"Name\":\"over\",\"Tags\":" + tags(201) + "}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"));
|
||||
}
|
||||
|
||||
private static String tags(int n) {
|
||||
return IntStream.range(0, n).mapToObj(i -> "{\"Key\":\"k" + i + "\",\"Value\":\"v\"}")
|
||||
.collect(Collectors.joining(",", "[", "]"));
|
||||
}
|
||||
|
||||
private static String keys(int n) {
|
||||
return IntStream.range(0, n).mapToObj(i -> "\"k" + i + "\"").collect(Collectors.joining(",", "[", "]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownOrDeletedResource_isResourceNotFound() {
|
||||
listTags("arn:aws:route53resolver:us-east-1:000000000000:resolver-endpoint/rslvr-out-doesnotexist1")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
|
||||
String arn = createEndpoint("[{\"Key\":\"a\",\"Value\":\"1\"}]");
|
||||
String id = arn.substring(arn.lastIndexOf('/') + 1);
|
||||
call("DeleteResolverEndpoint", "{\"ResolverEndpointId\":\"" + id + "\"}").statusCode(200);
|
||||
listTags(arn)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\",\"Tags\":[{\"Key\":\"a\",\"Value\":\"1\"}]}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void arnNamingAnotherRegionOrAccount_isResourceNotFound() {
|
||||
String arn = createEndpoint("[{\"Key\":\"a\",\"Value\":\"1\"}]");
|
||||
|
||||
listTags(arn.replace(":us-east-1:", ":us-west-2:"))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
listTags(arn.replace(":000000000000:", ":000000000077:"))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
listTags(arn.replace("arn:aws:", "arn:aws-cn:"))
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
// Another account cannot read or write this account's resource by its exact ARN.
|
||||
call(OTHER_ACCOUNT_AUTH, "ListTagsForResource", "{\"ResourceArn\":\"" + arn + "\"}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
call(OTHER_ACCOUNT_AUTH, "UntagResource", "{\"ResourceArn\":\"" + arn + "\",\"TagKeys\":[\"a\"]}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
listTags(arn).statusCode(200).body("Tags.Key", containsInAnyOrder("a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidTags_areRejected_andCreateWithInvalidTagStoresNothing() {
|
||||
String arn = createEndpoint("[]");
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\",\"Tags\":[{\"Key\":\"\",\"Value\":\"v\"}]}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidTagException"));
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\",\"Tags\":[{\"Key\":\"k\"}]}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidTagException"));
|
||||
for (String malformed : new String[] {
|
||||
"{\"Key\":123,\"Value\":\"v\"}", "{\"Key\":\"k\",\"Value\":true}",
|
||||
"{\"Key\":\"k\",\"Value\":{\"x\":1}}", "{\"Key\":[\"k\"],\"Value\":\"v\"}"}) {
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\",\"Tags\":[" + malformed + "]}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidTagException"));
|
||||
}
|
||||
call("UntagResource", "{\"ResourceArn\":\"" + arn + "\",\"TagKeys\":[123]}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
call("TagResource", "{\"ResourceArn\":\"" + arn + "\"}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
call("UntagResource", "{\"ResourceArn\":\"" + arn + "\"}")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
listTags(arn).statusCode(200).body("Tags", empty());
|
||||
|
||||
int before = call("ListResolverRules", "{}").statusCode(200).extract().path("ResolverRules.size()");
|
||||
call("CreateResolverRule", """
|
||||
{"Name":"bad","RuleType":"SYSTEM","DomainName":"bad.example","Tags":[{"Key":"","Value":"v"}]}""")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterException"));
|
||||
call("ListResolverRules", "{}").statusCode(200).body("ResolverRules", hasSize(before));
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package io.github.hectorvent.floci.services.route53resolver;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Tagging behaviour that depends on storage state the public API cannot produce: a
|
||||
* pre-multi-account (unprefixed) resource entry, and reads of the shared tag store.
|
||||
*/
|
||||
class Route53ResolverTaggingStorageTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
private static final String DEFAULT_ACCOUNT = "000000000000";
|
||||
private static final String OWNER = "111111111111";
|
||||
private static final String OTHER = "222222222222";
|
||||
private static final String ID = "rslvr-out-legacy0000001";
|
||||
private static final String ARN =
|
||||
"arn:aws:route53resolver:us-east-1:" + OWNER + ":resolver-endpoint/" + ID;
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private Route53ResolverService service(InMemoryStorage<String, ObjectNode> endpointDelegate,
|
||||
InMemoryStorage<String, ObjectNode> tagStore) {
|
||||
return new Route53ResolverService(new InMemoryStorage<>(),
|
||||
new AccountAwareStorageBackend<>(endpointDelegate, null, DEFAULT_ACCOUNT),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(), tagStore,
|
||||
objectMapper);
|
||||
}
|
||||
|
||||
private InMemoryStorage<String, ObjectNode> legacyEndpointStore() {
|
||||
InMemoryStorage<String, ObjectNode> delegate = new InMemoryStorage<>();
|
||||
delegate.put(ID, objectMapper.createObjectNode().put("Id", ID).put("Arn", ARN));
|
||||
return delegate;
|
||||
}
|
||||
|
||||
private ArrayNode tags(String key, String value) {
|
||||
ArrayNode tags = objectMapper.createArrayNode();
|
||||
tags.addObject().put("Key", key).put("Value", value);
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Test
|
||||
void legacyResource_isNotClaimedByAnotherAccountNamingItsArn() {
|
||||
InMemoryStorage<String, ObjectNode> delegate = legacyEndpointStore();
|
||||
Route53ResolverService service = service(delegate, new InMemoryStorage<>());
|
||||
|
||||
AwsException tag = assertThrows(AwsException.class,
|
||||
() -> service.tagResource(ARN, tags("k", "v"), REGION, OTHER));
|
||||
assertEquals("ResourceNotFoundException", tag.getErrorCode());
|
||||
AwsException list = assertThrows(AwsException.class,
|
||||
() -> service.listTagsForResource(ARN, null, null, REGION, OTHER));
|
||||
assertEquals("ResourceNotFoundException", list.getErrorCode());
|
||||
// Naming the same id under its own account must not drag the legacy entry over either.
|
||||
AwsException ownArn = assertThrows(AwsException.class,
|
||||
() -> service.listTagsForResource(ARN.replace(OWNER, OTHER), null, null, REGION, OTHER));
|
||||
assertEquals("ResourceNotFoundException", ownArn.getErrorCode());
|
||||
|
||||
// The legacy entry stays where it was; no other account's partition gained it.
|
||||
assertTrue(delegate.get(ID).isPresent());
|
||||
assertEquals(1, delegate.keys().size(), delegate.keys().toString());
|
||||
|
||||
// Its real owner can still tag it, which migrates it into the owner's partition.
|
||||
service.tagResource(ARN, tags("k", "v"), REGION, OWNER);
|
||||
assertEquals("v", service.listTagsForResource(ARN, null, null, REGION, OWNER)
|
||||
.path("Tags").path(0).path("Value").asText());
|
||||
assertTrue(delegate.get(OWNER + "/" + ID).isPresent());
|
||||
assertFalse(delegate.get(ID).isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listTags_readsTheTagStoreUnderTheMutatorsMonitor() {
|
||||
AtomicReference<Route53ResolverService> self = new AtomicReference<>();
|
||||
AtomicBoolean unlockedRead = new AtomicBoolean();
|
||||
InMemoryStorage<String, ObjectNode> tagStore = new InMemoryStorage<>() {
|
||||
@Override
|
||||
public Optional<ObjectNode> get(String key) {
|
||||
if (!Thread.holdsLock(self.get())) {
|
||||
unlockedRead.set(true);
|
||||
}
|
||||
return super.get(key);
|
||||
}
|
||||
};
|
||||
Route53ResolverService service = service(legacyEndpointStore(), tagStore);
|
||||
self.set(service);
|
||||
|
||||
service.tagResource(ARN, tags("k", "v"), REGION, OWNER);
|
||||
service.listTagsForResource(ARN, null, null, REGION, OWNER);
|
||||
|
||||
assertFalse(unlockedRead.get(), "ListTagsForResource read the live tag node outside the monitor");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user