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