Commit 4addd9e3 authored by Paff's avatar Paff
Browse files

test trustlevel after transformation

parent e55b8041
...@@ -3,11 +3,15 @@ package secarc; ...@@ -3,11 +3,15 @@ package secarc;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import interfaces2.namespaces.NameSpace; import interfaces2.namespaces.NameSpace;
import interfaces2.resolvers.AmbigousException; import interfaces2.resolvers.AmbigousException;
import mc.MCG; import mc.MCG;
import mc.ast.ASTNode; import mc.ast.ASTNode;
import mc.ast.InheritanceVisitor;
import mc.umlp.arcd._ast.ASTArcComponent; import mc.umlp.arcd._ast.ASTArcComponent;
import mc.umlp.arcd.ets.entries.ComponentEntry; import mc.umlp.arcd.ets.entries.ComponentEntry;
...@@ -15,6 +19,7 @@ import org.junit.Test; ...@@ -15,6 +19,7 @@ import org.junit.Test;
import secarc._tool.MontiSecArcRoot; import secarc._tool.MontiSecArcRoot;
import secarc.ets.entries.SecComponentEntry; import secarc.ets.entries.SecComponentEntry;
import secarc.ets.transform.trustlevel.AnalysisTrustlevelTransformationVisitor;
public class MontiSecArcAnalysisTransformationTrustlevelTest extends TestWithSymtabAnalysis<MontiSecArcAnalysisTestTool> { public class MontiSecArcAnalysisTransformationTrustlevelTest extends TestWithSymtabAnalysis<MontiSecArcAnalysisTestTool> {
...@@ -59,6 +64,51 @@ public class MontiSecArcAnalysisTransformationTrustlevelTest extends TestWithSym ...@@ -59,6 +64,51 @@ public class MontiSecArcAnalysisTransformationTrustlevelTest extends TestWithSym
assertEquals(9, handler.getWarnings().size()); assertEquals(9, handler.getWarnings().size());
} }
/**
* Test if parameter exists
*/
@Test
public void testTranformationWithParameterExistence() {
//First file
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" });
tool.init();
assertTrue(tool.run());
MontiSecArcRoot root = (MontiSecArcRoot) initSymtabForRoot(tool, "secarc.analysis.connector.EncryptedPathEndInLowTrustlevel");
//Transform entries
AnalysisTrustlevelTransformationVisitor visitor = new AnalysisTrustlevelTransformationVisitor(root);
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(4, handler.getWarnings().size());
}
/** /**
* Test if parameter do not exist * Test if parameter do not exist
*/ */
......
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