Search in sources :

Example 1 with ApplicationGrantTypeEntity

use of io.gravitee.rest.api.model.configuration.application.ApplicationGrantTypeEntity in project gravitee-management-rest-api by gravitee-io.

the class ApplicationService_CreateTest method shouldNotCreateBecauseRedirectURIsNotFound.

@Test(expected = ApplicationRedirectUrisNotFound.class)
public void shouldNotCreateBecauseRedirectURIsNotFound() {
    ApplicationSettings settings = new ApplicationSettings();
    OAuthClientSettings clientSettings = new OAuthClientSettings();
    clientSettings.setApplicationType("web");
    clientSettings.setGrantTypes(Arrays.asList("foobar"));
    settings.setoAuthClient(clientSettings);
    ApplicationTypeEntity applicationType = mock(ApplicationTypeEntity.class);
    ApplicationGrantTypeEntity foobar = new ApplicationGrantTypeEntity();
    foobar.setType("foobar");
    when(applicationType.getRequires_redirect_uris()).thenReturn(true);
    when(applicationType.getAllowed_grant_types()).thenReturn(Arrays.asList(foobar));
    when(applicationTypeService.getApplicationType(any())).thenReturn(applicationType);
    when(newApplication.getSettings()).thenReturn(settings);
    when(parameterService.findAsBoolean(Key.APPLICATION_REGISTRATION_ENABLED, "DEFAULT", ParameterReferenceType.ENVIRONMENT)).thenReturn(Boolean.TRUE);
    when(parameterService.findAsBoolean(Key.APPLICATION_TYPE_WEB_ENABLED, "DEFAULT", ParameterReferenceType.ENVIRONMENT)).thenReturn(Boolean.TRUE);
    applicationService.create(newApplication, USER_NAME);
}
Also used : ApplicationSettings(io.gravitee.rest.api.model.application.ApplicationSettings) SimpleApplicationSettings(io.gravitee.rest.api.model.application.SimpleApplicationSettings) OAuthClientSettings(io.gravitee.rest.api.model.application.OAuthClientSettings) ApplicationTypeEntity(io.gravitee.rest.api.model.configuration.application.ApplicationTypeEntity) ApplicationGrantTypeEntity(io.gravitee.rest.api.model.configuration.application.ApplicationGrantTypeEntity) Test(org.junit.Test)

Example 2 with ApplicationGrantTypeEntity

use of io.gravitee.rest.api.model.configuration.application.ApplicationGrantTypeEntity in project gravitee-management-rest-api by gravitee-io.

the class ConfigurationResourceTest method shouldGetApplicationTypes.

@Test
public void shouldGetApplicationTypes() throws TechnicalException {
    resetAllMocks();
    ApplicationTypesEntity typesEntity = new ApplicationTypesEntity();
    List<ApplicationTypeEntity> data = new ArrayList<>();
    ApplicationTypeEntity simple = new ApplicationTypeEntity();
    simple.setId("simple");
    simple.setAllowed_grant_types(new ArrayList<>());
    simple.setDefault_grant_types(new ArrayList<>());
    simple.setMandatory_grant_types(new ArrayList<>());
    simple.setName("Simple");
    simple.setDescription("Simple type");
    data.add(simple);
    ApplicationTypeEntity web = new ApplicationTypeEntity();
    web.setId("web");
    List<ApplicationGrantTypeEntity> grantTypes = new ArrayList<>();
    ApplicationGrantTypeEntity grantType = new ApplicationGrantTypeEntity();
    grantType.setName("name");
    List<String> responses_types = new ArrayList<>();
    responses_types.add("token");
    grantType.setResponse_types(responses_types);
    grantTypes.add(grantType);
    web.setAllowed_grant_types(grantTypes);
    web.setDefault_grant_types(new ArrayList<>());
    web.setMandatory_grant_types(new ArrayList<>());
    web.setName("Web");
    web.setDescription("Web type");
    data.add(web);
    typesEntity.setData(data);
    when(applicationTypeService.getEnabledApplicationTypes()).thenReturn(typesEntity);
    final Response response = target().path("applications").path("types").request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    final ConfigurationApplicationTypesResponse appTypes = response.readEntity(ConfigurationApplicationTypesResponse.class);
    assertNotNull(appTypes);
    @Valid List<ApplicationType> types = appTypes.getData();
    assertNotNull(types);
    assertEquals(2, types.size());
    assertEquals("web", types.get(1).getId());
    assertEquals(1, types.get(1).getAllowedGrantTypes().size());
}
Also used : ApplicationTypeEntity(io.gravitee.rest.api.model.configuration.application.ApplicationTypeEntity) ApplicationGrantTypeEntity(io.gravitee.rest.api.model.configuration.application.ApplicationGrantTypeEntity) Response(javax.ws.rs.core.Response) Valid(javax.validation.Valid) ApplicationTypesEntity(io.gravitee.rest.api.model.configuration.application.ApplicationTypesEntity) Test(org.junit.Test)

Aggregations

ApplicationGrantTypeEntity (io.gravitee.rest.api.model.configuration.application.ApplicationGrantTypeEntity)2 ApplicationTypeEntity (io.gravitee.rest.api.model.configuration.application.ApplicationTypeEntity)2 Test (org.junit.Test)2 ApplicationSettings (io.gravitee.rest.api.model.application.ApplicationSettings)1 OAuthClientSettings (io.gravitee.rest.api.model.application.OAuthClientSettings)1 SimpleApplicationSettings (io.gravitee.rest.api.model.application.SimpleApplicationSettings)1 ApplicationTypesEntity (io.gravitee.rest.api.model.configuration.application.ApplicationTypesEntity)1 Valid (javax.validation.Valid)1 Response (javax.ws.rs.core.Response)1