def testEncryptedPython(self): phrase = 'once I was the king of spain' f = open("epersisttest.python", 'w') f.write(sob._encrypt(phrase, 'foo=[1,2,3]')) f.close() o = sob.loadValueFromFile('epersisttest.python', 'foo', phrase) self.assertEqual(o, [1, 2, 3])
def testEncryptedPython(self): phrase='once I was the king of spain' f = open("epersisttest.python", 'w') f.write( sob._encrypt(phrase, 'foo=[1,2,3]')) f.close() o = sob.loadValueFromFile('epersisttest.python', 'foo', phrase) self.failUnlessEqual(o, [1,2,3])
def testEncryptedPython(self): try: import Crypto except ImportError: raise unittest.SkipTest() phrase='once I was the king of spain' open("epersisttest.python", 'w').write( sob._encrypt(phrase, 'foo=[1,2,3]')) o = sob.loadValueFromFile('epersisttest.python', 'foo', phrase) self.failUnlessEqual(o, [1,2,3])
def test_loadValueFromFileEncryptedPython(self): """ Encrypted Python data can be loaded from a file. """ phrase = b'once I was the king of spain' with open("epersisttest.python", 'wb') as f: f.write(sob._encrypt(phrase, b'foo=[1,2,3]')) o = sob.loadValueFromFile('epersisttest.python', 'foo', phrase) self.assertEqual(o, [1,2,3]) self.flushWarnings([ sob.loadValueFromFile, self.test_loadValueFromFileEncryptedPython])
def test_loadValueFromFileEncryptedPython(self): """ Encrypted Python data can be loaded from a file. """ phrase = b'once I was the king of spain' with open("epersisttest.python", 'wb') as f: f.write(sob._encrypt(phrase, b'outputFile=[1,2,3]')) o = sob.loadValueFromFile('epersisttest.python', 'outputFile', phrase) self.assertEqual(o, [1, 2, 3]) self.flushWarnings([ sob.loadValueFromFile, self.test_loadValueFromFileEncryptedPython ])
def test_loadValueFromFileEncryptedDeprecation(self): """ Loading encrypted persisted data is deprecated. """ tempDir = FilePath(self.mktemp()) tempDir.makedirs() persistedPath = tempDir.child('epersisttest.python') persistedPath.setContent(sob._encrypt(b'some-pass', b'foo=[1,2,3]')) # Clean all previous warnings as _encpryt will also raise a warning. self.flushWarnings([self.test_loadValueFromFileEncryptedDeprecation]) loadedData = sob.loadValueFromFile(persistedPath.path, 'foo', b'some-pass') self.assertEqual([1, 2, 3], loadedData) warnings = self.flushWarnings([sob.loadValueFromFile]) self.assertEqual(1, len(warnings)) self.assertIs(DeprecationWarning, warnings[0]['category']) self.assertEqual( 'Loading encrypted persisted data is deprecated since ' 'Twisted 15.5.0', warnings[0]['message'])
def test_loadValueFromFileEncryptedDeprecation(self): """ Loading encrypted persisted data is deprecated. """ tempDir = FilePath(self.mktemp()) tempDir.makedirs() persistedPath = tempDir.child('epersisttest.python') persistedPath.setContent(sob._encrypt(b'some-pass', b'foo=[1,2,3]')) # Clean all previous warnings as _encpryt will also raise a warning. self.flushWarnings([ self.test_loadValueFromFileEncryptedDeprecation]) loadedData = sob.loadValueFromFile( persistedPath.path, 'foo', b'some-pass') self.assertEqual([1, 2, 3], loadedData) warnings = self.flushWarnings([sob.loadValueFromFile]) self.assertEqual(1, len(warnings)) self.assertIs(DeprecationWarning, warnings[0]['category']) self.assertEqual( 'Loading encrypted persisted data is deprecated since ' 'Twisted 15.5.0', warnings[0]['message'])
def testEncryptedPython(self): phrase = b'once I was the king of spain' with open("epersisttest.python", 'wb') as f: f.write(sob._encrypt(phrase, b'foo=[1,2,3]')) o = sob.loadValueFromFile('epersisttest.python', 'foo', phrase) self.assertEqual(o, [1, 2, 3])
def testEncryptedPython(self): phrase = b"once I was the king of spain" with open("epersisttest.python", "wb") as f: f.write(sob._encrypt(phrase, b"foo=[1,2,3]")) o = sob.loadValueFromFile("epersisttest.python", "foo", phrase) self.assertEqual(o, [1, 2, 3])