Skip to content

Commit 96f0432

Browse files
authored
Merge pull request #137 from WebFuzzing/spring-actuator-demo-drivers
Spring actuator demo drivers
2 parents f7711c7 + 7d5a9ca commit 96f0432

File tree

18 files changed

+525
-0
lines changed

18 files changed

+525
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,7 @@ jdk_8_maven/em/external/rest/spring-batch-rest/target
351351
/jdk_8_gradle/em/embedded/rest/erc20-rest-service/build
352352
/jdk_8_gradle/em/external/rest/erc20-rest-service/build
353353
/jdk_8_gradle/cs/rest/erc20-rest-service/.gradle
354+
355+
/jdk_8_maven/cs/rest/original/spring-actuator-demo/target
356+
/jdk_8_maven/em/embedded/rest/spring-actuator-demo/target
357+
/jdk_8_maven/em/external/rest/spring-actuator-demo/target

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ For simplicity, all schemas are also available as JSON/YML files under the folde
120120

121121
* **Session Service** (not-known license), [jdk_8_maven/cs/rest/original/session-service](jdk_8_maven/cs/rest/original/session-service), from [https://github.com/cBioPortal/session-service](https://github.com/cBioPortal/session-service)
122122

123+
* **Spring-actuator-demo** (not-known license), [jdk_8_maven/cs/rest/original/spring-actuator-demo](jdk_8_maven/cs/rest/original/spring-actuator-demo), from [https://github.com/callicoder/spring-boot-actuator-demo](https://github.com/callicoder/spring-boot-actuator-demo)
124+
123125
* **Spring-batch-rest** (Apache), [jdk_8_maven/cs/rest/original/spring-batch-rest](jdk_8_maven/cs/rest/original/spring-batch-rest), from [https://github.com/chrisgleissner/spring-batch-rest](https://github.com/chrisgleissner/spring-batch-rest)
124126

125127
* **Spring Boot Restful API Example** (MIT), [jdk_17_maven/cs/rest/spring-rest-example](jdk_17_maven/cs/rest/spring-rest-example), from [https://github.com/phantasmicmeans/spring-boot-restful-api-example](https://github.com/phantasmicmeans/spring-boot-restful-api-example)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
auth:
2+
- name: admin
3+
fixedHeaders:
4+
- name: Authorization
5+
value: Basic YWN0dWF0b3I6YWN0dWF0b3I=
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM amazoncorretto:8-alpine-jdk
2+
3+
COPY ./dist/spring-actuator-demo-sut.jar .
4+
COPY ./dist/jacocoagent.jar .
5+
6+
7+
8+
#ENV TOOL="undefined"
9+
#ENV RUN="0"
10+
11+
ENTRYPOINT \
12+
java \
13+
# unfortunately dumponexit is completely unreliable in Docker :(
14+
# -javaagent:jacocoagent.jar=destfile=./jacoco/spring-actuator-demo__${TOOL}__${RUN}__jacoco.exec,append=false,dumponexit=true \
15+
-javaagent:jacocoagent.jar=output=tcpserver,address=*,port=6300,append=false,dumponexit=false \
16+
-jar spring-actuator-demo-sut.jar \
17+
--server.port=8080
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
sut-spring-actuator-demo:
3+
build:
4+
dockerfile: ./dockerfiles/spring-actuator-demo.dockerfile
5+
context: ..
6+
# environment:
7+
# TOOL: ${TOOL:-undefined}
8+
# RUN: ${RUN:-0}
9+
ports:
10+
- "${HOST_PORT:-8080}:8080"
11+
- "${JACOCO_PORT:-6300}:6300"
12+
# volumes:
13+
# default env does not work on volumes
14+
# - ${JACOCODIR}:/jacoco
15+

jdk_8_maven/cs/rest/original/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<module>user-management</module>
2525
<module>blogapi</module>
2626
<module>spring-batch-rest</module>
27+
<module>spring-actuator-demo</module>
2728
</modules>
2829

2930

jdk_8_maven/cs/rest/original/spring-actuator-demo/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,30 @@
5757
<artifactId>spring-security-test</artifactId>
5858
<scope>test</scope>
5959
</dependency>
60+
<!-- MODIFIED-->
61+
<dependency>
62+
<groupId>org.springdoc</groupId>
63+
<artifactId>springdoc-openapi-ui</artifactId>
64+
<version>1.6.15</version>
65+
</dependency>
6066
</dependencies>
6167

6268
<build>
6369
<plugins>
6470
<plugin>
6571
<groupId>org.springframework.boot</groupId>
6672
<artifactId>spring-boot-maven-plugin</artifactId>
73+
<executions>
74+
<execution>
75+
<goals>
76+
<goal>repackage</goal>
77+
</goals>
78+
</execution>
79+
</executions>
80+
<configuration>
81+
<finalName>spring-actuator-demo</finalName>
82+
<classifier>sut</classifier>
83+
</configuration>
6784
</plugin>
6885
</plugins>
6986
</build>

jdk_8_maven/em/embedded/rest/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<module>user-management</module>
3131
<module>blogapi</module>
3232
<module>spring-batch-rest</module>
33+
<module>spring-actuator-demo</module>
3334
</modules>
3435

3536
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<artifactId>evomaster-benchmark-em-embedded-rest-spring-actuator-demo</artifactId>
8+
<packaging>jar</packaging>
9+
10+
<parent>
11+
<groupId>org.evomaster</groupId>
12+
<artifactId>evomaster-benchmark-em-embedded-rest</artifactId>
13+
<version>3.4.1-SNAPSHOT</version>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.example</groupId>
19+
<artifactId>actuator-demo</artifactId>
20+
<version>0.0.1-SNAPSHOT</version>
21+
</dependency>
22+
</dependencies>
23+
24+
25+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package em.embedded.spring.actuator.demo;
2+
3+
import com.example.actuatordemo.ActuatorDemoApplication;
4+
import org.evomaster.client.java.controller.AuthUtils;
5+
import org.evomaster.client.java.controller.EmbeddedSutController;
6+
import org.evomaster.client.java.controller.InstrumentedSutStarter;
7+
import org.evomaster.client.java.sql.DbSpecification;
8+
9+
10+
import org.evomaster.client.java.controller.problem.ProblemInfo;
11+
import org.evomaster.client.java.controller.problem.RestProblem;
12+
import org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto;
13+
import org.evomaster.client.java.controller.api.dto.SutInfoDto;
14+
15+
import org.springframework.boot.SpringApplication;
16+
import org.springframework.context.ConfigurableApplicationContext;
17+
18+
import java.util.Arrays;
19+
import java.util.List;
20+
import java.util.Map;
21+
22+
/**
23+
* Class used to start/stop the SUT. This will be controller by the EvoMaster process
24+
*/
25+
public class EmbeddedEvoMasterController extends EmbeddedSutController {
26+
27+
public static void main(String[] args) {
28+
29+
int port = 40100;
30+
if (args.length > 0) {
31+
port = Integer.parseInt(args[0]);
32+
}
33+
34+
EmbeddedEvoMasterController controller = new EmbeddedEvoMasterController(port);
35+
InstrumentedSutStarter starter = new InstrumentedSutStarter(controller);
36+
37+
starter.start();
38+
}
39+
40+
41+
private ConfigurableApplicationContext ctx;
42+
43+
44+
public EmbeddedEvoMasterController() {
45+
this(40100);
46+
}
47+
48+
public EmbeddedEvoMasterController(int port) {
49+
setControllerPort(port);
50+
}
51+
52+
@Override
53+
public String startSut() {
54+
ctx = SpringApplication.run(ActuatorDemoApplication.class, new String[]{
55+
"--server.port=0",
56+
});
57+
58+
59+
return "http://localhost:" + getSutPort();
60+
}
61+
62+
protected int getSutPort() {
63+
return (Integer) ((Map) ctx.getEnvironment()
64+
.getPropertySources().get("server.ports").getSource())
65+
.get("local.server.port");
66+
}
67+
68+
69+
@Override
70+
public boolean isSutRunning() {
71+
return ctx != null && ctx.isRunning();
72+
}
73+
74+
@Override
75+
public void stopSut() {
76+
ctx.stop();
77+
}
78+
79+
@Override
80+
public String getPackagePrefixesToCover() {
81+
return "com.example.actuatordemo.";
82+
}
83+
84+
@Override
85+
public void resetStateOfSUT() {
86+
}
87+
88+
@Override
89+
public List<AuthenticationDto> getInfoForAuthentication() {
90+
return Arrays.asList(
91+
AuthUtils.getForBasic("actuator","actuator","actuator")
92+
);
93+
}
94+
95+
@Override
96+
public ProblemInfo getProblemInfo() {
97+
return new RestProblem(
98+
"http://localhost:" + getSutPort() + "/v3/api-docs",
99+
null
100+
);
101+
}
102+
103+
@Override
104+
public SutInfoDto.OutputFormat getPreferredOutputFormat() {
105+
return SutInfoDto.OutputFormat.JAVA_JUNIT_4;
106+
}
107+
108+
@Override
109+
public List<DbSpecification> getDbSpecifications() {
110+
return null;
111+
}
112+
113+
}

0 commit comments

Comments
 (0)