forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_guidance.py
More file actions
124 lines (113 loc) · 4.41 KB
/
test_guidance.py
File metadata and controls
124 lines (113 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import pytest
import datetime
from arango import ArangoClient
from guidance import *
from test_data import *
arango_client = ArangoClient(hosts="http://testdb:8529")
# Connect to arango system DB and create test DB
sys_db = arango_client.db("_system", username="", password="")
sys_db.create_database("test")
# Establish DB connection
db = arango_client.db("test", username="", password="")
graph = db.create_graph("compliance")
def test_update_guidance():
test_guidance = []
test_guidance.append(
{"file": "scanSummaryCriteria.json", "guidance": scan_summary_criteria_data}
)
test_guidance.append(
{"file": "chartSummaryCriteria.json", "guidance": chart_summary_criteria_data}
)
test_guidance.append({"file": "tags_dkim.json", "guidance": dkim_tag_data})
test_guidance.append({"file": "tags_dmarc.json", "guidance": dmarc_tag_data})
test_guidance.append({"file": "tags_spf.json", "guidance": spf_tag_data})
test_guidance.append({"file": "tags_https.json", "guidance": https_tag_data})
test_guidance.append({"file": "tags_ssl.json", "guidance": ssl_tag_data})
test_guidance.append(
{"file": "tags_aggregate.json", "guidance": aggregate_tag_data}
)
update_guidance(
test_guidance, host="testdb", name="test", user="", password="", port=8529
)
for key, data in scan_summary_criteria_data.items():
test_criteria = {"_key": key}
for k, v in data.items():
test_criteria[k] = v
current_criteria = db.collection("scanSummaryCriteria").get({"_key": key})
assert test_criteria == {
"_key": current_criteria["_key"],
"pass": current_criteria["pass"],
"fail": current_criteria["fail"],
"info": current_criteria["info"],
"warning": current_criteria["warning"],
}
for key, data in chart_summary_criteria_data.items():
test_criteria = {"_key": key}
for k, v in data.items():
test_criteria[k] = v
current_criteria = db.collection("chartSummaryCriteria").get({"_key": key})
assert test_criteria == {
"_key": current_criteria["_key"],
"pass": current_criteria["pass"],
"fail": current_criteria["fail"],
}
for key, data in dkim_tag_data.items():
test_tag = {"_key": key}
for k, v in data.items():
test_tag[k] = v
current_tag = db.collection("dkimGuidanceTags").get({"_key": key})
assert test_tag == {
"_key": current_tag["_key"],
"en": current_tag["en"],
"fr": current_tag["fr"],
}
for key, data in dmarc_tag_data.items():
test_tag = {"_key": key}
for k, v in data.items():
test_tag[k] = v
current_tag = db.collection("dmarcGuidanceTags").get({"_key": key})
assert test_tag == {
"_key": current_tag["_key"],
"en": current_tag["en"],
"fr": current_tag["fr"],
}
for key, data in spf_tag_data.items():
test_tag = {"_key": key}
for k, v in data.items():
test_tag[k] = v
current_tag = db.collection("spfGuidanceTags").get({"_key": key})
assert test_tag == {
"_key": current_tag["_key"],
"en": current_tag["en"],
"fr": current_tag["fr"],
}
for key, data in https_tag_data.items():
test_tag = {"_key": key}
for k, v in data.items():
test_tag[k] = v
current_tag = db.collection("httpsGuidanceTags").get({"_key": key})
assert test_tag == {
"_key": current_tag["_key"],
"en": current_tag["en"],
"fr": current_tag["fr"],
}
for key, data in ssl_tag_data.items():
test_tag = {"_key": key}
for k, v in data.items():
test_tag[k] = v
current_tag = db.collection("sslGuidanceTags").get({"_key": key})
assert test_tag == {
"_key": current_tag["_key"],
"en": current_tag["en"],
"fr": current_tag["fr"],
}
for key, data in aggregate_tag_data.items():
test_tag = {"_key": key}
for k, v in data.items():
test_tag[k] = v
current_tag = db.collection("aggregateGuidanceTags").get({"_key": key})
assert test_tag == {
"_key": current_tag["_key"],
"en": current_tag["en"],
"fr": current_tag["fr"],
}