use of io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity in project gravitee-management-rest-api by gravitee-io.
the class ConfigurationIdentitiesResourceTest method shouldGetConfigurationIdentities.
@Test
public void shouldGetConfigurationIdentities() {
resetAllMocks();
IdentityProviderActivationEntity activatedIdp = new IdentityProviderActivationEntity();
activatedIdp.setIdentityProvider(IDP_ID);
doReturn(Sets.newSet(activatedIdp)).when(identityProviderActivationService).findAllByTarget(any());
doReturn(Sets.newSet(mockAMIdentityProviderEntity(), mockGoogleIdentityProviderEntity(), mockGitHubIdentityProviderEntity(), mockOIDCIdentityProviderEntity())).when(socialIdentityProviderService).findAll(any());
PortalSettingsEntity configEntity = new PortalSettingsEntity();
doReturn(configEntity).when(configService).getPortalSettings();
final Response response = target().request().get();
assertEquals(HttpStatusCode.OK_200, response.getStatus());
verify(identityProviderMapper, times(4)).convert(any());
verify(socialIdentityProviderService).findAll(any());
ConfigurationIdentitiesResponse configurationIdentitiesResponse = response.readEntity(ConfigurationIdentitiesResponse.class);
assertEquals(4, configurationIdentitiesResponse.getData().size());
}
use of io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity in project gravitee-management-rest-api by gravitee-io.
the class IdentityProviderActivationServiceImpl method convert.
private IdentityProviderActivationEntity convert(IdentityProviderActivation identityProviderActivation) {
IdentityProviderActivationEntity identityProviderActivationEntity = new IdentityProviderActivationEntity();
identityProviderActivationEntity.setIdentityProvider(identityProviderActivation.getIdentityProviderId());
identityProviderActivationEntity.setReferenceId(identityProviderActivation.getReferenceId());
identityProviderActivationEntity.setReferenceType(convert(identityProviderActivation.getReferenceType()));
identityProviderActivationEntity.setCreatedAt(identityProviderActivation.getCreatedAt());
return identityProviderActivationEntity;
}
use of io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity in project gravitee-management-rest-api by gravitee-io.
the class IdentityProviderActivationServiceTest method shouldFindAllByTarget.
@Test
public void shouldFindAllByTarget() throws TechnicalException {
// Given
final Date now = new Date();
IdentityProviderActivation ipa = new IdentityProviderActivation();
ipa.setIdentityProviderId(IDENTITY_PROVIDER_ID);
ipa.setReferenceId(TARGET_REFERENCE_ID);
ipa.setReferenceType(TARGET_REFERENCE_TYPE);
ipa.setCreatedAt(now);
IdentityProviderActivation anotherIpa = new IdentityProviderActivation();
anotherIpa.setIdentityProviderId(ANOTHER_IDENTITY_PROVIDER_ID);
anotherIpa.setReferenceId(TARGET_REFERENCE_ID);
anotherIpa.setReferenceType(TARGET_REFERENCE_TYPE);
anotherIpa.setCreatedAt(now);
doReturn(newSet(ipa, anotherIpa)).when(identityProviderActivationRepository).findAllByReferenceIdAndReferenceType(TARGET_REFERENCE_ID, TARGET_REFERENCE_TYPE);
// When
Set<IdentityProviderActivationEntity> foundIdentityProviders = this.identityProviderActivationService.findAllByTarget(new ActivationTarget(TARGET_REFERENCE_ID, io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationReferenceType.valueOf(TARGET_REFERENCE_TYPE.name())));
// Then
assertNotNull(foundIdentityProviders);
assertEquals(2, foundIdentityProviders.size());
verify(identityProviderActivationRepository).findAllByReferenceIdAndReferenceType(TARGET_REFERENCE_ID, TARGET_REFERENCE_TYPE);
}
Aggregations