Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ jobs:
cd services/${{ matrix.service }}
mvn clean test

- name: Static Analysis with Spotbugs
run: |
cd services/${{ matrix.service }}
mvn compile spotbugs:check

frontend-test:
name: Build & Test Frontend
needs: openapi-lint
Expand Down
8 changes: 4 additions & 4 deletions scripts/test-backends.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (fs.existsSync(servicesDir)) {
const pomPath = path.join(servicesDir, service, 'pom.xml');
if (fs.existsSync(pomPath)) {
console.log(`\n========================================`);
console.log(`Running tests for service: ${service}`);
console.log(`Running tests and static analysis for service: ${service}`);
console.log(`========================================`);
try {
const serviceDir = path.join(servicesDir, service);
Expand All @@ -20,12 +20,12 @@ if (fs.existsSync(servicesDir)) {
? (process.platform === 'win32' ? 'mvnw.cmd' : './mvnw')
: 'mvn';

execSync(`${cmd} clean test -Dsurefire.exitTimeout=1 -DargLine="-Dlogging.level.com.tngtech.archunit.core.importer.ClassFileProcessor=ERROR"`, {
execSync(`${cmd} clean test spotbugs:check -Dsurefire.exitTimeout=1 -DargLine="-Dlogging.level.com.tngtech.archunit.core.importer.ClassFileProcessor=ERROR"`, {
cwd: serviceDir,
stdio: 'inherit'
});
} catch (error) {
console.error(`\nTests failed for service: ${service}`);
console.error(`\nTests or static analysis failed for service: ${service}`);
failed = true;
}
}
Expand All @@ -35,5 +35,5 @@ if (fs.existsSync(servicesDir)) {
if (failed) {
process.exit(1);
} else {
console.log('\nAll backend tests completed successfully.');
console.log('\nAll backend tests and static analysis completed successfully.');
}
15 changes: 15 additions & 0 deletions services/admin-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.10.2.0</version>
<configuration>
<excludeFilterFile>${project.basedir}/../spotbugs-exclude.xml</excludeFilterFile>
</configuration>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.10.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
15 changes: 15 additions & 0 deletions services/calendar-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.10.2.0</version>
<configuration>
<excludeFilterFile>${project.basedir}/../spotbugs-exclude.xml</excludeFilterFile>
</configuration>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.10.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
15 changes: 15 additions & 0 deletions services/checklist-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.10.2.0</version>
<configuration>
<excludeFilterFile>${project.basedir}/../spotbugs-exclude.xml</excludeFilterFile>
</configuration>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.10.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
15 changes: 15 additions & 0 deletions services/note-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.10.2.0</version>
<configuration>
<excludeFilterFile>${project.basedir}/../spotbugs-exclude.xml</excludeFilterFile>
</configuration>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.10.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
15 changes: 15 additions & 0 deletions services/shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.10.2.0</version>
<configuration>
<excludeFilterFile>${project.basedir}/../spotbugs-exclude.xml</excludeFilterFile>
</configuration>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.10.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.jsonwebtoken.Claims;
import jakarta.servlet.http.HttpServletRequest;

public class JWTHelper {
public final class JWTHelper {

private JWTHelper() {
throw new IllegalAccessError("Illegal access of JWTHelper - No instantiation!");
Expand Down
17 changes: 17 additions & 0 deletions services/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter
xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/master/spotbugs/etc/findbugsfilter.xsd">

<!-- Exclude generated OpenAPI classes -->
<Match>
<Package name="~org\.openapitools\..*" />
</Match>

<!-- Exclude MapStruct generated mapper implementations -->
<Match>
<Class name="~.*MapperImpl.*" />
</Match>

</FindBugsFilter>
15 changes: 15 additions & 0 deletions services/user-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.10.2.0</version>
<configuration>
<excludeFilterFile>${project.basedir}/../spotbugs-exclude.xml</excludeFilterFile>
</configuration>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.10.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
@EnableWebSecurity
public class SecurityConfig {

private final JwtAuthenticationFilter jwtAuthFilter;

public SecurityConfig(JwtAuthenticationFilter jwtAuthFilter) {
this.jwtAuthFilter = jwtAuthFilter;
}

@Bean
@Order(1)
public SecurityFilterChain loginSecurityFilterChain(HttpSecurity http) {
Expand All @@ -39,7 +33,7 @@ public SecurityFilterChain loginSecurityFilterChain(HttpSecurity http) {

@Bean
@Order(2)
public SecurityFilterChain apiSecurityFilterChain(HttpSecurity http) {
public SecurityFilterChain apiSecurityFilterChain(HttpSecurity http, JwtAuthenticationFilter jwtAuthFilter) {
http
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(auth -> auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.function.Function;

@Service
public class JwtService {
public final class JwtService {

private static final long EXPIRATION_MS = 24 * 60 * 60 * 1000L;
private final PrivateKey privateKey;
Expand Down Expand Up @@ -73,10 +73,6 @@ public String extractUsername(String token) {
return extractClaim(token, claims -> claims.get("name", String.class));
}

public String extractUserId(String token) {
return extractClaim(token, Claims::getSubject);
}

public Date extractExpiration(String token) {
return extractClaim(token, Claims::getExpiration);
}
Expand Down
Loading