mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 09:47:56 -05:00
fix(resourceexplorer2): give resource-tag conditions the tags of the resource a request names (#8719)
The generated request resources give Resource Explorer's index and view types the aws:ResourceTag/ key, but ResourceExplorer2Service answered no tags, so a condition on an index's or a view's tags saw none. Its storedTags now reads the index or view stored under the ARN in the account it names, in place, matched on the whole ARN both are kept by; each is an immutable record that tagging replaces. Tag changes now take the service's lock, so two on one resource keep each other's tags.
This commit is contained in:
1 parent
6c18ec745e
commit
7ed62b2597
5 files changed
+79
-5
No files matched your search
@@ -1145,6 +1145,32 @@ class IamRestRouteEnforcementIntegrationTest {
|
||||
return sink;
|
||||
}
|
||||
|
||||
/**
|
||||
* An {@code aws:ResourceTag} condition reads the tags Resource Explorer holds on the view a request names, so an
|
||||
* allow on one team's tag lets the caller read that team's view and not another's.
|
||||
*/
|
||||
@Test
|
||||
void aResourceExplorerResourceTagConditionReadsTheTagsOfTheView() {
|
||||
String tagged = taggedView("data");
|
||||
String other = taggedView("web");
|
||||
String user = user("route-view-tags");
|
||||
|
||||
policy(user, onTeam("Allow", "resource-explorer-2:GetView", "data"));
|
||||
request(user, "resource-explorer-2", "POST", "/GetView", "{\"ViewArn\":\"" + tagged + "\"}").statusCode(200);
|
||||
refused(request(user, "resource-explorer-2", "POST", "/GetView", "{\"ViewArn\":\"" + other + "\"}"),
|
||||
"resource-explorer-2:GetView");
|
||||
}
|
||||
|
||||
/** The ARN of a Resource Explorer view an administrator creates tagged with the team, deleted after the test. */
|
||||
private String taggedView(String team) {
|
||||
String view = adminOf("resource-explorer-2").body("{\"ViewName\":\"route-view-" + suffix()
|
||||
+ "\",\"Tags\":{\"team\":\"" + team + "\"}}").post("/CreateView")
|
||||
.then().statusCode(200).extract().path("View.ViewArn");
|
||||
cleanup.register(() -> adminOf("resource-explorer-2").body("{\"ViewArn\":\"" + view + "\"}")
|
||||
.post("/DeleteView"));
|
||||
return view;
|
||||
}
|
||||
|
||||
@Test
|
||||
void oamIsCheckedOnTheArnItsIdentifiersHold() {
|
||||
String sink = oamSink("{}");
|
||||
|
||||
+16
@@ -47,6 +47,22 @@ class ResourceExplorer2DefaultViewLookupTest {
|
||||
new ObjectMapper(), indexStore, viewStore, defaultViewStore, new InMemoryStorage<>(),
|
||||
new ResourceExplorer2RequestContext());
|
||||
|
||||
/**
|
||||
* IAM's tag lookup reads the tags held on the view the whole ARN names, as tagging leaves them, read in place;
|
||||
* nothing for an ARN naming no stored view or index.
|
||||
*/
|
||||
@Test
|
||||
void storedTagsAreTheTagsOfTheViewTheArnNames() {
|
||||
String view = service.createView(REGION, "tagged", null, null, List.of(), Map.of("team", "data")).viewArn();
|
||||
service.tagResource(view, Map.of("env", "prod"));
|
||||
service.untagResource(view, List.of("team"));
|
||||
|
||||
assertEquals(Map.of("env", "prod"), service.storedTags(view));
|
||||
assertEquals(Map.of(), service.storedTags(VIEWS + "absent/1"));
|
||||
assertEquals(Map.of(), service.storedTags("arn:aws:s3:::bucket"));
|
||||
assertTrue(indexStore.scan(key -> true).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void theDefaultViewIsReadWithoutProvisioningTheBaseline() {
|
||||
// No index yet: a request naming no view would provision the baseline, whose view's id is not minted yet.
|
||||
|
||||
Reference in new issue
Block a user