Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for get policy #2254

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions servers/zms/src/test/java/com/yahoo/athenz/zms/ZMSImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33956,6 +33956,40 @@ public void testValidateGcpProjectDetails() {
assertFalse(zmsImpl.validateGcpProjectDetails("1234", null));
}

@Test
public void testGetPolicyWithTags() {

ZMSImpl zmsImpl = zmsTestInitializer.getZms();
RsrcCtxWrapper ctx = zmsTestInitializer.getMockDomRsrcCtx();
final String auditRef = zmsTestInitializer.getAuditRef();

final String domainName = "setup-policy-with-tags";
TopLevelDomain dom1 = zmsTestInitializer.createTopLevelDomainObject(domainName,
"Test Domain1", "testOrg", zmsTestInitializer.getAdminUser());
zmsImpl.postTopLevelDomain(ctx, auditRef, dom1);
Map<String, TagValueList> policy1Tags = Collections.singletonMap("tag-key", new TagValueList().setList(Arrays.asList("val2", "val3")));
Policy policy1 = zmsTestInitializer.createPolicyObject(domainName, "policy1");
policy1.setTags(policy1Tags);
zmsImpl.putPolicy(ctx, domainName, "policy1", auditRef, false, policy1);

Policy policy1version2 = zmsTestInitializer.createPolicyObject(domainName, "policy1");
Map<String, TagValueList> policy2Tags = Collections.singletonMap("tag-key2", new TagValueList().setList(Arrays.asList("val5", "val6")));
policy1version2.setVersion("2");
policy1version2.setActive(false);
policy1version2.setTags(policy2Tags);
zmsImpl.putPolicy(ctx, domainName, "policy1", auditRef, false, policy1version2);

Policy returnedPolicy = zmsImpl.getPolicy(ctx, domainName, "policy1");
verifyPolicyHasTag(returnedPolicy, "tag-key", "val2");

zmsImpl.setActivePolicyVersion(ctx,domainName, "policy1",new PolicyOptions().setFromVersion("0").setVersion("2"), "test");

Policy returnedPolicy2 = zmsImpl.getPolicy(ctx, domainName, "policy1");
verifyPolicyHasTag(returnedPolicy2, "tag-key2", "val6");

zmsImpl.deleteTopLevelDomain(ctx, domainName, auditRef);
}

@Test
public void testSetupPolicyListWithTags() {

Expand Down