Skip to content

Disable tests with unpermitted operations in Threads #895

Description

@alisevych

Description

Tests with unpermitted operation is Threads should be disabled, but they are up.

To Reproduce

  1. IntelliJ IDEA 2022.1.4 with latest UTBot plugin installed
  2. Create/open a project with JDK 8/11
  3. Add the following class and generate tests for it with default settings:
publicclassSecurityCheck {
publicintread() throwsThrowable {
Threadt = newThread("fileRead") {
publicvoidrun() {
try {
newFile("a.txt").createNewFile();
} catch (IOExceptione) {
thrownewRuntimeException(e);
}
}
};
t.start();
Thread.sleep(500);
return10;
}
}
  1. Open the generated test

Expected behavior

Generated test should be disabled due to sandbox.

Actual behavior

The following method is not executed - AccessControlException is thrown (was seen in Concrete executor logs when they were informative) - that's Ok.
But the generated tests are not disabled due to Sandbox. If we run the test - file will be created.

Visual proofs (screenshots, logs, images)

publicclassSecurityCheckTest {
@Test@DisplayName("read: arg_0 = SecurityCheck() -> return 10")
publicvoidtestReadReturns10() throwsThrowable {
SecurityChecksecurityCheck = newSecurityCheck();
intactual = securityCheck.read();
assertEquals(10, actual);
}
}

Environment

Windows 10 Pro
IntelliJ IDEA 2022.1.4
JDK 8

Originally posted by @alisevych in #790 (comment)

Metadata

Metadata

Assignees

Labels

comp-sandboxingIssue is related to sandboxing unpermitted operations by Java Security Managerctg-bugIssue is a bug

Type

No type

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions