Skip to content

Commit 4b2011e

Browse files
committed
feat: add integration test for jakarta JSP
1 parent 0f12ad6 commit 4b2011e

File tree

23 files changed

+575
-95
lines changed

23 files changed

+575
-95
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ jobs:
2121
distribution: 'temurin'
2222
- name: Run build
2323
run: |
24-
mvn install
24+
mvn install -PtestJakarta
2525
2626

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ nb-configuration.xml
1919
/esapi/target/
2020
/target/
2121
/jakarta/target/
22+
/jakarta-test/target/

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,26 @@ Java 9+ Module Names
7878
| encoder-jsp | owasp.encoder.jsp |
7979
| encoder-espai | owasp.encoder.esapi |
8080

81+
82+
TagLib
83+
--------------------
84+
85+
| Lib | TagLib |
86+
|---------------------|-----------------------------------------------------------------------------------------------|
87+
| encoder-jakarta-jsp | <%@taglib prefix="e" uri="owasp.encoder.jakarta"%> |
88+
| encoder-jsp | <%@taglib prefix="e" uri="https://www.owasp.org/index.php/OWASP_Java_Encoder_Project"%> |
89+
90+
8191
News
8292
----
83-
### 2024-08-01 - 1.2.3 Release
93+
### 2024-08-02 - 1.3.0 Release
8494
The team is happy to announce that version 1.3.0 has been released!
85-
* Minimum JDK Requirement are now Java 8
95+
* Minimum JDK Requirement is now Java 8
8696
- Requires Java 17 to build due to test case dependencies.
8797
* Adds Java 9 Module name via Multi-Release Jars (#77).
8898
* Fixed compilation errors with the ESAPI Thunk (#76).
8999
* Adds support for Servlet Spec 5 using the `jakarta.servlet.*` (#75).
100+
- taglib : <%@taglib prefix="e" uri="owasp.encoder.jakarta"%>
90101

91102
### 2020-11-08 - 1.2.3 Release
92103
The team is happy to announce that version 1.2.3 has been released!

jakarta-test/pom.xml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>3.3.2</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>org.owasp.encoder.testing</groupId>
12+
<artifactId>jakarta-test</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<packaging>war</packaging>
15+
<name>jakarta-test</name>
16+
<description>Test for OWASP encoder jakarta JSP</description>
17+
<properties>
18+
<java.version>17</java.version>
19+
</properties>
20+
<dependencies>
21+
<dependency>
22+
<groupId>org.owasp.encoder</groupId>
23+
<artifactId>encoder-jakarta-jsp</artifactId>
24+
<version>1.3.0</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-web</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.apache.tomcat.embed</groupId>
32+
<artifactId>tomcat-embed-jasper</artifactId>
33+
<version>10.1.18</version>
34+
<scope>provided</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-tomcat</artifactId>
39+
<version>3.2.2</version>
40+
<scope>provided</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>jakarta.servlet</groupId>
44+
<artifactId>jakarta.servlet-api</artifactId>
45+
<version>6.0.0</version>
46+
<scope>provided</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>jakarta.servlet.jsp</groupId>
50+
<artifactId>jakarta.servlet.jsp-api</artifactId>
51+
<version>3.1.0</version>
52+
<scope>provided</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>jakarta.servlet.jsp.jstl</groupId>
56+
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
57+
<version>3.0.0</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>jakarta.el</groupId>
61+
<artifactId>jakarta.el-api</artifactId>
62+
<version>5.0.1</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.glassfish.web</groupId>
66+
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
67+
<version>3.0.1</version>
68+
</dependency>
69+
70+
<dependency>
71+
<groupId>org.springframework.boot</groupId>
72+
<artifactId>spring-boot-starter-test</artifactId>
73+
<scope>test</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-testcontainers</artifactId>
78+
<scope>test</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.testcontainers</groupId>
82+
<artifactId>selenium</artifactId>
83+
<version>1.20.0</version>
84+
<scope>test</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.seleniumhq.selenium</groupId>
88+
<artifactId>selenium-remote-driver</artifactId>
89+
<version>4.23.0</version>
90+
<scope>test</scope>
91+
</dependency>
92+
<dependency>
93+
<groupId>org.seleniumhq.selenium</groupId>
94+
<artifactId>selenium-chrome-driver</artifactId>
95+
<version>4.23.0</version>
96+
<scope>test</scope>
97+
</dependency>
98+
<dependency>
99+
<groupId>org.testcontainers</groupId>
100+
<artifactId>junit-jupiter</artifactId>
101+
<version>1.20.0</version>
102+
<scope>test</scope>
103+
</dependency>
104+
</dependencies>
105+
106+
<build>
107+
<finalName>jakarta-test</finalName>
108+
<plugins>
109+
<plugin>
110+
<groupId>org.springframework.boot</groupId>
111+
<artifactId>spring-boot-maven-plugin</artifactId>
112+
<configuration>
113+
<mainClass>org.owasp.encoder.testing.jakarta_test.JakartaTestApplication</mainClass>
114+
</configuration>
115+
<executions>
116+
<execution>
117+
<goals>
118+
<goal>repackage</goal>
119+
</goals>
120+
</execution>
121+
</executions>
122+
</plugin>
123+
</plugins>
124+
</build>
125+
126+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.owasp.encoder.testing.jakarta_test;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.builder.SpringApplicationBuilder;
6+
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
7+
8+
@SpringBootApplication(scanBasePackages = "org.owasp.encoder.testing.jakarta_test")
9+
public class JakartaTestApplication extends SpringBootServletInitializer {
10+
11+
@Override
12+
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
13+
return builder.sources(JakartaTestApplication.class);
14+
}
15+
16+
public static void main(String[] args) {
17+
SpringApplication.run(JakartaTestApplication.class, args);
18+
}
19+
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.owasp.encoder.testing.jakarta_test.controller;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
7+
/**
8+
*
9+
* @author jeremy
10+
*/
11+
@Controller
12+
@RequestMapping("/")
13+
public class HomeController {
14+
15+
@GetMapping("")
16+
public String index() {
17+
return "index";
18+
}
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package org.owasp.encoder.testing.jakarta_test.controller;
6+
7+
import org.owasp.encoder.testing.jakarta_test.service.ItemService;
8+
import org.springframework.stereotype.Controller;
9+
import org.springframework.ui.Model;
10+
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
13+
/**
14+
*
15+
* @author jeremy
16+
*/
17+
@Controller
18+
@RequestMapping("/item")
19+
public class ItemController {
20+
21+
private final ItemService itemService;
22+
23+
public ItemController(ItemService itemService) {
24+
this.itemService = itemService;
25+
}
26+
27+
@GetMapping("/viewItems")
28+
public String viewItems(Model model) {
29+
model.addAttribute("items", itemService.getItems());
30+
return "view-items";
31+
}
32+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package org.owasp.encoder.testing.jakarta_test.dto;
2+
3+
/**
4+
*
5+
* @author jeremy
6+
*/
7+
public class Item {
8+
9+
private int id;
10+
11+
private String name;
12+
13+
private String description;
14+
15+
public Item() {
16+
}
17+
18+
public Item(int id, String name, String description) {
19+
this.id = id;
20+
this.name = name;
21+
this.description = description;
22+
}
23+
24+
/**
25+
* Get the value of id
26+
*
27+
* @return the value of id
28+
*/
29+
public int getId() {
30+
return id;
31+
}
32+
33+
/**
34+
* Set the value of id
35+
*
36+
* @param id new value of id
37+
*/
38+
public void setId(int id) {
39+
this.id = id;
40+
}
41+
42+
/**
43+
* Get the value of name
44+
*
45+
* @return the value of name
46+
*/
47+
public String getName() {
48+
return name;
49+
}
50+
51+
/**
52+
* Set the value of name
53+
*
54+
* @param name new value of name
55+
*/
56+
public void setName(String name) {
57+
this.name = name;
58+
}
59+
60+
/**
61+
* Get the value of description
62+
*
63+
* @return the value of description
64+
*/
65+
public String getDescription() {
66+
return description;
67+
}
68+
69+
/**
70+
* Set the value of description
71+
*
72+
* @param description new value of description
73+
*/
74+
public void setDescription(String description) {
75+
this.description = description;
76+
}
77+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.owasp.encoder.testing.jakarta_test.service;
2+
3+
import java.util.Collection;
4+
import org.owasp.encoder.testing.jakarta_test.dto.Item;
5+
6+
/**
7+
*
8+
* @author jeremy
9+
*/
10+
public interface ItemService {
11+
Collection<Item> getItems();
12+
13+
Item addItem(Item item);
14+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.owasp.encoder.testing.jakarta_test.service.impl;
2+
3+
import java.util.ArrayList;
4+
import java.util.Collection;
5+
import org.owasp.encoder.testing.jakarta_test.dto.Item;
6+
import org.owasp.encoder.testing.jakarta_test.service.ItemService;
7+
import org.springframework.stereotype.Service;
8+
9+
/**
10+
*
11+
* @author jeremy
12+
*/
13+
@Service
14+
public class ItemServiceImpl implements ItemService {
15+
16+
@Override
17+
public Collection<Item> getItems() {
18+
Collection<Item> items = new ArrayList<>();
19+
items.add(new Item(1, "menu", "blob"));
20+
items.add(new Item(2, "top<script>alert(1)</script>", "fancy <script>alert(1)</script>"));
21+
return items;
22+
}
23+
24+
@Override
25+
public Item addItem(Item item) {
26+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
27+
}
28+
29+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
spring.application.name=jakarta-test
2+
server.servlet.context-path=/jakarta-test
3+
spring.mvc.view.prefix=/WEB-INF/jsp/
4+
spring.mvc.view.suffix=.jsp
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
table {
2+
font-family: arial, sans-serif;
3+
border-collapse: collapse;
4+
}
5+
6+
td, th {
7+
border: 1px solid #dddddd;
8+
text-align: left;
9+
padding: 8px;
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Error</title>
6+
</head>
7+
<body>
8+
Apparently you don't know what you are looking for?<br/><br/>4xx Error Occurred
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)