Search in sources :

Example 6 with IdentityProviderActivationEntity

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());
}
Also used : PortalSettingsEntity(io.gravitee.rest.api.model.settings.PortalSettingsEntity) ConfigurationIdentitiesResponse(io.gravitee.rest.api.portal.rest.model.ConfigurationIdentitiesResponse) Response(javax.ws.rs.core.Response) IdentityProviderActivationEntity(io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity) ConfigurationIdentitiesResponse(io.gravitee.rest.api.portal.rest.model.ConfigurationIdentitiesResponse) Test(org.junit.Test)

Example 7 with IdentityProviderActivationEntity

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;
}
Also used : IdentityProviderActivationEntity(io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity)

Example 8 with 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);
}
Also used : IdentityProviderActivation(io.gravitee.repository.management.model.IdentityProviderActivation) ActivationTarget(io.gravitee.rest.api.service.configuration.identity.IdentityProviderActivationService.ActivationTarget) IdentityProviderActivationEntity(io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity) Date(java.util.Date) Test(org.junit.Test)

Aggregations

IdentityProviderActivationEntity (io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity)8 IdentityProviderActivation (io.gravitee.repository.management.model.IdentityProviderActivation)6 Test (org.junit.Test)5 Date (java.util.Date)4 ActivationTarget (io.gravitee.rest.api.service.configuration.identity.IdentityProviderActivationService.ActivationTarget)3 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)2 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)2 PortalSettingsEntity (io.gravitee.rest.api.model.settings.PortalSettingsEntity)1 ConfigurationIdentitiesResponse (io.gravitee.rest.api.portal.rest.model.ConfigurationIdentitiesResponse)1 Response (javax.ws.rs.core.Response)1