This file is indexed.

/usr/lib/python2.7/dist-packages/keyring/tests/backends/test_keyczar.py is in python-keyring 7.3-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import unittest

from keyring.backends import keyczar
from .. import mocks

def is_keyczar_supported():
    return hasattr(keyczar, 'keyczar')

@unittest.skipUnless(is_keyczar_supported(),
                     "Need Keyczar")
class KeyczarCrypterTestCase(unittest.TestCase):

    """Test the keyczar crypter"""

    def setUp(self):
        self._orig_keyczar = keyczar.keyczar
        keyczar.keyczar = mocks.MockKeyczar()

    def tearDown(self):
        keyczar.keyczar = self._orig_keyczar
        if keyczar.EnvironCrypter.KEYSET_ENV_VAR in os.environ:
            del os.environ[keyczar.EnvironCrypter.KEYSET_ENV_VAR]
        if keyczar.EnvironCrypter.ENC_KEYSET_ENV_VAR in os.environ:
            del os.environ[keyczar.EnvironCrypter.ENC_KEYSET_ENV_VAR]

    def testKeyczarCrypterWithUnencryptedReader(self):
        """
        """
        location = 'bar://baz'
        kz_crypter = keyczar.Crypter(location)
        self.assertEquals(location, kz_crypter.keyset_location)
        self.assertIsNone(kz_crypter.encrypting_keyset_location)
        self.assertIsInstance(kz_crypter.crypter, mocks.MockKeyczarCrypter)
        self.assertIsInstance(kz_crypter.crypter.reader, mocks.MockKeyczarReader)
        self.assertEquals(location, kz_crypter.crypter.reader.location)

    def testKeyczarCrypterWithEncryptedReader(self):
        """
        """
        location = 'foo://baz'
        encrypting_location = 'castle://aaargh'
        kz_crypter = keyczar.Crypter(location, encrypting_location)
        self.assertEquals(location, kz_crypter.keyset_location)
        self.assertEquals(encrypting_location,
                          kz_crypter.encrypting_keyset_location)
        self.assertIsInstance(kz_crypter.crypter, mocks.MockKeyczarCrypter)
        self.assertIsInstance(kz_crypter.crypter.reader,
                              mocks.MockKeyczarEncryptedReader)
        self.assertEquals(location, kz_crypter.crypter.reader._reader.location)
        self.assertEquals(encrypting_location,
                          kz_crypter.crypter.reader._crypter.reader.location)

    def testKeyczarCrypterEncryptDecryptHandlesEmptyNone(self):
        location = 'castle://aargh'
        kz_crypter = keyczar.Crypter(location)
        self.assertEquals('', kz_crypter.encrypt(''))
        self.assertEquals('', kz_crypter.encrypt(None))
        self.assertEquals('', kz_crypter.decrypt(''))
        self.assertEquals('', kz_crypter.decrypt(None))

    def testEnvironCrypterReadsCorrectValues(self):
        location = 'foo://baz'
        encrypting_location = 'castle://aaargh'
        kz_crypter = keyczar.EnvironCrypter()
        os.environ[kz_crypter.KEYSET_ENV_VAR] = location
        self.assertEqual(location, kz_crypter.keyset_location)
        self.assertIsNone(kz_crypter.encrypting_keyset_location)
        os.environ[kz_crypter.ENC_KEYSET_ENV_VAR] = encrypting_location
        self.assertEqual(encrypting_location, kz_crypter.encrypting_keyset_location)

    def testEnvironCrypterThrowsExceptionOnMissingValues(self):
        kz_crypter = keyczar.EnvironCrypter()
        with self.assertRaises(ValueError):
            kz_crypter.keyset_location
        self.assertIsNone(kz_crypter.encrypting_keyset_location)