Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable tests with unpermitted operations in Threads #895

Open
alisevych opened this issue Sep 9, 2022 · 0 comments
Open

Disable tests with unpermitted operations in Threads #895

alisevych opened this issue Sep 9, 2022 · 0 comments
Assignees
Labels
comp-sandboxing Issue is related to sandboxing unpermitted operations by Java Security Manager ctg-bug Issue is a bug

Comments

@alisevych
Copy link
Member

alisevych commented Sep 9, 2022

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)

@alisevych alisevych added the ctg-bug Issue is a bug label Sep 9, 2022
@alisevych alisevych changed the title Disable tests with unpermitted operation is a Thread Disable tests with unpermitted operations is a Thread Sep 9, 2022
@alisevych alisevych changed the title Disable tests with unpermitted operations is a Thread Disable tests with unpermitted operations in Threads Sep 9, 2022
@korifey korifey moved this to Todo in UTBot Java Sep 9, 2022
@alisevych alisevych added ctg-enhancement New feature, improvement or change request and removed ctg-bug Issue is a bug labels Sep 12, 2022
@alisevych alisevych added ctg-bug Issue is a bug comp-sandboxing Issue is related to sandboxing unpermitted operations by Java Security Manager and removed ctg-enhancement New feature, improvement or change request labels Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-sandboxing Issue is related to sandboxing unpermitted operations by Java Security Manager ctg-bug Issue is a bug
Projects
Status: Todo
Development

No branches or pull requests

2 participants