Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add fusion csrf cookie to correct path (#11852)
* fix: add fusion csrf cookie to correct path * code format
- Loading branch information
1 parent
204e5dc
commit 00226c1
Showing
12 changed files
with
454 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
# / | ||
frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-tests</artifactId> | ||
<version>9.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>test-fusion-csrf-context</artifactId> | ||
<name>Fusion CSRF tests with custom context path</name> | ||
<description> | ||
For https://github.com/vaadin/fusion/issues/105. | ||
It verifies that the csrf cookie is added to correct path | ||
when first open a sub view. | ||
Note, the test needs to be in a separate module because | ||
it needs to open a sub view first, put the test into another | ||
module cannot gurantee this. | ||
</description> | ||
<version>9.0-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
|
||
<properties> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- Project dependencies --> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>fusion-endpoint</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-dev-server</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>test-fusion-csrf</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>frontend</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>test-fusion-csrf</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>unpack</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>unpack</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>test-fusion-csrf</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>frontend</classifier> | ||
<outputDirectory>${project.basedir}/frontend</outputDirectory> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- This module is mapped to default web context --> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<configuration> | ||
<systemProperties> | ||
<systemProperty> | ||
<!-- make sure we do not leave webpack-dev-server running after IT --> | ||
<name>vaadin.reuseDevServer</name> | ||
<value>false</value> | ||
</systemProperty> | ||
</systemProperties> | ||
<webApp> | ||
<contextPath>/foo</contextPath> | ||
</webApp> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-maven-plugin</artifactId> | ||
<configuration> | ||
<productionMode>false</productionMode> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>local-run</id> | ||
<activation> | ||
<property> | ||
<name>!test.use.hub</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.lazerycode.selenium</groupId> | ||
<artifactId>driver-binary-downloader-maven-plugin | ||
</artifactId> | ||
<version> | ||
${driver.binary.downloader.maven.plugin.version} | ||
</version> | ||
<configuration> | ||
<onlyGetDriversForHostOperatingSystem>true | ||
</onlyGetDriversForHostOperatingSystem> | ||
<rootStandaloneServerDirectory> | ||
${project.rootdir}/driver | ||
</rootStandaloneServerDirectory> | ||
<downloadedZipFileDirectory> | ||
${project.rootdir}/driver_zips | ||
</downloadedZipFileDirectory> | ||
<customRepositoryMap> | ||
${project.rootdir}/drivers.xml | ||
</customRepositoryMap> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>selenium</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
10 changes: 10 additions & 0 deletions
10
flow-tests/test-fusion-csrf-context/src/main/java/com/vaadin/fusion/csrftest/MyServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.vaadin.fusion.csrftest; | ||
|
||
import javax.servlet.annotation.WebServlet; | ||
|
||
import com.vaadin.flow.server.VaadinServlet; | ||
|
||
@WebServlet("/*") | ||
public class MyServlet extends VaadinServlet { | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...c/test/java/com/vaadin/fusion/csrftest/CsrfCookieWithTrailingSlashAndCustomContextIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2000-2021 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.vaadin.fusion.csrftest; | ||
|
||
public class CsrfCookieWithTrailingSlashAndCustomContextIT | ||
extends CsrfCookieWithTrailingSlashIT { | ||
@Override | ||
protected String getContextPath() { | ||
return "/foo"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>fusion-csrf</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
} | ||
|
||
#outlet { | ||
height: 100%; | ||
} | ||
</style> | ||
<!-- index.ts is included here automatically (either by the dev server or during the build) --> | ||
</head> | ||
|
||
<body> | ||
<div id="outlet"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Router, Route } from '@vaadin/router'; | ||
import './views/helloworld/hello-world-view'; | ||
|
||
export const router = new Router(document.querySelector('#outlet')); | ||
|
||
export const routes: Route[] = [ | ||
// place routes below (more info https://vaadin.com/docs/latest/fusion/routing/overview) | ||
{ | ||
path: '', | ||
component: 'hello-world-view', | ||
}, | ||
{ | ||
path: 'hello', | ||
component: 'hello-world-view', | ||
} | ||
]; | ||
router.setRoutes(routes); |
11 changes: 11 additions & 0 deletions
11
flow-tests/test-fusion-csrf/frontend/views/helloworld/hello-world-view.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { html, LitElement } from 'lit'; | ||
import { customElement } from 'lit/decorators.js'; | ||
|
||
@customElement('hello-world-view') | ||
export class HelloWorldView extends LitElement { | ||
render() { | ||
return html` | ||
<div>HelloWorldView</div> | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-tests</artifactId> | ||
<version>9.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>test-fusion-csrf</artifactId> | ||
<name>Fusion CSRF tests (dev mode)</name> | ||
<description> | ||
For https://github.com/vaadin/fusion/issues/105. | ||
It verifies that the csrf cookie is added to correct path | ||
when first open a sub view. | ||
Note, the test needs to be in a separate module because | ||
it needs to open a sub view first, put the test into another | ||
module cannot gurantee this. | ||
</description> | ||
<version>9.0-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
|
||
<properties> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- Project dependencies --> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>fusion-endpoint</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-dev-server</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>package-frontend-folder</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<configuration> | ||
<classifier>frontend</classifier> | ||
<classesDirectory>${project.basedir}/frontend</classesDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- This module is mapped to default web context --> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<configuration> | ||
<systemProperties> | ||
<systemProperty> | ||
<!-- make sure we do not leave webpack-dev-server running after IT --> | ||
<name>vaadin.reuseDevServer</name> | ||
<value>false</value> | ||
</systemProperty> | ||
</systemProperties> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-maven-plugin</artifactId> | ||
<configuration> | ||
<productionMode>false</productionMode> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>local-run</id> | ||
<activation> | ||
<property> | ||
<name>!test.use.hub</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.lazerycode.selenium</groupId> | ||
<artifactId>driver-binary-downloader-maven-plugin | ||
</artifactId> | ||
<version> | ||
${driver.binary.downloader.maven.plugin.version} | ||
</version> | ||
<configuration> | ||
<onlyGetDriversForHostOperatingSystem>true | ||
</onlyGetDriversForHostOperatingSystem> | ||
<rootStandaloneServerDirectory> | ||
${project.rootdir}/driver | ||
</rootStandaloneServerDirectory> | ||
<downloadedZipFileDirectory> | ||
${project.rootdir}/driver_zips | ||
</downloadedZipFileDirectory> | ||
<customRepositoryMap> | ||
${project.rootdir}/drivers.xml | ||
</customRepositoryMap> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>selenium</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
Oops, something went wrong.