DBService implements RolesProvider { ServiceIdentity updateTemplateServiceIdentity(ServiceIdentity serviceIdentity, String domainName, List<TemplateParam> params) { String templateServiceName = serviceIdentity.getName().replace(TEMPLATE_DOMAIN_NAME, domainName); if (params != null) { for (TemplateParam param : params) { final String paramKey = "_" + param.getName() + "_"; templateServiceName = templateServiceName.replace(paramKey, param.getValue()); } } ServiceIdentity templateServiceIdentity = new ServiceIdentity().setName(templateServiceName); templateServiceIdentity.setDescription(serviceIdentity.getDescription()); templateServiceIdentity.setExecutable(serviceIdentity.getExecutable()); templateServiceIdentity.setGroup(serviceIdentity.getGroup()); templateServiceIdentity.setUser(serviceIdentity.getUser()); templateServiceIdentity.setProviderEndpoint(serviceIdentity.getProviderEndpoint()); List<PublicKeyEntry> publicKeyEntries = serviceIdentity.getPublicKeys(); List<PublicKeyEntry> newPublicKeyEntries = new ArrayList<>(); if (publicKeyEntries != null && !publicKeyEntries.isEmpty()) { for (PublicKeyEntry publicKeyEntry : publicKeyEntries) { PublicKeyEntry newPublicKeyEntry = new PublicKeyEntry(); newPublicKeyEntry.setId(publicKeyEntry.getId()); newPublicKeyEntry.setKey(publicKeyEntry.getKey()); newPublicKeyEntries.add(newPublicKeyEntry); } } templateServiceIdentity.setPublicKeys(newPublicKeyEntries); List<String> hosts = serviceIdentity.getHosts(); if (hosts != null) { templateServiceIdentity.setHosts(new ArrayList<>(hosts)); } return templateServiceIdentity; } DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator); DomainRoleMembers listOverdueReviewRoleMembers(String domainName); @Override List<Role> getRolesByDomain(String domain); ResourceAccessList getResourceAccessList(String principal, String action); AthenzDomain getAthenzDomain(final String domainName, boolean masterCopy); Quota getQuota(String domainName); void executePutRoleSystemMeta(ResourceContext ctx, final String domainName, final String roleName,
           RoleSystemMeta meta, final String attribute, final String auditRef, final String caller); void executePutGroupSystemMeta(ResourceContext ctx, final String domainName, final String groupName,
                                          GroupSystemMeta meta, final String attribute, final String auditRef); void executePutServiceIdentitySystemMeta(ResourceContext ctx, String domainName, String serviceName,
            ServiceIdentitySystemMeta meta, String attribute, String auditRef, String caller); void executePutRoleMeta(ResourceContext ctx, String domainName, String roleName, Role originalRole,
                                   RoleMeta meta, String auditRef, String caller); void executePutGroupMeta(ResourceContext ctx, final String domainName, final String groupName,
                                    GroupMeta meta, final String auditRef); Set<String> getPendingMembershipApproverRoles(int delayDays); Set<String> getPendingGroupMembershipApproverRoles(int delayDays); Map<String, DomainRoleMember> getRoleExpiryMembers(int delayDays); Map<String, DomainRoleMember> getRoleReviewMembers(int delayDays); Map<String, DomainGroupMember> getGroupExpiryMembers(int delayDays); void processExpiredPendingMembers(int pendingRoleMemberLifespan, final String monitorIdentity); void processExpiredPendingGroupMembers(int pendingGroupMemberLifespan, final String monitorIdentity); static int AUDIT_TYPE_ROLE; static int AUDIT_TYPE_POLICY; static int AUDIT_TYPE_SERVICE; static int AUDIT_TYPE_DOMAIN; static int AUDIT_TYPE_ENTITY; static int AUDIT_TYPE_TENANCY; static int AUDIT_TYPE_TEMPLATE; static int AUDIT_TYPE_GROUP; }
@Test public void testUpdateTemplateServiceIdentity() { ServiceIdentity service = createServiceObject("_domain_", "_service___api_-backend", "http: "users", "host1"); List<TemplateParam> params = new ArrayList<>(); params.add(new TemplateParam().setName("service").setValue("storage")); params.add(new TemplateParam().setName("api").setValue("java")); params.add(new TemplateParam().setName("name").setValue("notfound")); ServiceIdentity newService = zms.dbService.updateTemplateServiceIdentity(service, "athenz", params); assertEquals("athenz.storage_java-backend", newService.getName()); }