Search in sources :

Example 6 with PortalSettingsEntity

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

the class ConfigServiceTest method shouldGetPortalSettings.

@Test
public void shouldGetPortalSettings() {
    Map<String, List<String>> params = new HashMap<>();
    params.put(Key.PORTAL_AUTHENTICATION_FORCELOGIN_ENABLED.key(), singletonList("true"));
    params.put(Key.PORTAL_SCHEDULER_NOTIFICATIONS.key(), singletonList("11"));
    params.put(Key.PORTAL_ANALYTICS_ENABLED.key(), singletonList("true"));
    params.put(Key.OPEN_API_DOC_TYPE_SWAGGER_ENABLED.key(), singletonList("true"));
    params.put(Key.API_LABELS_DICTIONARY.key(), Arrays.asList("label1", "label2"));
    when(mockParameterService.findAll(any(List.class), any(Function.class), eq("DEFAULT"), eq(ParameterReferenceType.ENVIRONMENT))).thenReturn(params);
    when(reCaptchaService.getSiteKey()).thenReturn("my-site-key");
    when(reCaptchaService.isEnabled()).thenReturn(true);
    PortalSettingsEntity portalSettings = configService.getPortalSettings();
    assertNotNull(portalSettings);
    assertEquals("force login", true, portalSettings.getAuthentication().getForceLogin().isEnabled());
    assertEquals("scheduler notifications", Integer.valueOf(11), portalSettings.getScheduler().getNotificationsInSeconds());
    assertEquals("analytics", Boolean.TRUE, portalSettings.getPortal().getAnalytics().isEnabled());
    assertEquals("recaptcha siteKey", "my-site-key", portalSettings.getReCaptcha().getSiteKey());
    assertEquals("recaptcha enabled", Boolean.TRUE, portalSettings.getReCaptcha().getEnabled());
    assertEquals("plan security keyless", Boolean.TRUE, portalSettings.getPlan().getSecurity().getKeyless().isEnabled());
    assertEquals("open api swagger enabled", Boolean.TRUE, portalSettings.getOpenAPIDocViewer().getOpenAPIDocType().getSwagger().isEnabled());
    assertEquals("open api swagger default", "Swagger", portalSettings.getOpenAPIDocViewer().getOpenAPIDocType().getDefaultType());
    assertEquals("api labels", 2, portalSettings.getApi().getLabelsDictionary().size());
    assertEquals("cors exposed headers", 2, portalSettings.getCors().getExposedHeaders().size());
}
Also used : PortalSettingsEntity(io.gravitee.rest.api.model.settings.PortalSettingsEntity) Function(java.util.function.Function) HashMap(java.util.HashMap) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) Test(org.junit.Test)

Aggregations

PortalSettingsEntity (io.gravitee.rest.api.model.settings.PortalSettingsEntity)6 Test (org.junit.Test)6 ConsoleSettingsEntity (io.gravitee.rest.api.model.settings.ConsoleSettingsEntity)2 Collections.singletonList (java.util.Collections.singletonList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Function (java.util.function.Function)2 Response (javax.ws.rs.core.Response)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Parameter (io.gravitee.repository.management.model.Parameter)1 IdentityProviderActivationEntity (io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity)1 ConfigurationIdentitiesResponse (io.gravitee.rest.api.portal.rest.model.ConfigurationIdentitiesResponse)1 ConfigurationResponse (io.gravitee.rest.api.portal.rest.model.ConfigurationResponse)1