Search in sources :

Example 31 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class ConflictTest method testCyclicCallNegative.

@Test
public void testCyclicCallNegative() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/conflicts/cyclic-call-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length == 3);
    BAssertUtil.validateError(result, 0, "taint checking for 'f3' could not complete due to recursion with 'f1', add @tainted or " + "@untainted to returns", 10, 12);
    BAssertUtil.validateError(result, 1, "taint checking for 'f1' could not complete due to recursion with 'f2', add @tainted or " + "@untainted to returns", 2, 12);
    BAssertUtil.validateError(result, 2, "taint checking for 'f2' could not complete due to recursion with 'f3', add @tainted or " + "@untainted to returns", 6, 12);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 32 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class ConflictTest method testRecursion.

// Test recursions.
@Test
public void testRecursion() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/conflicts/recursion.bal");
    Assert.assertTrue(result.getDiagnostics().length == 1);
    BAssertUtil.validateWarning(result, 0, "taint checking for 'f1' partially done based on return annotations", 1, 1);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 33 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class TaintedStatusPropagationTest method testStructNegative.

@Test
public void testStructNegative() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/propagation/struct-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length == 8);
    BAssertUtil.validateError(result, 0, "tainted value passed to sensitive parameter 'secureIn'", 8, 20);
    BAssertUtil.validateError(result, 1, "tainted value passed to sensitive parameter 'secureIn'", 12, 20);
    BAssertUtil.validateError(result, 2, "tainted value passed to sensitive parameter 'secureIn'", 16, 20);
    BAssertUtil.validateError(result, 3, "tainted value passed to sensitive parameter 'secureIn'", 20, 20);
    BAssertUtil.validateError(result, 4, "tainted value passed to sensitive parameter 'secureIn'", 25, 20);
    BAssertUtil.validateError(result, 5, "tainted value passed to sensitive parameter 'secureIn'", 30, 20);
    BAssertUtil.validateError(result, 6, "tainted value passed to sensitive parameter 'secureIn'", 36, 20);
    BAssertUtil.validateError(result, 7, "tainted value passed to sensitive parameter 'secureIn'", 42, 20);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 34 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class TaintedStatusPropagationTest method testReturn.

@Test
public void testReturn() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/propagation/returns.bal");
    Assert.assertTrue(result.getDiagnostics().length == 0);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 35 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class TaintedStatusPropagationTest method testIterableNegative.

@Test
public void testIterableNegative() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/propagation/iterable-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length == 2);
    BAssertUtil.validateError(result, 0, "tainted value passed to sensitive parameter 'secureIn'", 3, 20);
    BAssertUtil.validateError(result, 1, "tainted value passed to sensitive parameter 'secureIn'", 5, 58);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Aggregations

CompileResult (org.ballerinalang.launcher.util.CompileResult)291 Test (org.testng.annotations.Test)287 BValue (org.ballerinalang.model.values.BValue)60 PackageNode (org.ballerinalang.model.tree.PackageNode)16 BLangDocumentation (org.wso2.ballerinalang.compiler.tree.BLangDocumentation)14 BString (org.ballerinalang.model.values.BString)13 BInteger (org.ballerinalang.model.values.BInteger)12 Path (java.nio.file.Path)5 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)5 File (java.io.File)4 GrpcCmd (org.ballerinalang.protobuf.cmd.GrpcCmd)4 BStringArray (org.ballerinalang.model.values.BStringArray)3 BLangDeprecatedNode (org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode)3 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)3 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)3 BFloat (org.ballerinalang.model.values.BFloat)2 BIntArray (org.ballerinalang.model.values.BIntArray)2 BMap (org.ballerinalang.model.values.BMap)2 BeforeTest (org.testng.annotations.BeforeTest)2 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)2