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:
public class SecurityCheck {
    public int read() throws Throwable {
        Thread t = new Thread("fileRead") {
            public void run()  {
                try {
                    new File("a.txt").createNewFile();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        };
        t.start();
        Thread.sleep(500);
        return 10;
    }
}
  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)

public class SecurityCheckTest {
    @Test
    @DisplayName("read: arg_0 = SecurityCheck() -> return 10")
    public void testReadReturns10() throws Throwable {
        SecurityCheck securityCheck = new SecurityCheck();

        int actual = securityCheck.read();

        assertEquals(10, actual);
    }
}

Environment

Windows 10 Pro
IntelliJ IDEA 2022.1.4
JDK 8

Originally posted by @alisevych in #790 (comment)

Activity

  1. changed the title [-]Disable tests with unpermitted operation is a Thread[/-] [+]Disable tests with unpermitted operations is a Thread[/+] on Sep 9, 2022
  2. changed the title [-]Disable tests with unpermitted operations is a Thread[/-] [+]Disable tests with unpermitted operations in Threads[/+] on Sep 9, 2022
  3. moved this to Todo in UTBot Javaon Sep 9, 2022
  4. added
    ctg-enhancementNew feature, improvement or change request
    and removed
    ctg-bugIssue is a bug
    on Sep 12, 2022
  5. added
    ctg-bugIssue is a bug
    comp-sandboxingIssue is related to sandboxing unpermitted operations by Java Security Manager
    and removed
    ctg-enhancementNew feature, improvement or change request
    on Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions