mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(iam): check Translate's terminology rule under enforcement (#6936)
Translate was the one namespace #6927 read without a test under enforcement. TranslateText and TranslateDocument are checked on the terminologies their TerminologyNames give, terminology/<name>; the new case grants each on one terminology and checks that a translation naming it passes and one naming another is refused.
This commit is contained in:
1 parent
f8d37ded69
commit
17a8d76cee
1 file changed
+27
+27
@@ -19,6 +19,8 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -843,6 +845,26 @@ class IamRequestResourceEnforcementIntegrationTest {
|
||||
refusedJson(serviceQuota(user, "L-00000000"), "servicequotas:GetServiceQuota");
|
||||
}
|
||||
|
||||
/** A translation is checked on the terminology its {@code TerminologyNames} give, {@code terminology/<name>}. */
|
||||
@Test
|
||||
void aTranslationIsCheckedOnTheTerminologyItNames() {
|
||||
String name = "res-terminology-" + suffix();
|
||||
String arn = "arn:aws:translate:" + REGION + ":" + ACCOUNT + ":terminology/" + name;
|
||||
String text = "\"Text\":\"hello\",\"SourceLanguageCode\":\"en\",\"TargetLanguageCode\":\"fr\"";
|
||||
String document = "\"Document\":{\"Content\":\""
|
||||
+ Base64.getEncoder().encodeToString("hello".getBytes(StandardCharsets.UTF_8))
|
||||
+ "\",\"ContentType\":\"text/plain\"},\"SourceLanguageCode\":\"en\",\"TargetLanguageCode\":\"fr\"";
|
||||
User user = user("res-terminology");
|
||||
user.policy(allowOn("translate:TranslateText", arn) + "," + allowOn("translate:TranslateDocument", arn));
|
||||
translate(user, "TranslateText", "{" + text + ",\"TerminologyNames\":[\"" + name + "\"]}").statusCode(200);
|
||||
refusedJson(translate(user, "TranslateText", "{" + text + ",\"TerminologyNames\":[\"" + name + "-other\"]}"),
|
||||
"translate:TranslateText");
|
||||
translate(user, "TranslateDocument", "{" + document + ",\"TerminologyNames\":[\"" + name + "\"]}")
|
||||
.statusCode(200);
|
||||
refusedJson(translate(user, "TranslateDocument", "{" + document + ",\"TerminologyNames\":[\"" + name
|
||||
+ "-other\"]}"), "translate:TranslateDocument");
|
||||
}
|
||||
|
||||
/** A monthly cost budget of the name, with a billing view ARN when one is given. */
|
||||
private static String budget(String name, String billingViewArn) {
|
||||
return "{\"BudgetName\":\"" + name + "\",\"BudgetType\":\"COST\",\"TimeUnit\":\"MONTHLY\",\"BudgetLimit\":"
|
||||
@@ -871,6 +893,11 @@ class IamRequestResourceEnforcementIntegrationTest {
|
||||
.body("{\"ServiceCode\":\"codebuild\",\"QuotaCode\":\"" + quotaCode + "\"}").post("/").then();
|
||||
}
|
||||
|
||||
private static ValidatableResponse translate(User user, String operation, String body) {
|
||||
return user.json("translate", "AWSShineFrontendService_20170701." + operation, "1.1").body(body).post("/")
|
||||
.then();
|
||||
}
|
||||
|
||||
private static ValidatableResponse codeBuild(User user, String operation, String body) {
|
||||
return user.json("codebuild", "CodeBuild_20161006." + operation, "1.1").body(body).post("/").then();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user