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


Python DVSNI.gen_response方法代碼示例

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


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

示例1: DVSNITest

# 需要導入模塊: from acme.challenges import DVSNI [as 別名]
# 或者: from acme.challenges.DVSNI import gen_response [as 別名]
class DVSNITest(unittest.TestCase):

    def setUp(self):
        from acme.challenges import DVSNI
        self.msg = DVSNI(
            token=jose.b64decode('a82d5ff8ef740d12881f6d3c2277ab2e'))
        self.jmsg = {
            'type': 'dvsni',
            'token': 'a82d5ff8ef740d12881f6d3c2277ab2e',
        }

    def test_to_partial_json(self):
        self.assertEqual(self.jmsg, self.msg.to_partial_json())

    def test_from_json(self):
        from acme.challenges import DVSNI
        self.assertEqual(self.msg, DVSNI.from_json(self.jmsg))

    def test_from_json_hashable(self):
        from acme.challenges import DVSNI
        hash(DVSNI.from_json(self.jmsg))

    def test_from_json_invalid_token_length(self):
        from acme.challenges import DVSNI
        self.jmsg['token'] = jose.encode_b64jose(b'abcd')
        self.assertRaises(
            jose.DeserializationError, DVSNI.from_json, self.jmsg)

    def test_gen_response(self):
        key = jose.JWKRSA(key=KEY)
        from acme.challenges import DVSNI
        self.assertEqual(self.msg, DVSNI.json_loads(
            self.msg.gen_response(key).validation.payload.decode()))
開發者ID:fmarier,項目名稱:letsencrypt,代碼行數:35,代碼來源:challenges_test.py


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