Skip to content

Commit 28fb3ba

Browse files
Added missing security tests; fixes gh-85
1 parent 3edd260 commit 28fb3ba

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed

tests/otel/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<module>spring-cloud-sleuth-instrumentation-rsocket-tests</module>
5757
<module>spring-cloud-sleuth-instrumentation-rxjava-tests</module>
5858
<module>spring-cloud-sleuth-instrumentation-r2dbc-tests</module>
59+
<module>spring-cloud-sleuth-instrumentation-security-tests</module>
5960
<module>spring-cloud-sleuth-instrumentation-scheduling-tests</module>
6061
<module>spring-cloud-sleuth-instrumentation-task-tests</module>
6162
<module>spring-cloud-sleuth-instrumentation-webflux-tests</module>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2021-2021 the original author or authors.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
~
18+
-->
19+
20+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xmlns="http://maven.apache.org/POM/4.0.0"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<artifactId>spring-cloud-sleuth-instrumentation-security-tests</artifactId>
26+
<packaging>jar</packaging>
27+
<name>Spring Cloud Sleuth OTel Security Instrumentation Tests</name>
28+
<description>Spring Cloud Sleuth OTel Security Instrumentation Tests</description>
29+
30+
<parent>
31+
<groupId>org.springframework.cloud</groupId>
32+
<artifactId>spring-cloud-sleuth-otel-tests</artifactId>
33+
<version>1.1.0-SNAPSHOT</version>
34+
<relativePath>..</relativePath>
35+
</parent>
36+
37+
<properties>
38+
<sonar.skip>true</sonar.skip>
39+
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
40+
</properties>
41+
42+
<build>
43+
<plugins>
44+
<plugin>
45+
<!--skip deploy -->
46+
<artifactId>maven-deploy-plugin</artifactId>
47+
<configuration>
48+
<skip>true</skip>
49+
</configuration>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
54+
<dependencies>
55+
<dependency>
56+
<groupId>org.springframework.cloud</groupId>
57+
<artifactId>spring-cloud-sleuth-tests-otel-common</artifactId>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-starter-web</artifactId>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-starter-security</artifactId>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.springframework.cloud</groupId>
69+
<artifactId>spring-cloud-starter-sleuth</artifactId>
70+
<exclusions>
71+
<exclusion>
72+
<groupId>org.springframework.cloud</groupId>
73+
<artifactId>spring-cloud-sleuth-brave</artifactId>
74+
</exclusion>
75+
</exclusions>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.springframework.cloud</groupId>
79+
<artifactId>spring-cloud-sleuth-otel-autoconfigure</artifactId>
80+
</dependency>
81+
<dependency>
82+
<groupId>org.springframework.boot</groupId>
83+
<artifactId>spring-boot-starter-test</artifactId>
84+
</dependency>
85+
</dependencies>
86+
87+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2021-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.sleuth.brave.instrument.security;
18+
19+
import io.opentelemetry.sdk.trace.samplers.Sampler;
20+
21+
import org.springframework.boot.test.context.SpringBootTest;
22+
import org.springframework.cloud.sleuth.instrument.security.SpringSecurityTests;
23+
import org.springframework.cloud.sleuth.otel.OtelTestSpanHandler;
24+
import org.springframework.cloud.sleuth.otel.bridge.ArrayListSpanProcessor;
25+
import org.springframework.context.annotation.Bean;
26+
import org.springframework.context.annotation.Configuration;
27+
import org.springframework.test.context.ContextConfiguration;
28+
29+
/**
30+
* @author Jonatan Ivanov
31+
*/
32+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
33+
@ContextConfiguration(classes = TracingSecurityContextChangedListenerIntegrationTests.Config.class)
34+
public class TracingSecurityContextChangedListenerIntegrationTests extends SpringSecurityTests {
35+
36+
@Configuration(proxyBeanMethods = false)
37+
static class Config {
38+
39+
@Bean
40+
OtelTestSpanHandler testSpanHandlerSupplier() {
41+
return new OtelTestSpanHandler(new ArrayListSpanProcessor());
42+
}
43+
44+
@Bean
45+
Sampler alwaysSampler() {
46+
return Sampler.alwaysOn();
47+
}
48+
49+
}
50+
51+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
spring.application.name: spring-security-test-app
2+
3+
#logging.level.org.springframework.security: TRACE

0 commit comments

Comments
 (0)