use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class WebComponentWrapperTest method constructWebComponentUI.
private static WebComponentUI constructWebComponentUI(Element wrapperElement) {
WebComponentUI ui = mock(WebComponentUI.class);
when(ui.getUI()).thenReturn(Optional.of(ui));
Element body = new Element("body");
when(ui.getElement()).thenReturn(body);
UIInternals internals = new UIInternals(ui);
internals.setSession(new AlwaysLockedVaadinSession(mock(VaadinService.class)));
when(ui.getInternals()).thenReturn(internals);
Component parent = new Parent();
parent.getElement().appendVirtualChild(wrapperElement);
VaadinSession session = mock(VaadinSession.class);
DeploymentConfiguration configuration = mock(DeploymentConfiguration.class);
when(ui.getSession()).thenReturn(session);
when(session.getConfiguration()).thenReturn(configuration);
when(configuration.getWebComponentDisconnect()).thenReturn(1);
return ui;
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class UIInternalsTest method setUpInitialPush.
private PushConfiguration setUpInitialPush() {
DeploymentConfiguration config = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(vaadinService.getDeploymentConfiguration()).thenReturn(config);
PushConfiguration pushConfig = Mockito.mock(PushConfiguration.class);
Mockito.when(ui.getPushConfiguration()).thenReturn(pushConfig);
Mockito.when(config.getPushMode()).thenReturn(PushMode.DISABLED);
return pushConfig;
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class UIInternalsTest method showRouteTarget_componentHasNoPush_pushIsDisabled.
@Test
public void showRouteTarget_componentHasNoPush_pushIsDisabled() {
PushConfiguration pushConfig = setUpInitialPush();
useV14Bootstrap();
DeploymentConfiguration deploymentConfiguration = vaadinService.getDeploymentConfiguration();
Mockito.when(deploymentConfiguration.getPushMode()).thenReturn(PushMode.AUTOMATIC);
internals.showRouteTarget(Mockito.mock(Location.class), new Text(""), Collections.emptyList());
Mockito.verify(pushConfig).setPushMode(PushMode.AUTOMATIC);
Mockito.verify(pushConfig, Mockito.times(0)).setTransport(Mockito.any());
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class InfoView method update.
private void update(UI ui) {
VaadinSession session = ui.getSession();
WebBrowser webBrowser = session.getBrowser();
DeploymentConfiguration deploymentConfiguration = session.getConfiguration();
List<String> device = new ArrayList<>();
List<String> os = new ArrayList<>();
List<String> browser = new ArrayList<>();
removeAll();
add(new NativeButton("Refresh", e -> {
update(ui);
}));
header("Browser");
info("Address", webBrowser.getAddress());
add(device, "Android", webBrowser.isAndroid());
add(device, "iPhone", webBrowser.isIPhone());
add(device, "Windows Phone", webBrowser.isWindowsPhone());
info("Device", device.stream().collect(Collectors.joining(", ")));
add(os, "Linux", webBrowser.isLinux());
add(os, "Mac", webBrowser.isMacOSX());
add(os, "Windows", webBrowser.isWindows());
info("Os", os.stream().collect(Collectors.joining(", ")));
add(browser, "Chrome", webBrowser.isChrome());
add(browser, "Edge", webBrowser.isEdge());
add(browser, "Firefox", webBrowser.isFirefox());
add(browser, "IE", webBrowser.isIE());
add(browser, "Safari", webBrowser.isSafari());
info("Browser", browser.stream().collect(Collectors.joining(", ")));
if (webBrowser.isTooOldToFunctionProperly()) {
header("Browser is too old to function properly");
}
info("User-agent", webBrowser.getBrowserApplication());
info("Browser major", webBrowser.getBrowserMajorVersion());
info("Browser minor", webBrowser.getBrowserMinorVersion());
info("Locale", webBrowser.getLocale());
info("Secure connection (https)", webBrowser.isSecureConnection());
separator();
header("Push configuration");
info("Push mode", ui.getPushConfiguration().getPushMode());
info("Push transport", ui.getPushConfiguration().getTransport());
separator();
header("Deployment configuration");
info("Heartbeat interval", deploymentConfiguration.getHeartbeatInterval());
info("UI class", deploymentConfiguration.getUIClassName());
info("Close idle sessions", deploymentConfiguration.isCloseIdleSessions());
info("Send URLs as parameters", deploymentConfiguration.isSendUrlsAsParameters());
info("Sync id enabled", deploymentConfiguration.isSyncIdCheckEnabled());
info("XSRF protection enabled", deploymentConfiguration.isXsrfProtectionEnabled());
info("Production mode", deploymentConfiguration.isProductionMode());
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class EndpointAccessCheckerTest method should_notShowHelpfulMessage_When_accessDeniedInProductionMode.
@Test
public void should_notShowHelpfulMessage_When_accessDeniedInProductionMode() throws Exception {
VaadinService mockService = Mockito.mock(VaadinService.class);
DeploymentConfiguration mockDeploymentConfiguration = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(mockService.getDeploymentConfiguration()).thenReturn(mockDeploymentConfiguration);
Mockito.when(mockDeploymentConfiguration.isProductionMode()).thenReturn(true);
CurrentInstance.set(VaadinService.class, mockService);
try {
class Test {
public void test() {
}
}
Method method = Test.class.getMethod("test");
String accessDeniedMessage = checker.check(method, requestMock);
assertEquals(EndpointAccessChecker.ACCESS_DENIED_MSG, accessDeniedMessage);
} finally {
CurrentInstance.clearAll();
}
}
Aggregations