Example #1
0
class TestRsa(unittest.TestCase):
    def setUp(self):
        self.randText = ''.join([random.choice(string.letters) for i in range(10)])

        pubPath = os.path.join(basePath, 'config', 'test_key.pub')
        privPath = os.path.join(basePath, 'config', 'test_key')

        if not os.path.isfile(pubPath) or not os.path.isfile(privPath):
            raise SkipTest('could not access RSA keypair in config folder')

        self.rsa = Rsa()

        # set some parameters
        for e in self.rsa.params['sending']:
            if e.name == 'publicKey':
                e.value = pubPath

        for e in self.rsa.params['receiving']:
            if e.name == 'privateKey':
                e.value = privPath

    def test_encode(self):
        encoded = self.rsa.encode(self.randText)
        decoded = self.rsa.decode(encoded)
        self.assertEqual(decoded, self.randText)
Example #2
0
    def setUp(self):
        self.randText = ''.join([random.choice(string.letters) for i in range(10)])

        pubPath = os.path.join(basePath, 'config', 'test_key.pub')
        privPath = os.path.join(basePath, 'config', 'test_key')

        if not os.path.isfile(pubPath) or not os.path.isfile(privPath):
            raise SkipTest('could not access RSA keypair in config folder')

        self.rsa = Rsa()
        self.rsa.params['encode']['publicKey'] = pubPath

        self.rsa.params['decode']['privateKey'] = privPath
Example #3
0
    def setUp(self):
        self.randText = ''.join(
            [random.choice(string.letters) for i in range(10)])

        pubPath = os.path.join(basePath, 'config', 'test_key.pub')
        privPath = os.path.join(basePath, 'config', 'test_key')

        if not os.path.isfile(pubPath) or not os.path.isfile(privPath):
            raise SkipTest('could not access RSA keypair in config folder')

        self.rsa = Rsa()

        # set some parameters
        for e in self.rsa.params['sending']:
            if e.name == 'publicKey':
                e.value = pubPath

        for e in self.rsa.params['receiving']:
            if e.name == 'privateKey':
                e.value = privPath