From 20b97677db6a20b9a3d34fc20c9d2b1c6a572e0b Mon Sep 17 00:00:00 2001
From: sarps
Date: Mon, 21 Oct 2024 21:36:29 +0200
Subject: [PATCH] Address feedback
---
.../java/archunit/JavaArchUnitSecurityTestCase.java | 4 +++-
.../postcompile/JavaArchitectureTestCaseCollection.java | 3 +--
.../java/JavaSecurityTestCaseFactoryAndBuilder.java | 5 -----
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/main/java/de/tum/cit/ase/ares/api/architecture/java/archunit/JavaArchUnitSecurityTestCase.java b/src/main/java/de/tum/cit/ase/ares/api/architecture/java/archunit/JavaArchUnitSecurityTestCase.java
index e7fc67aa..57e9a5c9 100644
--- a/src/main/java/de/tum/cit/ase/ares/api/architecture/java/archunit/JavaArchUnitSecurityTestCase.java
+++ b/src/main/java/de/tum/cit/ase/ares/api/architecture/java/archunit/JavaArchUnitSecurityTestCase.java
@@ -96,7 +96,9 @@ public void executeArchitectureTestCase(JavaClasses classes) {
default -> throw new UnsupportedOperationException("Not implemented yet");
}
} catch (AssertionError e) {
- assert e.getMessage().split("\n").length > 1;
+ if (e.getMessage() == null || e.getMessage().split("\n").length < 2) {
+ throw new SecurityException(localized("security.archunit.illegal.execution", e.getMessage()));
+ }
throw new SecurityException(localized("security.archunit.illegal.execution", e.getMessage().split("\n")[1]));
}
}
diff --git a/src/main/java/de/tum/cit/ase/ares/api/architecture/java/archunit/postcompile/JavaArchitectureTestCaseCollection.java b/src/main/java/de/tum/cit/ase/ares/api/architecture/java/archunit/postcompile/JavaArchitectureTestCaseCollection.java
index d2076d7e..d996f33a 100644
--- a/src/main/java/de/tum/cit/ase/ares/api/architecture/java/archunit/postcompile/JavaArchitectureTestCaseCollection.java
+++ b/src/main/java/de/tum/cit/ase/ares/api/architecture/java/archunit/postcompile/JavaArchitectureTestCaseCollection.java
@@ -101,8 +101,7 @@ public static ArchRule noClassesShouldImportForbiddenPackages(Set allowe
public boolean test(JavaClass javaClass) {
return allowedPackages.stream().noneMatch(allowedPackage -> javaClass.getPackageName().startsWith(allowedPackage));
}
- })
- .as("TEST TEST");
+ });
}
private static ArchRule createNoClassShouldHaveMethodRule(
diff --git a/src/main/java/de/tum/cit/ase/ares/api/securitytest/java/JavaSecurityTestCaseFactoryAndBuilder.java b/src/main/java/de/tum/cit/ase/ares/api/securitytest/java/JavaSecurityTestCaseFactoryAndBuilder.java
index 24bb5d98..e7635d4c 100644
--- a/src/main/java/de/tum/cit/ase/ares/api/securitytest/java/JavaSecurityTestCaseFactoryAndBuilder.java
+++ b/src/main/java/de/tum/cit/ase/ares/api/securitytest/java/JavaSecurityTestCaseFactoryAndBuilder.java
@@ -30,7 +30,6 @@
import static com.google.common.collect.Iterables.isEmpty;
import static de.tum.cit.ase.ares.api.aop.java.instrumentation.advice.JavaInstrumentationAdviceToolbox.localize;
-import static de.tum.cit.ase.ares.api.jupiter.JupiterSecurityExtension.resetSettings;
//
/**
@@ -197,10 +196,6 @@ public JavaSecurityTestCaseFactoryAndBuilder(
*
*/
private void createSecurityTestCases() {
- //
- // Reset
- //
-
//
Set allowedPackages = new HashSet<>(resourceAccesses.regardingPackageImports());
// Add default imports needed for the execution