IdentityProviderMapper { public IdentityProvider convert(SocialIdentityProviderEntity socialIdentityProviderEntity) { IdentityProvider idpItem = new IdentityProvider(); idpItem.setAuthorizationEndpoint(socialIdentityProviderEntity.getAuthorizationEndpoint()); idpItem.setClientId(socialIdentityProviderEntity.getClientId()); idpItem.setColor(socialIdentityProviderEntity.getColor()); idpItem.setDescription(socialIdentityProviderEntity.getDescription()); idpItem.setDisplay(socialIdentityProviderEntity.getDisplay()); idpItem.setEmailRequired(socialIdentityProviderEntity.isEmailRequired()); idpItem.setId(socialIdentityProviderEntity.getId()); idpItem.setName(socialIdentityProviderEntity.getName()); idpItem.setOptionalUrlParams(socialIdentityProviderEntity.getOptionalUrlParams()); idpItem.setRequiredUrlParams(socialIdentityProviderEntity.getRequiredUrlParams()); idpItem.setScopes(socialIdentityProviderEntity.getScopes()); idpItem.setTokenIntrospectionEndpoint(socialIdentityProviderEntity.getTokenIntrospectionEndpoint()); idpItem.setType(IdentityProviderType.fromValue(socialIdentityProviderEntity.getType().name())); idpItem.setUserLogoutEndpoint(socialIdentityProviderEntity.getUserLogoutEndpoint()); return idpItem; }  IdentityProvider convert(SocialIdentityProviderEntity socialIdentityProviderEntity);  }
@Test public void testGraviteeIoAMProvider() { AMIdentityProviderEntity providerEntity = new AMIdentityProviderEntity(serverUrl); providerEntity.setClientId(IDP_CLIENT_ID); providerEntity.setClientSecret(IDP_CLIENT_SECRET); providerEntity.setColor(IDP_COLOR); providerEntity.setDescription(IDP_DESCRIPTION); providerEntity.setDiscoveryEndpoint(IDP_DISCOVERY_ENDPOINT); providerEntity.setEmailRequired(IDP_EMAIL_REQUIRED); providerEntity.setGroupMappings(new ArrayList<>()); providerEntity.setId(IDP_ID); providerEntity.setName(IDP_NAME); providerEntity.setRoleMappings(new ArrayList<>()); providerEntity.setScopes(Arrays.asList(IDP_SCOPE)); providerEntity.setUserProfileMapping(new HashMap<>()); IdentityProvider idp = identityProviderMapper.convert(providerEntity); checkIdp(idp, IdentityProviderType.GRAVITEEIO_AM); }
@Test public void testGithubProvider() { GitHubIdentityProviderEntity providerEntity = new GitHubIdentityProviderEntity(); providerEntity.setClientId(IDP_CLIENT_ID); providerEntity.setClientSecret(IDP_CLIENT_SECRET); providerEntity.setDescription(IDP_DESCRIPTION); providerEntity.setEmailRequired(IDP_EMAIL_REQUIRED); providerEntity.setGroupMappings(new ArrayList<>()); providerEntity.setId(IDP_ID); providerEntity.setName(IDP_NAME); providerEntity.setRoleMappings(new ArrayList<>()); IdentityProvider idp = identityProviderMapper.convert(providerEntity); checkIdp(idp, IdentityProviderType.GITHUB); }
@Test public void testGoogleProvider() { GoogleIdentityProviderEntity providerEntity = new GoogleIdentityProviderEntity(); providerEntity.setClientId(IDP_CLIENT_ID); providerEntity.setClientSecret(IDP_CLIENT_SECRET); providerEntity.setDescription(IDP_DESCRIPTION); providerEntity.setEmailRequired(IDP_EMAIL_REQUIRED); providerEntity.setGroupMappings(new ArrayList<>()); providerEntity.setId(IDP_ID); providerEntity.setName(IDP_NAME); providerEntity.setRoleMappings(new ArrayList<>()); IdentityProvider idp = identityProviderMapper.convert(providerEntity); checkIdp(idp, IdentityProviderType.GOOGLE); }
@Test public void testOIDCProvider() { OIDCIdentityProviderEntity providerEntity = new OIDCIdentityProviderEntity(); providerEntity.setAuthorizationEndpoint(IDP_AUTHORIZATION_ENDPOINT); providerEntity.setClientId(IDP_CLIENT_ID); providerEntity.setClientSecret(IDP_CLIENT_SECRET); providerEntity.setColor(IDP_COLOR); providerEntity.setDescription(IDP_DESCRIPTION); providerEntity.setDiscoveryEndpoint(IDP_DISCOVERY_ENDPOINT); providerEntity.setEmailRequired(IDP_EMAIL_REQUIRED); providerEntity.setGroupMappings(new ArrayList<>()); providerEntity.setId(IDP_ID); providerEntity.setName(IDP_NAME); providerEntity.setRoleMappings(new ArrayList<>()); providerEntity.setScopes(Arrays.asList(IDP_SCOPE)); providerEntity.setTokenEndpoint(IDP_TOKEN_ENDPOINT); providerEntity.setTokenIntrospectionEndpoint(IDP_TOKEN_INTROSPECTION_ENDPOINT); providerEntity.setUserInfoEndpoint(IDP_USER_INFO_ENDPOINT); providerEntity.setUserLogoutEndpoint(IDP_USER_LOGOUT_ENDPOINT); providerEntity.setUserProfileMapping(new HashMap<>()); IdentityProvider idp = identityProviderMapper.convert(providerEntity); checkIdp(idp, IdentityProviderType.OIDC); }