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());
}
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());
}
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());
}
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());
}
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));
}
Aggregations