Skip to content

Commit 01b2ce9

Browse files
committed
Added multi-severity to the colormap test
1 parent 79c32af commit 01b2ce9

File tree

2 files changed

+179
-0
lines changed

2 files changed

+179
-0
lines changed

tests/dfd_colormap.dot

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
digraph tm {
2+
graph [
3+
fontname = Arial;
4+
fontsize = 14;
5+
]
6+
node [
7+
fontname = Arial;
8+
fontsize = 14;
9+
rankdir = lr;
10+
]
11+
edge [
12+
shape = none;
13+
arrowtail = onormal;
14+
fontname = Arial;
15+
fontsize = 12;
16+
]
17+
labelloc = "t";
18+
fontsize = 20;
19+
nodesep = 1;
20+
21+
subgraph cluster_boundary_Companynet_88f2d9c06f {
22+
graph [
23+
fontsize = 10;
24+
fontcolor = black;
25+
style = dashed;
26+
color = black;
27+
label = <<i>Company net</i>>;
28+
]
29+
30+
subgraph cluster_boundary_dmz_579e9aae81 {
31+
graph [
32+
fontsize = 10;
33+
fontcolor = black;
34+
style = dashed;
35+
color = black;
36+
label = <<i>dmz</i>>;
37+
]
38+
39+
server_Gateway_f8af758679 [
40+
shape = circle;
41+
color = firebrick3; fillcolor="#b2222222"; style=filled ;
42+
fontcolor = black;
43+
label = "Gateway";
44+
margin = 0.02;
45+
]
46+
47+
}
48+
49+
subgraph cluster_boundary_backend_f2eb7a3ff7 {
50+
graph [
51+
fontsize = 10;
52+
fontcolor = black;
53+
style = dashed;
54+
color = black;
55+
label = <<i>backend</i>>;
56+
]
57+
58+
server_WebServer_2c440ebe53 [
59+
shape = circle;
60+
color = firebrick3; fillcolor="#b2222222"; style=filled ;
61+
fontcolor = black;
62+
label = "Web Server";
63+
margin = 0.02;
64+
]
65+
66+
datastore_SQLDatabase_0291419f72 [
67+
shape = none;
68+
fixedsize = shape;
69+
image = "/Users/izar.tarandach/Src/pytm/pytm/images/datastore_gold.png";
70+
imagescale = true;
71+
color = gold; fillcolor="#ffd80022"; style=filled;
72+
fontcolor = black;
73+
xlabel = "SQL Database";
74+
label = "";
75+
]
76+
77+
}
78+
79+
}
80+
81+
subgraph cluster_boundary_Internet_acf3059e70 {
82+
graph [
83+
fontsize = 10;
84+
fontcolor = black;
85+
style = dashed;
86+
color = black;
87+
label = <<i>Internet</i>>;
88+
]
89+
90+
actor_User_d2006ce1bb [
91+
shape = square;
92+
color = darkgreen; fillcolor="#00630022"; style=filled;
93+
fontcolor = black;
94+
label = "User";
95+
margin = 0.02;
96+
]
97+
98+
}
99+
100+
actor_User_d2006ce1bb -> server_Gateway_f8af758679 [
101+
color = gold; fillcolor="#ffd80022"; style=filled;
102+
fontcolor = gold; fillcolor="#ffd80022"; style=filled;
103+
dir = forward;
104+
label = "User enters\ncomments (*)";
105+
]
106+
107+
server_Gateway_f8af758679 -> server_WebServer_2c440ebe53 [
108+
color = gold; fillcolor="#ffd80022"; style=filled;
109+
fontcolor = gold; fillcolor="#ffd80022"; style=filled;
110+
dir = forward;
111+
label = "Request";
112+
]
113+
114+
server_WebServer_2c440ebe53 -> datastore_SQLDatabase_0291419f72 [
115+
color = gold; fillcolor="#ffd80022"; style=filled;
116+
fontcolor = gold; fillcolor="#ffd80022"; style=filled;
117+
dir = forward;
118+
label = "Insert query with\ncomments";
119+
]
120+
121+
datastore_SQLDatabase_0291419f72 -> server_WebServer_2c440ebe53 [
122+
color = gold; fillcolor="#ffd80022"; style=filled;
123+
fontcolor = gold; fillcolor="#ffd80022"; style=filled;
124+
dir = forward;
125+
label = "Retrieve comments";
126+
]
127+
128+
server_WebServer_2c440ebe53 -> server_Gateway_f8af758679 [
129+
color = gold; fillcolor="#ffd80022"; style=filled;
130+
fontcolor = gold; fillcolor="#ffd80022"; style=filled;
131+
dir = forward;
132+
label = "Response";
133+
]
134+
135+
server_Gateway_f8af758679 -> actor_User_d2006ce1bb [
136+
color = gold; fillcolor="#ffd80022"; style=filled;
137+
fontcolor = gold; fillcolor="#ffd80022"; style=filled;
138+
dir = forward;
139+
label = "Show comments (*)";
140+
]
141+
142+
}

tests/test_pytmfunc.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,43 @@ def test_dfd(self):
126126
self.maxDiff = None
127127
self.assertEqual(output, expected)
128128

129+
def test_dfd_colormap(self):
130+
dir_path = os.path.dirname(os.path.realpath(__file__))
131+
install_path = os.path.dirname(os.path.realpath(pytm.__file__))
132+
133+
with open(os.path.join(dir_path, "dfd_colormap.dot")) as x:
134+
expected = (
135+
x.read().strip().replace("INSTALL_PATH", os.path.dirname(install_path))
136+
)
137+
138+
random.seed(0)
139+
140+
TM.reset()
141+
tm = TM("my test tm", description="aaa")
142+
internet = Boundary("Internet")
143+
net = Boundary("Company net")
144+
dmz = Boundary("dmz", inBoundary=net)
145+
backend = Boundary("backend", inBoundary=net)
146+
user = Actor("User", inBoundary=internet)
147+
gw = Server("Gateway", inBoundary=dmz)
148+
web = Server("Web Server", inBoundary=backend)
149+
db = Datastore("SQL Database", inBoundary=backend, isEncryptedAtRest=True)
150+
comment = Data("Comment", isStored=True)
151+
152+
Dataflow(user, gw, "User enters comments (*)")
153+
Dataflow(gw, web, "Request")
154+
Dataflow(web, db, "Insert query with comments", data=[comment])
155+
Dataflow(db, web, "Retrieve comments")
156+
Dataflow(web, gw, "Response")
157+
Dataflow(gw, user, "Show comments (*)")
158+
159+
self.assertTrue(tm.check())
160+
tm.resolve()
161+
output = tm.dfd(colormap=True)
162+
163+
self.maxDiff = None
164+
self.assertEqual(output, expected)
165+
129166
def test_dfd_duplicates_ignore(self):
130167
dir_path = os.path.dirname(os.path.realpath(__file__))
131168
install_path = os.path.dirname(os.path.realpath(pytm.__file__))

0 commit comments

Comments
 (0)