def test_02_no_handlers(self):
        "test no handlers"

        #check constructor...
        cc = CryptContext()
        self.assertRaises(KeyError, cc.identify, 'hash', required=True)
        self.assertRaises(KeyError, cc.encrypt, 'secret')
        self.assertRaises(KeyError, cc.verify, 'secret', 'hash')

        #check updating policy after the fact...
        cc = CryptContext(['md5_crypt'])
        p = CryptPolicy(schemes=[])
        cc.policy = p

        self.assertRaises(KeyError, cc.identify, 'hash', required=True)
        self.assertRaises(KeyError, cc.encrypt, 'secret')
        self.assertRaises(KeyError, cc.verify, 'secret', 'hash')
Esempio n. 2
0
    def test_02_no_handlers(self):
        "test no handlers"

        # check constructor...
        cc = CryptContext()
        self.assertRaises(KeyError, cc.identify, 'hash', required=True)
        self.assertRaises(KeyError, cc.encrypt, 'secret')
        self.assertRaises(KeyError, cc.verify, 'secret', 'hash')

        # check updating policy after the fact...
        cc = CryptContext(['md5_crypt'])
        p = CryptPolicy(schemes=[])
        cc.policy = p

        self.assertRaises(KeyError, cc.identify, 'hash', required=True)
        self.assertRaises(KeyError, cc.encrypt, 'secret')
        self.assertRaises(KeyError, cc.verify, 'secret', 'hash')
    def test_02_no_handlers(self):
        """test no handlers"""

        # check constructor...
        cc = CryptContext()
        self.assertRaises(KeyError, cc.identify, "hash", required=True)
        self.assertRaises(KeyError, cc.hash, "secret")
        self.assertRaises(KeyError, cc.verify, "secret", "hash")

        # check updating policy after the fact...
        cc = CryptContext(["md5_crypt"])
        p = CryptPolicy(schemes=[])
        cc.policy = p

        self.assertRaises(KeyError, cc.identify, "hash", required=True)
        self.assertRaises(KeyError, cc.hash, "secret")
        self.assertRaises(KeyError, cc.verify, "secret", "hash")