Skip to content

Commit fe41355

Browse files
author
Markus Paulsen
committed
fix: propagate bootstrap reset failures and relocate a misplaced comment
- resetSettingsInBootstrapClassLoader swallowed NoSuchMethodException, IllegalAccessException and InvocationTargetException, so a bootstrap-loaded settings class whose reset failed left the next test with stale security settings (fail-open). It now throws a SecurityException for those, matching resetSettings for the standard class loader, and still ignores only ClassNotFoundException, which just means there is nothing to reset yet. This closes the fail-open one level below the interceptor fix. - the earlier brace addition pulled the custom-URI comment inside the tests.isEmpty() branch, after an unconditional throw, where it was dead and no longer described the dynamicContainer return. Moved it back in front of the return in the four structural providers.
1 parent 5eb2908 commit fe41355

5 files changed

Lines changed: 29 additions & 19 deletions

File tree

src/main/java/de/tum/cit/ase/ares/api/jupiter/JupiterSecurityExtension.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,19 @@ public static void resetSettingsInBootstrapClassLoader() {
186186
resetMethod.invoke(null);
187187
resetMethod.setAccessible(false);
188188
} catch (ClassNotFoundException e) {
189-
// Class not yet loaded in Bootstrap ClassLoader - OK if no instrumentation yet
190-
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
191-
// Reset failed - log silently
189+
// Class not yet loaded in the bootstrap class loader: there is nothing to
190+
// reset,
191+
// which is the only benign reason this can fail.
192+
} catch (NoSuchMethodException e) {
193+
// The class is present but its reset failed. Fail closed rather than let the
194+
// next
195+
// test inherit stale security settings, matching resetSettings for the standard
196+
// class loader.
197+
throw new SecurityException(localize("security.settings.reset.method.not.found"), e);
198+
} catch (IllegalAccessException e) {
199+
throw new SecurityException(localize("security.settings.reset.access.denied"), e);
200+
} catch (InvocationTargetException e) {
201+
throw new SecurityException(localize("security.settings.error.within.method"), e);
192202
}
193203
}
194204

src/main/java/de/tum/cit/ase/ares/api/structural/AttributeTestProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ protected DynamicContainer generateTestsForAllClasses() throws URISyntaxExceptio
6161
if (tests.isEmpty()) {
6262
throw failure(
6363
"No tests for attributes available in the structural oracle (test.json). Either provide attributes information or delete AttributeTest.java!"); //$NON-NLS-1$
64-
/*
65-
* Using a custom URI here to workaround surefire rendering the JUnit XML
66-
* without the correct test names.
67-
*/
6864
}
65+
/*
66+
* Using a custom URI here to workaround surefire rendering the JUnit XML
67+
* without the correct test names.
68+
*/
6969
return dynamicContainer(getClass().getName(), new URI(getClass().getName()), tests.stream());
7070
}
7171

src/main/java/de/tum/cit/ase/ares/api/structural/ClassTestProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ && hasAdditionalProperties(expectedClassPropertiesJSON)) {
6262
if (tests.isEmpty()) {
6363
throw failure(
6464
"No tests for classes available in the structural oracle (test.json). Either provide attributes information or delete ClassTest.java!"); //$NON-NLS-1$
65-
/*
66-
* Using a custom URI here to workaround surefire rendering the JUnit XML
67-
* without the correct test names.
68-
*/
6965
}
66+
/*
67+
* Using a custom URI here to workaround surefire rendering the JUnit XML
68+
* without the correct test names.
69+
*/
7070
return dynamicContainer(getClass().getName(), new URI(getClass().getName()), tests.stream());
7171
}
7272

src/main/java/de/tum/cit/ase/ares/api/structural/ConstructorTestProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ protected DynamicContainer generateTestsForAllClasses() throws URISyntaxExceptio
5858
if (tests.isEmpty()) {
5959
throw failure(
6060
"No tests for constructors available in the structural oracle (test.json). Either provide constructor information or delete ConstructorTest.java!"); //$NON-NLS-1$
61-
/*
62-
* Using a custom URI here to workaround surefire rendering the JUnit XML
63-
* without the correct test names.
64-
*/
6561
}
62+
/*
63+
* Using a custom URI here to workaround surefire rendering the JUnit XML
64+
* without the correct test names.
65+
*/
6666
return dynamicContainer(getClass().getName(), new URI(getClass().getName()), tests.stream());
6767
}
6868

src/main/java/de/tum/cit/ase/ares/api/structural/MethodTestProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ protected DynamicContainer generateTestsForAllClasses() throws URISyntaxExceptio
5858
if (tests.isEmpty()) {
5959
throw failure(
6060
"No tests for methods available in the structural oracle (test.json). Either provide attributes information or delete MethodTest.java!"); //$NON-NLS-1$
61-
/*
62-
* Using a custom URI here to workaround surefire rendering the JUnit XML
63-
* without the correct test names.
64-
*/
6561
}
62+
/*
63+
* Using a custom URI here to workaround surefire rendering the JUnit XML
64+
* without the correct test names.
65+
*/
6666
return dynamicContainer(getClass().getName(), new URI(getClass().getName()), tests.stream());
6767
}
6868

0 commit comments

Comments
 (0)