view 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
line wrap: on
line source
import unittest

from datetime import datetime

from farolluz.cvrf import CVRF, CVRFPublisher, CVRFTracking, CVRFTrackingID, CVRFRevision, CVRFFullProductName, CVRFVulnerability, CVRFProductStatus, CVRFRelationship

class TestProductIdRename(unittest.TestCase):

    def setUp(self):
        self.doc = CVRF('title', 'type')
        self.doc.setPublisher(CVRFPublisher('Other'))
        initial = datetime.now()
        current = datetime.now()
        track = CVRFTracking(CVRFTrackingID('1234'), 'Draft', (0,0), initial, current)
        track.addRevision(CVRFRevision((0,0), current, '1st'))
        self.doc.setTracking(track)
        self.doc.validate()


    def testChangeProductId(self):
        ptree = self.doc.createProductTree()
        prod = CVRFFullProductName('1', 'a', ptree)
        ptree.addProduct(prod)
        vuln = CVRFVulnerability(1)
        st = CVRFProductStatus('Fixed')
        st.addProductID('1')
        vuln.addProductStatus(st)
        self.doc.addVulnerability(vuln)
        self.doc.validate()
        prod._productid = '2'
        self.doc.changeProductID('1', '2')
        self.doc.validate()

    def testChangeProductIdRelation(self):
        ptree = self.doc.createProductTree()
        prod1 = CVRFFullProductName('1', 'a', ptree)
        ptree.addProduct(prod1)
        prod2 = CVRFFullProductName('2', 'b', ptree)
        ptree.addProduct(prod2)
        rel = CVRFRelationship('1', 'Installed On', '2')
        ptree.addRelationship(rel)
        self.doc.validate()
        prod1._productid = '3'
        self.doc.changeProductID('1', '3')
        self.doc.validate()
        prod2._productid = '1'
        self.doc.changeProductID('2', '1')
        self.doc.validate()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)