Commit 192459bb authored by Paff's avatar Paff
Browse files

transformation test coverage > 80

parent d1f75f28
......@@ -242,7 +242,7 @@ public class MontiSecArcAnalysisVisitor extends CheckWorkflowClient {
}
//Check if analysis parameter existiert
if(analysisParameter != null) {
if(analysisParameter != null) {
for(String parameter : analysisParameter) {
try {
for (ISecAnalysisParameterChecker cc : analysisParameterChecker) {
......
......@@ -12,7 +12,6 @@ import java.util.Map;
import org.jgrapht.traverse.DepthFirstIterator;
import org.jgrapht.traverse.GraphIterator;
import secarc._tool.MontiSecArcRoot;
import secarc.ets.analysis.checker.AnalysisHelper;
import secarc.ets.entries.SecComponentEntry;
import secarc.ets.entries.SecPortEntry;
......
......@@ -65,11 +65,43 @@ public class MontiSecArcAnalysisTransformationTrustlevelTest extends TestWithSym
}
/**
* Test if parameter exists
* Test if parameter exists with not existing trustlevel
*/
@Test
public void testTranformationWithParameterExistence() {
//First file
public void testParameterExistenceNotExistingTrustlevel() {
//First file with existing trustlevel
System.out.println("DerivedTrustlevel.secarc");
String parameter = "secarc.analysis.trustlevel.DerivedTrustlevel.Help";
MontiSecArcAnalysisTestTool tool = createTestToolWithoutJavaWhatIfTrustlevel(new String[] { "src/test/resources/secarc/analysis/trustlevel/DerivedTrustlevel.secarc" }, parameter);
tool.init();
assertTrue(tool.run());
MontiSecArcRoot root = (MontiSecArcRoot) initSymtabForRoot(tool, "secarc.analysis.trustlevel.DerivedTrustlevel");
ComponentEntry entry = null;
for(ASTNode child : root.getAst().get_Children()) {
if(child instanceof ASTArcComponent) {
try {
entry = existComponent(parameter, getNameSpaceFor(child));
break;
} catch (AmbigousException e) {
// not checked here
MCG.getLogger().info(e.getMessage());
}
}
}
if(entry != null) {
assertEquals(false, ((SecComponentEntry) entry).getTrustlevel().isPresent());
}
assertEquals(4, handler.getWarnings().size());
}
/**
* Test if parameter exists with existing trustelvel
*/
@Test
public void testTranformationWithParameterExistenceExistingTrustlevel() {
//First file with existing trustlevel
System.out.println("EncryptedPathEndInLowTrustlevel.secarc");
String parameter = "secarc.analysis.connector.EncryptedPathEndInLowTrustlevel.TargetHelp";
MontiSecArcAnalysisTestTool tool = createTestToolWithoutJava(new String[] { "src/test/resources/secarc/analysis/connector/EncryptedPathEndInLowTrustlevel.secarc" });
......@@ -109,6 +141,51 @@ public class MontiSecArcAnalysisTransformationTrustlevelTest extends TestWithSym
assertEquals(5, handler.getWarnings().size());
}
/**
* Test if parameter exists with existing trustelvel which does not exist
*/
@Test
public void testTranformationWithParameterExistenceNotExistingTrustlevel() {
//First file with existing trustlevel
System.out.println("DerivedTrustlevel.secarc");
String parameter = "secarc.analysis.trustlevel.DerivedTrustlevel.Help";
MontiSecArcAnalysisTestTool tool = createTestToolWithoutJava(new String[] { "src/test/resources/secarc/analysis/trustlevel/DerivedTrustlevel.secarc" });
tool.init();
assertTrue(tool.run());
MontiSecArcRoot root = (MontiSecArcRoot) initSymtabForRoot(tool, "secarc.analysis.trustlevel.DerivedTrustlevel");
//Transform entries
AnalysisTrustlevelTransformationVisitor visitor = new AnalysisTrustlevelTransformationVisitor();
List<String> parameters = new ArrayList<String>();
parameters.add(parameter);
visitor.setAnalysisParameter(parameters);
visitor.setResolver(resolver);
visitor.setNodesToNameSpaces(nodesToNameSpaces);
visitor.isReverse(false);
InheritanceVisitor.run(visitor, root.getAst());
ComponentEntry entry = null;
for(ASTNode child : root.getAst().get_Children()) {
if(child instanceof ASTArcComponent) {
try {
entry = existComponent(parameter, getNameSpaceFor(child));
break;
} catch (AmbigousException e) {
// not checked here
MCG.getLogger().info(e.getMessage());
}
}
}
if(entry != null) {
assertEquals(true, ((SecComponentEntry) entry).getTrustlevel().isPresent());
assertEquals(1, ((SecComponentEntry) entry).getTrustlevel().get().getValue());
assertEquals(false, ((SecComponentEntry) entry).getTrustlevel().get().isPositive());
}
assertEquals(2, handler.getWarnings().size());
}
/**
* Test if parameter do not exist
*/
......@@ -131,7 +208,7 @@ public class MontiSecArcAnalysisTransformationTrustlevelTest extends TestWithSym
} catch (AmbigousException e) {
// not checked here
MCG.getLogger().info(e.getMessage());
}
}
}
}
assertEquals(null, entry);
......
......@@ -10,7 +10,6 @@ import mc.ProblemReport;
import org.junit.Test;
import secarc.error.MontiSecArcAnalysisErrorCodes;
import secarc.ets.check.MontiSecArcContextConditionConstants;
public class MontiSecArcAnalysisWhatIfTrustlevelTest extends TestWithSymtabAnalysis<MontiSecArcAnalysisTestTool> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment