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

Fix JUnit issue with Python tests #148

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaAESGCMTest extends TestBase {
class PycaAESGCMTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/aead/PycaAESGCMTestFile.py", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@
import com.ibm.mapper.model.functionality.Encrypt;
import com.ibm.mapper.model.functionality.KeyGeneration;
import com.ibm.plugin.TestBase;
import com.ibm.plugin.utils.GenerateAssertsHelper;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaChaCha20Poly1305Test extends TestBase {
class PycaChaCha20Poly1305Test extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/aead/PycaChaCha20Poly1305TestFile.py", this);
}
Expand Down Expand Up @@ -83,8 +82,6 @@ public void asserts(
assertThat(encryptValue).isInstanceOf(CipherAction.class);
assertThat(encryptValue.asString()).isEqualTo("DECRYPT");

GenerateAssertsHelper.generate(detectionStore, nodes);

/*
* Translation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaDSANumbersTest extends TestBase {
class PycaDSANumbersTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/DSA/PycaDSANumbersTestFile.py", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaDSASignTest extends TestBase {
class PycaDSASignTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/DSA/PycaDSASignTestFile.py", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
Expand All @@ -45,7 +45,7 @@ public final class PycaDiffieHellmanGenerateTest extends TestBase {
// The key size does not yet appear because
// of the TraceSymbol problem documented on the Github issue
@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/DiffieHellman/PycaDiffieHellmanGenerateTestFile.py",
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaDiffieHellmanNumbersTest extends TestBase {
class PycaDiffieHellmanNumbersTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/DiffieHellman/PycaDiffieHellmanNumbersTestFile.py",
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaEllipticCurveDeriveTest extends TestBase {
class PycaEllipticCurveDeriveTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/EllipticCurve/PycaEllipticCurveDeriveTestFile.py",
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaEllipticCurveKeyExchangeTest extends TestBase {
class PycaEllipticCurveKeyExchangeTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/EllipticCurve/PycaEllipticCurveKeyExchangeTestFile.py",
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaEllipticCurveNumbersTest extends TestBase {
class PycaEllipticCurveNumbersTest extends TestBase {

@Ignore("In this testcase the name of a var is resolved, but not teh actual value.")
@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/EllipticCurve/PycaEllipticCurveNumbersTestFile.py",
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaEllipticCurveSign2Test extends TestBase {
class PycaEllipticCurveSign2Test extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/EllipticCurve/PycaEllipticCurveSign2TestFile.py",
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaEllipticCurveSignTest extends TestBase {
class PycaEllipticCurveSignTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/EllipticCurve/PycaEllipticCurveSignTestFile.py",
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaEllipticCurveVerifyTest extends TestBase {
class PycaEllipticCurveVerifyTest extends TestBase {

// junit4
@Ignore(
@Disabled(
"Reenable once we have an approach to detect `verify` (either make it an entry\n"
+ "point, or better handle file imports for depending detection rule)")
@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/EllipticCurve/PycaEllipticCurveVerifyTestFile.py",
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaRSADecryptTest extends TestBase {
class PycaRSADecryptTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/RSA/PycaRSADecryptTestFile.py", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaRSANumbersTest extends TestBase {
class PycaRSANumbersTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/RSA/PycaRSANumbersTestFile.py", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaRSASign1Test extends TestBase {
class PycaRSASign1Test extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/RSA/PycaRSASign1TestFile.py", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaRSASign2Test extends TestBase {
class PycaRSASign2Test extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/asymmetric/RSA/PycaRSASign2TestFile.py", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
import com.ibm.plugin.TestBase;
import java.util.List;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.python.api.PythonCheck;
import org.sonar.plugins.python.api.PythonVisitorContext;
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.python.checks.utils.PythonCheckVerifier;

public class PycaFernetDecryptTest extends TestBase {
class PycaFernetDecryptTest extends TestBase {

@Test
public void test() {
void test() {
PythonCheckVerifier.verify(
"src/test/files/rules/detection/fernet/PycaFernetDecryptTestFile.py", this);
}
Expand Down
Loading
Loading