Skip to content

Commit

Permalink
Rename internal API from Artemis to Ares
Browse files Browse the repository at this point in the history
  • Loading branch information
MaisiKoleni committed Mar 24, 2022
1 parent 18640d9 commit c08f7bd
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import de.tum.in.test.api.WhitelistClass;
import de.tum.in.test.api.WhitelistPackage;
import de.tum.in.test.api.WhitelistPath;
import de.tum.in.test.api.security.ArtemisSecurityConfiguration;
import de.tum.in.test.api.security.ArtemisSecurityConfigurationBuilder;
import de.tum.in.test.api.security.AresSecurityConfiguration;
import de.tum.in.test.api.security.AresSecurityConfigurationBuilder;
import de.tum.in.test.api.util.PackageRule;
import de.tum.in.test.api.util.PathRule;
import de.tum.in.test.api.util.RuleType;
Expand All @@ -38,8 +38,8 @@ public final class ConfigurationUtils {
private ConfigurationUtils() {
}

public static ArtemisSecurityConfiguration generateConfiguration(TestContext context) {
var config = ArtemisSecurityConfigurationBuilder.create();
public static AresSecurityConfiguration generateConfiguration(TestContext context) {
var config = AresSecurityConfigurationBuilder.create();
config.configureFromContext(context);
config.withPath(Path.of("")); //$NON-NLS-1$
config.addWhitelistedClassNames(generateClassWhiteList(context));
Expand Down Expand Up @@ -87,7 +87,7 @@ public static long getMaxStandardOutput(TestContext context) {
.orElse(MirrorOutput.DEFAULT_MAX_STD_OUT);
}

public static void configureAllowLocalPort(ArtemisSecurityConfigurationBuilder config, TestContext context) {
public static void configureAllowLocalPort(AresSecurityConfigurationBuilder config, TestContext context) {
TestContextUtils.findAnnotationIn(context, AllowLocalPort.class).ifPresent(allowLocalPort -> {
config.withAllowedLocalPorts(IntStream.of(allowLocalPort.value()).boxed().collect(Collectors.toSet()));
config.withAllowLocalPortsAbove(OptionalInt.of(allowLocalPort.allowPortsAbove()));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/tum/in/test/api/internal/TestType.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import de.tum.in.test.api.jupiter.PublicTest;

/**
* Type of an Artemis test case
* Type of an Ares test case
*
* @see Hidden
* @see Public
* @see HiddenTest
* @see PublicTest
* @author Christian Femers
* @since 0.2.0
* @version 1.0.0
* @version 1.0.1
*/
@API(status = Status.INTERNAL)
public enum TestType {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/tum/in/test/api/jqwik/Hidden.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@Documented
@Retention(RUNTIME)
@Target({ METHOD, ANNOTATION_TYPE, TYPE })
@JqwikArtemisTest(TestType.HIDDEN)
@JqwikAresTest(TestType.HIDDEN)
public @interface Hidden {
// marker only
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@AddLifecycleHook(value = JqwikIOExtension.class, propagateTo = PropagationMode.ALL_DESCENDANTS)
@AddLifecycleHook(value = JqwikSecurityExtension.class, propagateTo = PropagationMode.ALL_DESCENDANTS)
@AddLifecycleHook(value = JqwikStrictTimeoutExtension.class, propagateTo = PropagationMode.ALL_DESCENDANTS)
public @interface JqwikArtemisTest {
public @interface JqwikAresTest {

TestType value();
}
2 changes: 1 addition & 1 deletion src/main/java/de/tum/in/test/api/jqwik/JqwikContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public static JqwikContext of(PropertyLifecycleContext lifecycleContext) {

@Override
public Optional<TestType> findTestType() {
return TestContextUtils.findAnnotationIn(this, JqwikArtemisTest.class).map(JqwikArtemisTest::value);
return TestContextUtils.findAnnotationIn(this, JqwikAresTest.class).map(JqwikAresTest::value);
}
}
2 changes: 1 addition & 1 deletion src/main/java/de/tum/in/test/api/jqwik/Public.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@Documented
@Retention(RUNTIME)
@Target({ METHOD, ANNOTATION_TYPE, TYPE })
@JqwikArtemisTest(TestType.PUBLIC)
@JqwikAresTest(TestType.PUBLIC)
public @interface Public {
// marker only
}
2 changes: 1 addition & 1 deletion src/main/java/de/tum/in/test/api/jupiter/Hidden.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@Documented
@Retention(RUNTIME)
@Target({ METHOD, ANNOTATION_TYPE, TYPE })
@JupiterArtemisTest(TestType.HIDDEN)
@JupiterAresTest(TestType.HIDDEN)
public @interface Hidden {
// marker only
}
2 changes: 1 addition & 1 deletion src/main/java/de/tum/in/test/api/jupiter/HiddenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@Retention(RUNTIME)
@Target(METHOD)
@Test
@JupiterArtemisTest(TestType.HIDDEN)
@JupiterAresTest(TestType.HIDDEN)
public @interface HiddenTest {
// maker only
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@ExtendWith(JupiterTestGuard.class)
@ExtendWith(JupiterSecurityExtension.class)
@ExtendWith(JupiterStrictTimeoutExtension.class)
public @interface JupiterArtemisTest {
public @interface JupiterAresTest {

TestType value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public String displayName() {

@Override
public Optional<TestType> findTestType() {
return TestContextUtils.findAnnotationIn(this, JupiterArtemisTest.class).map(JupiterArtemisTest::value);
return TestContextUtils.findAnnotationIn(this, JupiterAresTest.class).map(JupiterAresTest::value);
}

public ExtensionContext getExtensionContext() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/tum/in/test/api/jupiter/Public.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@Documented
@Retention(RUNTIME)
@Target({ METHOD, ANNOTATION_TYPE, TYPE })
@JupiterArtemisTest(TestType.PUBLIC)
@JupiterAresTest(TestType.PUBLIC)
public @interface Public {
// marker only
}
2 changes: 1 addition & 1 deletion src/main/java/de/tum/in/test/api/jupiter/PublicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@Retention(RUNTIME)
@Target(METHOD)
@Test
@JupiterArtemisTest(TestType.PUBLIC)
@JupiterAresTest(TestType.PUBLIC)
public @interface PublicTest {
// maker only
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import de.tum.in.test.api.util.PathRule;

@API(status = Status.INTERNAL)
public final class ArtemisSecurityConfiguration {
public final class AresSecurityConfiguration {
private final Optional<Class<?>> testClass;
private final Optional<Method> testMethod;
private final Path executionPath;
Expand All @@ -33,7 +33,7 @@ public final class ArtemisSecurityConfiguration {
private final Set<PackageRule> trustedPackages;
private final TrustScope threadTrustScope;

ArtemisSecurityConfiguration(Optional<Class<?>> testClass, Optional<Method> testMethod, Path executionPath, // NOSONAR
AresSecurityConfiguration(Optional<Class<?>> testClass, Optional<Method> testMethod, Path executionPath, // NOSONAR
Collection<String> whitelistedClassNames, Optional<Collection<PathRule>> whitelistedPaths,
Collection<PathRule> blacklistedPaths, Set<Integer> allowedLocalPorts, OptionalInt allowLocalPortsAbove,
Set<Integer> excludedLocalPorts, OptionalInt allowedThreadCount, Set<PackageRule> blacklistedPackages,
Expand Down Expand Up @@ -114,9 +114,9 @@ public TrustScope threadTrustScope() {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!(obj instanceof ArtemisSecurityConfiguration))
if (!(obj instanceof AresSecurityConfiguration))
return false;
ArtemisSecurityConfiguration other = (ArtemisSecurityConfiguration) obj;
AresSecurityConfiguration other = (AresSecurityConfiguration) obj;
return Objects.equals(executionPath, other.executionPath) && Objects.equals(testClass, other.testClass)
&& Objects.equals(testMethod, other.testMethod)
&& Objects.equals(whitelistedClassNames, other.whitelistedClassNames)
Expand All @@ -139,7 +139,7 @@ public int hashCode() {

@Override
public String toString() {
return String.format("ArtemisSecurityConfigurationImpl [whitelistedClassNames=%s, executionPath=%s," //$NON-NLS-1$
return String.format("AresSecurityConfiguration [whitelistedClassNames=%s, executionPath=%s," //$NON-NLS-1$
+ " testClass=%s, testMethod=%s, whitelistedPaths=%s, blacklistedPaths=%s, allowedLocalPorts=%s," //$NON-NLS-1$
+ " allowLocalPortsAbove=%s, excludedLocalPorts=%s, allowedThreadCount=%s," //$NON-NLS-1$
+ " blacklistedPackages=%s, whitelistedPackages=%s, trustedPackages=%s, threadTrustScope=%s]", //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import de.tum.in.test.api.util.PathRule;

@API(status = Status.INTERNAL)
public final class ArtemisSecurityConfigurationBuilder {
public final class AresSecurityConfigurationBuilder {

private static final Logger LOG = LoggerFactory.getLogger(ArtemisSecurityConfigurationBuilder.class);
private static final Logger LOG = LoggerFactory.getLogger(AresSecurityConfigurationBuilder.class);

private static final Path EXPECTED_MAVEN_POM_PATH = Path
.of(System.getProperty(AresSystemProperties.ARES_MAVEN_POM, "pom.xml")); //$NON-NLS-1$
Expand Down Expand Up @@ -71,7 +71,7 @@ public final class ArtemisSecurityConfigurationBuilder {
private Set<PackageRule> trustedPackages;
private TrustScope threadTrustScope;

private ArtemisSecurityConfigurationBuilder() {
private AresSecurityConfigurationBuilder() {
testClass = Optional.empty();
testMethod = Optional.empty();
whitelistedClassNames = new HashSet<>();
Expand All @@ -86,75 +86,75 @@ private ArtemisSecurityConfigurationBuilder() {
threadTrustScope = TrustScope.MINIMAL;
}

public ArtemisSecurityConfigurationBuilder withPath(Path executionPath) {
public AresSecurityConfigurationBuilder withPath(Path executionPath) {
this.executionPath = Objects.requireNonNull(executionPath);
return this;
}

public ArtemisSecurityConfigurationBuilder withPathWhitelist(Collection<PathRule> whitelistedPaths) {
public AresSecurityConfigurationBuilder withPathWhitelist(Collection<PathRule> whitelistedPaths) {
this.whitelistedPaths = Set.copyOf(whitelistedPaths);
return this;
}

public ArtemisSecurityConfigurationBuilder withPathBlacklist(Collection<PathRule> blacklistedPaths) {
public AresSecurityConfigurationBuilder withPathBlacklist(Collection<PathRule> blacklistedPaths) {
this.blacklistedPaths = Set.copyOf(blacklistedPaths);
return this;
}

public ArtemisSecurityConfigurationBuilder withAllowedLocalPorts(Set<Integer> allowedLocalPorts) {
public AresSecurityConfigurationBuilder withAllowedLocalPorts(Set<Integer> allowedLocalPorts) {
this.allowedLocalPorts = Objects.requireNonNull(allowedLocalPorts);
return this;
}

public ArtemisSecurityConfigurationBuilder withAllowLocalPortsAbove(OptionalInt allowLocalPortsAbove) {
public AresSecurityConfigurationBuilder withAllowLocalPortsAbove(OptionalInt allowLocalPortsAbove) {
this.allowLocalPortsAbove = Objects.requireNonNull(allowLocalPortsAbove);
return this;
}

public ArtemisSecurityConfigurationBuilder withExcludedLocalPorts(Set<Integer> excludedLocalPorts) {
public AresSecurityConfigurationBuilder withExcludedLocalPorts(Set<Integer> excludedLocalPorts) {
this.excludedLocalPorts = Objects.requireNonNull(excludedLocalPorts);
return this;
}

public ArtemisSecurityConfigurationBuilder withAllowedThreadCount(OptionalInt allowedThreadCount) {
public AresSecurityConfigurationBuilder withAllowedThreadCount(OptionalInt allowedThreadCount) {
this.allowedThreadCount = Objects.requireNonNull(allowedThreadCount);
return this;
}

public ArtemisSecurityConfigurationBuilder configureFromContext(TestContext context) {
public AresSecurityConfigurationBuilder configureFromContext(TestContext context) {
testClass = Objects.requireNonNull(context.testClass());
testMethod = Objects.requireNonNull(context.testMethod());
return this;
}

public ArtemisSecurityConfigurationBuilder addWhitelistedClassNames(Collection<String> classNames) {
public AresSecurityConfigurationBuilder addWhitelistedClassNames(Collection<String> classNames) {
whitelistedClassNames.addAll(classNames);
return this;
}

public ArtemisSecurityConfigurationBuilder withPackageBlacklist(Collection<PackageRule> packageBlacklist) {
public AresSecurityConfigurationBuilder withPackageBlacklist(Collection<PackageRule> packageBlacklist) {
blacklistedPackages = Set.copyOf(packageBlacklist);
return this;
}

public ArtemisSecurityConfigurationBuilder withPackageWhitelist(Collection<PackageRule> packageWhitelist) {
public AresSecurityConfigurationBuilder withPackageWhitelist(Collection<PackageRule> packageWhitelist) {
whitelistedPackages = Set.copyOf(packageWhitelist);
return this;
}

public ArtemisSecurityConfigurationBuilder withTrustedPackages(Set<PackageRule> trustedPackages) {
public AresSecurityConfigurationBuilder withTrustedPackages(Set<PackageRule> trustedPackages) {
this.trustedPackages = Set.copyOf(trustedPackages);
return this;
}

public ArtemisSecurityConfigurationBuilder withThreadTrustScope(TrustScope threadTrustScope) {
public AresSecurityConfigurationBuilder withThreadTrustScope(TrustScope threadTrustScope) {
this.threadTrustScope = Objects.requireNonNull(threadTrustScope);
return this;
}

public ArtemisSecurityConfiguration build() {
public AresSecurityConfiguration build() {
validate();
return new ArtemisSecurityConfiguration(testClass, testMethod, executionPath, whitelistedClassNames,
return new AresSecurityConfiguration(testClass, testMethod, executionPath, whitelistedClassNames,
Optional.ofNullable(whitelistedPaths), blacklistedPaths, allowedLocalPorts, allowLocalPortsAbove,
excludedLocalPorts, allowedThreadCount, blacklistedPackages, whitelistedPackages, trustedPackages,
threadTrustScope);
Expand All @@ -165,8 +165,8 @@ private void validate() {
throw new ConfigurationException(localized("security.configuration_invalid_negative_threads")); //$NON-NLS-1$
if (!Collections.disjoint(allowedLocalPorts, excludedLocalPorts))
throw new ConfigurationException(localized("security.configuration_invalid_port_rule_intersection")); //$NON-NLS-1$
allowedLocalPorts.forEach(ArtemisSecurityConfigurationBuilder::validatePortRange);
excludedLocalPorts.forEach(ArtemisSecurityConfigurationBuilder::validatePortRange);
allowedLocalPorts.forEach(AresSecurityConfigurationBuilder::validatePortRange);
excludedLocalPorts.forEach(AresSecurityConfigurationBuilder::validatePortRange);
allowLocalPortsAbove.ifPresent(value -> {
validatePortRange(value);
if (allowedLocalPorts.stream().anyMatch(allowed -> allowed > value))
Expand Down Expand Up @@ -229,7 +229,7 @@ private static void validateTrustedPackages(Set<PackageRule> trustedPackages) {
}
}

public static ArtemisSecurityConfigurationBuilder create() {
return new ArtemisSecurityConfigurationBuilder();
public static AresSecurityConfigurationBuilder create() {
return new AresSecurityConfigurationBuilder();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public final class ArtemisSecurityManager extends SecurityManager {
private final ThreadLocal<AtomicInteger> recursionBreak = ThreadLocal.withInitial(AtomicInteger::new);
private final StackWalker stackWalker = StackWalker.getInstance();

private ArtemisSecurityConfiguration configuration;
private AresSecurityConfiguration configuration;
private String accessToken;
private Set<Thread> whitelistedThreads = new HashSet<>();
private volatile boolean isPartlyDisabled;
Expand Down Expand Up @@ -764,7 +764,7 @@ public static synchronized boolean isInstalled() {
return System.getSecurityManager() instanceof ArtemisSecurityManager;
}

public static synchronized String install(ArtemisSecurityConfiguration configuration) {
public static synchronized String install(AresSecurityConfiguration configuration) {
if (INSTANCE.lastUninstallFailed) {
LOG.info("Try recovery from lastUninstallFailed"); //$NON-NLS-1$
INSTANCE.checkThreadGroup();
Expand Down Expand Up @@ -819,7 +819,7 @@ public static synchronized void uninstall(String accessToken) {
formatLocalized("security.error_threads_still_active", Arrays.toString(activeThreads))); //$NON-NLS-1$
}

public static synchronized void configure(String accessToken, ArtemisSecurityConfiguration configuration) {
public static synchronized void configure(String accessToken, AresSecurityConfiguration configuration) {
INSTANCE.checkAccess(accessToken);
INSTANCE.configuration = configuration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import de.tum.in.test.api.util.PathRule;
import de.tum.in.test.api.util.RuleType;

class ArtemisSecurityConfigurationTest {
class AresSecurityConfigurationTest {

private static final int ALLOWED_PORT_NUMBER = 42;
private static final int ALLOW_PORT_ABOVE = 1000;
Expand All @@ -46,11 +46,11 @@ class ArtemisSecurityConfigurationTest {
private static final TestContext MOCK_TEST_CONTEXT_ONE = new MockTestContext(new TestTestClass(), TEST_ONE);
private static final TestContext MOCK_TEST_CONTEXT_TWO = new MockTestContext(new TestTestClass(), TEST_TWO);

private final ArtemisSecurityConfiguration configurationOneA = ConfigurationUtils
private final AresSecurityConfiguration configurationOneA = ConfigurationUtils
.generateConfiguration(MOCK_TEST_CONTEXT_ONE);
private final ArtemisSecurityConfiguration configurationOneB = ConfigurationUtils
private final AresSecurityConfiguration configurationOneB = ConfigurationUtils
.generateConfiguration(MOCK_TEST_CONTEXT_ONE);
private final ArtemisSecurityConfiguration configurationTwo = ConfigurationUtils
private final AresSecurityConfiguration configurationTwo = ConfigurationUtils
.generateConfiguration(MOCK_TEST_CONTEXT_TWO);

@Test
Expand Down

0 comments on commit c08f7bd

Please sign in to comment.