Mercurial > farol > farolluz
annotate tests/testProductIdRename.py @ 23:2ee8fcfc99bc
OVAL: Replace one SecPod with Farol
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Fri, 24 Oct 2014 16:42:19 +0200 |
parents | 4004b67216a9 |
children | e3ee542a89be |
rev | line source |
---|---|
22
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
1 import unittest |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
2 |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
3 from datetime import datetime |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
4 |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
5 from farolluz.cvrf import CVRF, CVRFPublisher, CVRFTracking, CVRFTrackingID, CVRFRevision, CVRFFullProductName, CVRFVulnerability, CVRFProductStatus, CVRFRelationship |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
6 |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
7 class TestProductIdRename(unittest.TestCase): |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
8 |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
9 def setUp(self): |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
10 self.doc = CVRF('title', 'type') |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
11 self.doc.setPublisher(CVRFPublisher('Other')) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
12 initial = datetime.now() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
13 current = datetime.now() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
14 track = CVRFTracking(CVRFTrackingID('1234'), 'Draft', (0,0), initial, current) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
15 track.addRevision(CVRFRevision((0,0), current, '1st')) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
16 self.doc.setTracking(track) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
17 self.doc.validate() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
18 |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
19 |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
20 def testChangeProductId(self): |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
21 ptree = self.doc.createProductTree() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
22 prod = CVRFFullProductName('1', 'a', ptree) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
23 ptree.addProduct(prod) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
24 vuln = CVRFVulnerability(1) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
25 st = CVRFProductStatus('Fixed') |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
26 st.addProductID('1') |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
27 vuln.addProductStatus(st) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
28 self.doc.addVulnerability(vuln) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
29 self.doc.validate() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
30 prod._productid = '2' |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
31 self.doc.changeProductID('1', '2') |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
32 self.doc.validate() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
33 |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
34 def testChangeProductIdRelation(self): |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
35 ptree = self.doc.createProductTree() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
36 prod1 = CVRFFullProductName('1', 'a', ptree) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
37 ptree.addProduct(prod1) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
38 prod2 = CVRFFullProductName('2', 'b', ptree) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
39 ptree.addProduct(prod2) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
40 rel = CVRFRelationship('1', 'Installed On', '2') |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
41 ptree.addRelationship(rel) |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
42 self.doc.validate() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
43 prod1._productid = '3' |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
44 self.doc.changeProductID('1', '3') |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
45 self.doc.validate() |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
46 prod2._productid = '1' |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
47 self.doc.changeProductID('2', '1') |
4004b67216a9
Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
48 self.doc.validate() |