Ejemplo n.º 1
0
    def test_sign_node_assertion(self):
        # Test that an assertion error is thrown when a node is passed
        # that does not have a Signingkey
        # create SignedObject
        temp = SignedObject({"TestSignatureDictKey": "test"}, "TestSignatureDictKey")
        # create a Node that does not have a signingKey
        testNode = Node(name="badNode")
        try:
            # should throw an an assertion error, Otherwise fail test
            temp.sign_from_node(testNode)
            self.fail("Should have raised an Assertion Error")

        except AssertionError, e:
            self.assertIsInstance(e, AssertionError)
    def test_sign_node_assertion(self):
        # Test that an assertion error is thrown when a node is passed
        # that does not have a Signingkey
        # create SignedObject
        signkey = SigObj.generate_signing_key()
        temp = SignedObject({signkey: "test"}, signkey)
        # create a Node that does not have a signingKey
        testNode = Node(name="badNode")
        try:
            # should throw an an assertion error, Otherwise fail test
            temp.sign_from_node(testNode)
            self.fail("Should have raised an Assertion Error")

        except AssertionError, e:
            self.assertIsInstance(e, AssertionError)
Ejemplo n.º 3
0
    def test_signed_node(self):
        # Verify that signed_node and sign_object does not invalidate the
        # signed object and can be returned to original
        # create initial signed object
        temp = SignedObject({"TestSignatureDictKey": "test"}, "TestSignatureDictKey")
        # save origanl OriginatorID before creating node
        idBeforeNode = temp.OriginatorID

        # create a node instance
        key = generate_private_key()
        sigkey = SigObj.generate_signing_key(wifstr=key)
        nodeid = SigObj.generate_identifier(sigkey)
        testNode = Node(name="testNode", signingkey=sigkey, identifier=nodeid)

        temp.sign_from_node(testNode)
        # save new OriginatorID after the
        idAfterNode = temp.OriginatorID

        self.assertNotEqual(idAfterNode, idBeforeNode)
        # check that the signed_object signature is still valid and reset
        # OrignatorId back to original
        self.assertTrue(temp.is_valid("unused parameter"))
        self.assertNotEqual(temp.OriginatorID, idBeforeNode)
    def test_signed_node(self):
        # Verify that signed_node and sign_object does not invalidate the
        # signed object and can be returned to original
        # create initial signed object
        signkey = SigObj.generate_signing_key()
        temp = SignedObject({signkey: "test"}, signkey)
        # save origanl OriginatorID before creating node
        idBeforeNode = temp.OriginatorID

        # create a node instance
        key = generate_private_key()
        sigkey = SigObj.generate_signing_key(wifstr=key)
        nodeid = SigObj.generate_identifier(sigkey)
        testNode = Node(name="testNode", signingkey=sigkey, identifier=nodeid)

        temp.sign_from_node(testNode)
        # save new OriginatorID after the
        idAfterNode = temp.OriginatorID

        self.assertNotEqual(idAfterNode, idBeforeNode)
        # check that the signed_object signature is still valid and reset
        # OrignatorId back to original
        self.assertTrue(temp.is_valid("unused parameter"))
        self.assertNotEqual(temp.OriginatorID, idBeforeNode)