def test_make_key(self): storage = StorageFactory().get_storage() key1 = storage.randomize_key(16) for loop_index in range(32): key_n = storage.randomize_key(16) assert key_n == key1
def test_retrieve_nofile(self): storage = StorageFactory().get_storage() data = ['*****@*****.**', 'mYsEcret007'] storage.store(data) os.remove(storage.get_filename()) assert_raises(IOError, storage.retrieve)
def test_retrieve_raw(self): storage = StorageFactory(kind='basic').get_storage() data = [ '*****@*****.**', 'mYsEcret007'] storage.store(data) read_data = storage.retrieve() assert data[0] in read_data[0] assert data[1] in read_data[1]
def test_retrieve_corrupted_noIV(self): storage = StorageFactory().get_storage() data = ['*****@*****.**', 'mYsEcret007'] storage.store(data) with open(storage.get_filename(), 'wb') as container: container.write("Junk") assert_raises(ValueError, storage.retrieve)
def test_retrieve_tuple(self): storage = StorageFactory().get_storage() data = ('*****@*****.**', 'mYsEcret007') storage.store(data) read_data = storage.retrieve() assert len(read_data) == 2 assert data[0] in read_data[0] assert data[1] in read_data[1]
def test_store_raw(self): storage = StorageFactory(kind='basic').get_storage() data = [ '*****@*****.**', 'mYsEcret007'] storage.store(data) with open(storage.get_filename(), 'rb') as store: lines = store.readlines() assert data[0] in lines[1] assert data[1] in lines[3]
def test_store(self): storage = StorageFactory().get_storage() data = ['*****@*****.**', 'mYsEcret007'] storage.store(data) filename = storage.get_filename() st = os.stat(filename) print S_IMODE(st.st_mode) assert S_IMODE(st.st_mode) == 0o600 with open(filename, 'rb') as store: lines = store.readlines() for line in lines: assert data[0] not in line assert data[1] not in line