Search in sources :

Example 21 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method testGroupModeWithNonExistingPOGroupAndCurrentUserBelongsToAPoGroup.

@Test
public void testGroupModeWithNonExistingPOGroupAndCurrentUserBelongsToAPoGroup() {
    setPrimaryOwnerMode("GROUP");
    setPoGroupNonExisting();
    addUserInPOGroup(CURRENT_USER, CURRENT_USER_PO_GROUP);
    JsonNode definition = poGroupDefinition();
    final PrimaryOwnerEntity primaryOwner = apiService.findPrimaryOwner(definition, CURRENT_USER);
    assertEquals(CURRENT_USER_PO_GROUP, primaryOwner.getId());
    assertEquals("GROUP", primaryOwner.getType());
}
Also used : PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 22 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method testHybridModeWithNonExistingPOGroupAndCurrentUserDoesNotBelongToAPoGroup.

@Test
public void testHybridModeWithNonExistingPOGroupAndCurrentUserDoesNotBelongToAPoGroup() {
    setPrimaryOwnerMode("HYBRID");
    setPoGroupNonExisting();
    setCurrentUserInNoPOGroup();
    defineUser(CURRENT_USER);
    JsonNode definition = poGroupDefinition();
    final PrimaryOwnerEntity primaryOwner = apiService.findPrimaryOwner(definition, CURRENT_USER);
    assertEquals(CURRENT_USER, primaryOwner.getId());
    assertEquals("USER", primaryOwner.getType());
}
Also used : PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 23 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method testGroupModeWithExistingPOUserAndPoUserDoesNotBelongToAPoGroupAndCurrentUserBelongsToAPoGroup.

@Test
public void testGroupModeWithExistingPOUserAndPoUserDoesNotBelongToAPoGroupAndCurrentUserBelongsToAPoGroup() {
    setPrimaryOwnerMode("GROUP");
    defineUser(PO_USER_ID);
    setPoUserInNoPOGroup();
    addUserInPOGroup(CURRENT_USER, CURRENT_USER_PO_GROUP);
    JsonNode definition = poUserDefinition();
    final PrimaryOwnerEntity primaryOwner = apiService.findPrimaryOwner(definition, CURRENT_USER);
    assertEquals(CURRENT_USER_PO_GROUP, primaryOwner.getId());
    assertEquals("GROUP", primaryOwner.getType());
}
Also used : PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 24 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method testGroupModeWithExistingPOUserAndPoUserBelongsToAPoGroup.

// GROUP + import with PO User
@Test
public void testGroupModeWithExistingPOUserAndPoUserBelongsToAPoGroup() {
    setPrimaryOwnerMode("GROUP");
    defineUser(PO_USER_ID);
    addUserInPOGroup(PO_USER_ID, PO_GROUP_ID);
    JsonNode definition = poUserDefinition();
    final PrimaryOwnerEntity primaryOwner = apiService.findPrimaryOwner(definition, CURRENT_USER);
    assertEquals(PO_GROUP_ID, primaryOwner.getId());
    assertEquals("GROUP", primaryOwner.getType());
}
Also used : PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 25 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class MetadataServiceTest method checkMetadataFormat_badEmailFormat_EL.

@Test(expected = TechnicalManagementException.class)
public void checkMetadataFormat_badEmailFormat_EL() throws TemplateException {
    when(this.notificationTemplateService.resolveInlineTemplateWithParam(anyString(), any(Reader.class), any())).thenReturn("test");
    UserEntity userEntity = new UserEntity();
    userEntity.setEmail("test");
    PrimaryOwnerEntity primaryOwnerEntity = new PrimaryOwnerEntity(userEntity);
    ApiEntity apiEntity = new ApiEntity();
    apiEntity.setPrimaryOwner(primaryOwnerEntity);
    metadataService.checkMetadataFormat(MetadataFormat.MAIL, "${api.primaryOwner.email}", API, apiEntity);
}
Also used : PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) Reader(java.io.Reader) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) UserEntity(io.gravitee.rest.api.model.UserEntity) Test(org.junit.Test)

Aggregations

PrimaryOwnerEntity (io.gravitee.rest.api.model.PrimaryOwnerEntity)26 Test (org.junit.Test)23 JsonNode (com.fasterxml.jackson.databind.JsonNode)16 UserEntity (io.gravitee.rest.api.model.UserEntity)9 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)8 ApplicationEntity (io.gravitee.rest.api.model.ApplicationEntity)3 ApplicationListItem (io.gravitee.rest.api.model.application.ApplicationListItem)3 Assert (org.junit.Assert)3 Before (org.junit.Before)3 Mockito (org.mockito.Mockito)3 NOT_FOUND_404 (io.gravitee.common.http.HttpStatusCode.NOT_FOUND_404)2 OK_200 (io.gravitee.common.http.HttpStatusCode.OK_200)2 Proxy (io.gravitee.definition.model.Proxy)2 VirtualHost (io.gravitee.definition.model.VirtualHost)2 RatingSummaryEntity (io.gravitee.rest.api.model.RatingSummaryEntity)2 SubscriptionEntity (io.gravitee.rest.api.model.SubscriptionEntity)2 TopHitsAnalytics (io.gravitee.rest.api.model.analytics.TopHitsAnalytics)2 GroupByQuery (io.gravitee.rest.api.model.analytics.query.GroupByQuery)2 ApiEntrypointEntity (io.gravitee.rest.api.model.api.ApiEntrypointEntity)2 ApiQuery (io.gravitee.rest.api.model.api.ApiQuery)2