DataCache { void processRoleTrustDomain(String roleName, String trustDomain) { if (trustDomain == null) { return; } if (!trustCache.containsKey(trustDomain)) { trustCache.put(trustDomain, new HashSet<>()); } final Set<String> rolesForTrustDomain = trustCache.get(trustDomain); rolesForTrustDomain.add(roleName); } DataCache(); void setDomainData(DomainData domainData); DomainData getDomainData(); void processRole(Role role); void processPolicy(String domainName, Policy policy, Map<String, Role> roles); void processServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity service); Set<MemberRole> getMemberRoleSet(final String member); List<String> getProviderDnsSuffixList(final String provider); List<String> getProviderHostnameAllowedSuffixList(final String provider); List<String> getProviderHostnameDeniedSuffixList(final String provider); Set<MemberRole> getAllMemberRoleSet(); Map<String, Set<MemberRole>> getPrefixMemberRoleSetMap(); int getMemberCount(); Set<String> getAWSResourceRoleSet(String role); RoleMeta getRoleMeta(String role); Map<String, Set<String>> getTrustMap(); Map<String, Set<String>> getHostMap(); Map<String, String> getPublicKeyMap(); Map<String, List<String>> getProviderDnsSuffixCache(); Map<String, List<String>> getProviderHostnameAllowedSuffixCache(); Map<String, List<String>> getProviderHostnameDeniedSuffixCache(); static final String ACTION_ASSUME_ROLE; static final String ACTION_ASSUME_AWS_ROLE; static final String ACTION_LAUNCH; static final String RESOURCE_DNS_PREFIX; static final String RESOURCE_HOSTNAME_PREFIX; }
@Test public void testProcessRoleTrustDomain() { DataCache cache = new DataCache(); cache.processRoleTrustDomain("dom.role1", "trustD"); Map<String, Set<String>> map = cache.getTrustMap(); assertNotNull(map); assertEquals(map.size(), 1); assertTrue(map.containsKey("trustD")); assertEquals(map.get("trustD").size(), 1); assertTrue(map.get("trustD").contains("dom.role1")); }