Search in sources :

Example 1 with Entrypoint

use of io.gravitee.am.model.Entrypoint in project gravitee-access-management by gravitee-io.

the class EntrypointServiceTest method shouldNotUpdate_notExistingEntrypoint.

@Test
public void shouldNotUpdate_notExistingEntrypoint() {
    DefaultUser user = new DefaultUser("test");
    user.setId(USER_ID);
    when(entrypointRepository.findById(ENTRYPOINT_ID, ORGANIZATION_ID)).thenReturn(Maybe.empty());
    TestObserver<Entrypoint> obs = cut.update(ENTRYPOINT_ID, ORGANIZATION_ID, new UpdateEntrypoint(), user).test();
    obs.awaitTerminalEvent();
    obs.assertError(EntrypointNotFoundException.class);
    verify(auditService, times(0)).report(any());
}
Also used : DefaultUser(io.gravitee.am.identityprovider.api.DefaultUser) UpdateEntrypoint(io.gravitee.am.service.model.UpdateEntrypoint) Entrypoint(io.gravitee.am.model.Entrypoint) NewEntrypoint(io.gravitee.am.service.model.NewEntrypoint) UpdateEntrypoint(io.gravitee.am.service.model.UpdateEntrypoint) Test(org.junit.Test)

Example 2 with Entrypoint

use of io.gravitee.am.model.Entrypoint in project gravitee-access-management by gravitee-io.

the class EntrypointResourceTest method shouldUpdateEntrypoint.

@Test
public void shouldUpdateEntrypoint() {
    UpdateEntrypoint updateEntrypoint = new UpdateEntrypoint();
    updateEntrypoint.setName("name");
    updateEntrypoint.setUrl("https://auth.company.com");
    updateEntrypoint.setTags(Collections.emptyList());
    final Entrypoint mockEntrypoint = new Entrypoint();
    mockEntrypoint.setId(ENTRYPOINT_ID);
    mockEntrypoint.setOrganizationId(ORGANIZATION_ID);
    mockEntrypoint.setName("name");
    doReturn(Single.just(mockEntrypoint)).when(entrypointService).update(eq(ENTRYPOINT_ID), eq(ORGANIZATION_ID), any(UpdateEntrypoint.class), any(User.class));
    final Response response = put(target("organizations").path(ORGANIZATION_ID).path("entrypoints").path(ENTRYPOINT_ID), updateEntrypoint);
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    final Entrypoint entrypoint = readEntity(response, Entrypoint.class);
    assertEquals(mockEntrypoint.getId(), entrypoint.getId());
    assertEquals(mockEntrypoint.getOrganizationId(), entrypoint.getOrganizationId());
    assertEquals(mockEntrypoint.getName(), entrypoint.getName());
}
Also used : Response(javax.ws.rs.core.Response) User(io.gravitee.am.identityprovider.api.User) UpdateEntrypoint(io.gravitee.am.service.model.UpdateEntrypoint) Entrypoint(io.gravitee.am.model.Entrypoint) UpdateEntrypoint(io.gravitee.am.service.model.UpdateEntrypoint) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 3 with Entrypoint

use of io.gravitee.am.model.Entrypoint in project gravitee-access-management by gravitee-io.

the class EntrypointResourceTest method shouldGetEntrypoint.

@Test
public void shouldGetEntrypoint() {
    final Entrypoint mockEntrypoint = new Entrypoint();
    mockEntrypoint.setId(ENTRYPOINT_ID);
    mockEntrypoint.setOrganizationId(ORGANIZATION_ID);
    mockEntrypoint.setName("name");
    mockEntrypoint.setDescription("description");
    mockEntrypoint.setOrganizationId(ORGANIZATION_ID);
    mockEntrypoint.setTags(Arrays.asList("tag#1", "tag#2"));
    mockEntrypoint.setCreatedAt(new Date());
    mockEntrypoint.setUpdatedAt(new Date());
    doReturn(Single.just(mockEntrypoint)).when(entrypointService).findById(ENTRYPOINT_ID, ORGANIZATION_ID);
    final Response response = target("organizations").path(ORGANIZATION_ID).path("entrypoints").path(ENTRYPOINT_ID).request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    final Entrypoint entrypoint = readEntity(response, Entrypoint.class);
    assertEquals(mockEntrypoint.getId(), entrypoint.getId());
    assertEquals(mockEntrypoint.getOrganizationId(), entrypoint.getOrganizationId());
    assertEquals(mockEntrypoint.getName(), entrypoint.getName());
    assertEquals(mockEntrypoint.getDescription(), entrypoint.getDescription());
    assertEquals(mockEntrypoint.getUrl(), entrypoint.getUrl());
    assertEquals(mockEntrypoint.getTags(), entrypoint.getTags());
    assertEquals(mockEntrypoint.getCreatedAt(), entrypoint.getCreatedAt());
    assertEquals(mockEntrypoint.getUpdatedAt(), entrypoint.getUpdatedAt());
}
Also used : Response(javax.ws.rs.core.Response) UpdateEntrypoint(io.gravitee.am.service.model.UpdateEntrypoint) Entrypoint(io.gravitee.am.model.Entrypoint) Date(java.util.Date) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 4 with Entrypoint

use of io.gravitee.am.model.Entrypoint in project gravitee-access-management by gravitee-io.

the class EntrypointsResourceTest method shouldGetEntrypoints.

@Test
public void shouldGetEntrypoints() {
    final Entrypoint entrypoint = new Entrypoint();
    entrypoint.setId(ENTRYPOINT_ID);
    entrypoint.setName("entrypoint-1-name");
    entrypoint.setOrganizationId(ORGANIZATION_ID);
    final Entrypoint entrypoint2 = new Entrypoint();
    entrypoint2.setId("entrypoint#2");
    entrypoint2.setName("entrypoint-2-name");
    entrypoint2.setOrganizationId(ORGANIZATION_ID);
    doReturn(Flowable.just(entrypoint, entrypoint2)).when(entrypointService).findAll(ORGANIZATION_ID);
    final Response response = target("organizations").path(ORGANIZATION_ID).path("entrypoints").request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    final List<Entrypoint> responseEntity = readEntity(response, List.class);
    assertEquals(2, responseEntity.size());
}
Also used : Response(javax.ws.rs.core.Response) Entrypoint(io.gravitee.am.model.Entrypoint) NewEntrypoint(io.gravitee.am.service.model.NewEntrypoint) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 5 with Entrypoint

use of io.gravitee.am.model.Entrypoint in project gravitee-access-management by gravitee-io.

the class EntrypointsResourceTest method shouldCreate.

@Test
public void shouldCreate() {
    NewEntrypoint newEntrypoint = new NewEntrypoint();
    newEntrypoint.setName("name");
    newEntrypoint.setUrl("https://auth.company.com");
    newEntrypoint.setTags(Collections.emptyList());
    Entrypoint entrypoint = new Entrypoint();
    entrypoint.setId("entrypoint-1");
    entrypoint.setName("name");
    doReturn(Single.just(entrypoint)).when(entrypointService).create(eq(ORGANIZATION_ID), any(NewEntrypoint.class), any(User.class));
    WebTarget path = target("organizations").path(ORGANIZATION_ID).path("entrypoints");
    final Response response = post(path, newEntrypoint);
    assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
    assertEquals(path.getUri().toString() + "/" + entrypoint.getId(), response.getHeaderString(HttpHeaders.LOCATION));
}
Also used : Response(javax.ws.rs.core.Response) User(io.gravitee.am.identityprovider.api.User) Entrypoint(io.gravitee.am.model.Entrypoint) NewEntrypoint(io.gravitee.am.service.model.NewEntrypoint) NewEntrypoint(io.gravitee.am.service.model.NewEntrypoint) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Aggregations

Entrypoint (io.gravitee.am.model.Entrypoint)32 Test (org.junit.Test)23 NewEntrypoint (io.gravitee.am.service.model.NewEntrypoint)18 UpdateEntrypoint (io.gravitee.am.service.model.UpdateEntrypoint)17 Single (io.reactivex.Single)13 DefaultUser (io.gravitee.am.identityprovider.api.DefaultUser)12 Completable (io.reactivex.Completable)12 List (java.util.List)12 EventType (io.gravitee.am.common.audit.EventType)10 Organization (io.gravitee.am.model.Organization)10 EntrypointRepository (io.gravitee.am.repository.management.api.EntrypointRepository)10 Maybe (io.reactivex.Maybe)10 Collections (java.util.Collections)10 TestObserver (io.reactivex.observers.TestObserver)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 ReferenceType (io.gravitee.am.model.ReferenceType)8 Audit (io.gravitee.am.reporter.api.audit.model.Audit)8 TechnicalException (io.gravitee.am.repository.exceptions.TechnicalException)8 EntrypointNotFoundException (io.gravitee.am.service.exception.EntrypointNotFoundException)8 InvalidEntrypointException (io.gravitee.am.service.exception.InvalidEntrypointException)8