當前位置: 首頁>>代碼示例>>Python>>正文


Python Cryptor._import_keys方法代碼示例

本文整理匯總了Python中passpie.crypt.Cryptor._import_keys方法的典型用法代碼示例。如果您正苦於以下問題:Python Cryptor._import_keys方法的具體用法?Python Cryptor._import_keys怎麽用?Python Cryptor._import_keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在passpie.crypt.Cryptor的用法示例。


在下文中一共展示了Cryptor._import_keys方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_import_keys_opens_keys_path_and_import_to_gpg

# 需要導入模塊: from passpie.crypt import Cryptor [as 別名]
# 或者: from passpie.crypt.Cryptor import _import_keys [as 別名]
    def test_import_keys_opens_keys_path_and_import_to_gpg(self):
        to_patch = 'passpie.crypt.open'
        mock_open = self.patch(to_patch, self.mock_open(), create=True)
        mock_open().read.return_value = "key data"

        cryptor = Cryptor("path/to/database")
        cryptor._import_keys()
        cryptor._gpg.import_keys.assert_called_once_with(
            mock_open().read()
        )
開發者ID:UtahDave,項目名稱:passpie,代碼行數:12,代碼來源:test_crypt.py

示例2: test_import_keys_raises_file_not_found_when_keys_not_found

# 需要導入模塊: from passpie.crypt import Cryptor [as 別名]
# 或者: from passpie.crypt.Cryptor import _import_keys [as 別名]
    def test_import_keys_raises_file_not_found_when_keys_not_found(self):
        to_patch = 'passpie.crypt.open'
        mock_open = self.patch(to_patch, self.mock_open(), create=True)
        cryptor = Cryptor("path/to/database")

        mock_open.side_effect = OSError(2, "File Not Found")
        with self.assertRaises(FileNotFoundError):
            cryptor._import_keys()

        mock_open.side_effect = OSError(17, "File exists")
        try:
            cryptor._import_keys()
        except Exception as exc:
            self.assertNotIsInstance(exc, FileNotFoundError)
開發者ID:UtahDave,項目名稱:passpie,代碼行數:16,代碼來源:test_crypt.py

示例3: test_encrypt_returns_gpg_encrypted_data

# 需要導入模塊: from passpie.crypt import Cryptor [as 別名]
# 或者: from passpie.crypt.Cryptor import _import_keys [as 別名]
    def test_encrypt_returns_gpg_encrypted_data(self):
        cryptor = Cryptor("path/to/database")
        cryptor._import_keys = self.Mock()
        encrypted = "encrypted data"
        cryptor._gpg.encrypt.return_value = self.Mock(data=encrypted)

        self.assertEqual(cryptor.encrypt("data"), str(encrypted))
開發者ID:UtahDave,項目名稱:passpie,代碼行數:9,代碼來源:test_crypt.py

示例4: test_decrypt_returns_gpg_decrypted_data

# 需要導入模塊: from passpie.crypt import Cryptor [as 別名]
# 或者: from passpie.crypt.Cryptor import _import_keys [as 別名]
    def test_decrypt_returns_gpg_decrypted_data(self):
        cryptor = Cryptor("path/to/database")
        cryptor._import_keys = self.Mock()
        decrypted = "decrypted data"
        cryptor._gpg.decrypt.return_value = self.Mock(data=decrypted)

        self.assertEqual(cryptor.decrypt("data", "passphrase"), str(decrypted))
開發者ID:UtahDave,項目名稱:passpie,代碼行數:9,代碼來源:test_crypt.py

示例5: test_passprase_check_with_ensure_raises_value_error_with_ensure

# 需要導入模塊: from passpie.crypt import Cryptor [as 別名]
# 或者: from passpie.crypt.Cryptor import _import_keys [as 別名]
    def test_passprase_check_with_ensure_raises_value_error_with_ensure(self):
        cryptor = Cryptor("path/to/database")
        cryptor._import_keys = self.Mock()
        cryptor._gpg.sign.return_value = None
        passphrase = "passphrase"

        with self.assertRaises(ValueError):
            cryptor.check(passphrase, ensure=True)
開發者ID:UtahDave,項目名稱:passpie,代碼行數:10,代碼來源:test_crypt.py

示例6: test_passphrase_check_raises_value_error_when_bad_passphrase

# 需要導入模塊: from passpie.crypt import Cryptor [as 別名]
# 或者: from passpie.crypt.Cryptor import _import_keys [as 別名]
    def test_passphrase_check_raises_value_error_when_bad_passphrase(self):
        cryptor = Cryptor("path/to/database")
        cryptor._import_keys = self.Mock()
        passphrase = "passphrase"
        result = cryptor.check(passphrase)

        self.assertTrue(result)
        self.assertTrue(cryptor._gpg.sign.called)
        cryptor._gpg.sign.assert_called_once_with(
            "testing",
            default_key=cryptor.current_key,
            passphrase=passphrase
        )
開發者ID:UtahDave,項目名稱:passpie,代碼行數:15,代碼來源:test_crypt.py


注:本文中的passpie.crypt.Cryptor._import_keys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。