l10n->t('Code integrity'); } public function getCategory(): string { return 'security'; } public function run(): SetupResult { if (!$this->checker->isCodeCheckEnforced()) { return SetupResult::info($this->l10n->t('Integrity checker has been disabled. Integrity cannot be verified.')); } // If there are no results we need to run the verification if ($this->checker->getResults() === null) { $this->checker->runInstanceVerification(); } if ($this->checker->hasPassedCheck()) { return SetupResult::success($this->l10n->t('No altered files')); } else { return SetupResult::error( $this->l10n->t('Some files have not passed the integrity check. {link1} {link2}'), $this->urlGenerator->linkToDocs('admin-code-integrity'), [ 'link1' => [ 'type' => 'highlight', 'id' => 'getFailedIntegrityCheckFiles', 'name' => 'List of invalid files…', 'link' => $this->urlGenerator->linkToRoute('settings.CheckSetup.getFailedIntegrityCheckFiles'), ], 'link2' => [ 'type' => 'highlight', 'id' => 'rescanFailedIntegrityCheck', 'name' => 'Rescan…', 'link' => $this->urlGenerator->linkToRoute('settings.CheckSetup.rescanFailedIntegrityCheck'), ], ], ); } } } h-1 Vaadin 6, 7, 8 is a Java framework for modern Java web applications: https://github.com/vaadin/frameworkwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/applicationcontext/CloseSessionTest.java
blob: 1d6bf3f9bf3eff2e8e5ce2b20f19cf18456a6567 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.vaadin.tests.applicationcontext;

import org.junit.Assert;
import org.junit.Test;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.tests.tb3.newelements.FixedNotificationElement;

public class CloseSessionTest extends MultiBrowserTest {

    @Override
    public void setup() throws Exception {
        super.setup();
        openTestURL();
    }

    /**
     * Close, reload and assert there's a new VaadinServiceSession in the old
     * HttpSession.
     */
    @Test
    public void testCloseAndReopen() {
        clickButton("Close VaadinServiceSession and reopen page");
        assertLogText(2, "4. Same hash as current? false");
        assertLogText(0, "6. Same WrappedSession id? true");
    }

    /**
     * Invalidate, reload and assert there's a new VaadinServiceSession in a new
     * HttpSession.
     */
    @Test
    public void testInvalidateHttpSessionAndReopen() {
        clickButton("Invalidate HttpSession and reopen page");
        assertLogText(2, "4. Same hash as current? false");
        assertLogText(0, "6. Same WrappedSession id? false");
    }

    /**
     * Test closing session and redirecting to another page.
     */
    @Test
    public void testCloseVaadinServiceAndRedirect() {
        clickButton("Close VaadinServiceSession and redirect elsewhere");
        Assert.assertEquals("Unexpected page contents,",
                "This is a static file", findElement(By.xpath("//h1"))
                        .getText());
    }

    /**
     * Verify we get a Session Expired error if doing something after closing
     * the VaadinSession.
     */
    @Test
    public void testCloseVaadinSession() {
        String caption = "Just close VaadinSession";
        clickButton(caption);
        clickButton(caption);
        assertSessionExpired();
    }

    /**
     * Verify we get a Session Expired error if doing something after closing
     * the HttpSession.
     */
    @Test
    public void testCloseHttpSession() {
        String caption = "Just close HttpSession";
        clickButton(caption);
        clickButton(caption);
        assertSessionExpired();
    }

    /**
     * Verify we get a Session Expired error if closing HttpSession in a
     * background thread.
     */
    @Test
    public void testBackgroundThreadHttpSessionInvalidation()
            throws InterruptedException {
        String caption = "Invalidate HttpSession in a background thread";
        clickButton(caption);
        sleep(2000);
        clickButton(caption);
        assertSessionExpired();
    }

    private void assertLogText(int index, String expected) {
        Assert.assertEquals("Unexpected log text,", expected, getLogRow(index));
    }

    private void assertSessionExpired() {
        String expected = "Session Expired";
        String actual = $(FixedNotificationElement.class).first().getCaption();
        Assert.assertEquals("Unexpected notification,", actual, expected);
    }

    public void clickButton(String caption) {
        $(ButtonElement.class).caption(caption).first().click();
    }
}