当前位置: 首页>>代码示例>>Python>>正文


Python challenges.SimpleHTTP类代码示例

本文整理汇总了Python中acme.challenges.SimpleHTTP的典型用法代码示例。如果您正苦于以下问题:Python SimpleHTTP类的具体用法?Python SimpleHTTP怎么用?Python SimpleHTTP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimpleHTTP类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SimpleHTTPTest

class SimpleHTTPTest(unittest.TestCase):

    def setUp(self):
        from acme.challenges import SimpleHTTP
        self.msg = SimpleHTTP(
            token=jose.decode_b64jose(
                'evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA'))
        self.jmsg = {
            'type': 'simpleHttp',
            'token': 'evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA',
        }

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

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

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

    def test_good_token(self):
        self.assertTrue(self.msg.good_token)
        self.assertFalse(
            self.msg.update(token=b'..').good_token)
开发者ID:fmarier,项目名称:letsencrypt,代码行数:27,代码来源:challenges_test.py

示例2: SimpleHTTPTest

class SimpleHTTPTest(unittest.TestCase):

    def setUp(self):
        from acme.challenges import SimpleHTTP
        self.msg = SimpleHTTP(
            token='evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA')
        self.jmsg = {
            'type': 'simpleHttp',
            'token': 'evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA',
            'tls': True,
        }

    def test_no_tls(self):
        from acme.challenges import SimpleHTTP
        self.assertEqual(SimpleHTTP(token='tok', tls=False).to_json(), {
            'tls': False,
            'token': 'tok',
            'type': 'simpleHttp',
        })

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

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

    def test_from_json_hashable(self):
        from acme.challenges import SimpleHTTP
        hash(SimpleHTTP.from_json(self.jmsg))
开发者ID:LlsDimple,项目名称:lets-encrypt-preview,代码行数:30,代码来源:challenges_test.py

示例3: setUp

 def setUp(self):
     from acme.challenges import SimpleHTTP
     self.msg = SimpleHTTP(
         token='evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA')
     self.jmsg = {
         'type': 'simpleHttp',
         'token': 'evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA',
     }
开发者ID:kepstin,项目名称:letsencrypt,代码行数:8,代码来源:challenges_test.py

示例4: setUp

    def setUp(self):
        from acme.challenges import SimpleHTTPResponse
        self.msg_http = SimpleHTTPResponse(tls=False)
        self.msg_https = SimpleHTTPResponse(tls=True)
        self.jmsg_http = {
            'resource': 'challenge',
            'type': 'simpleHttp',
            'tls': False,
        }
        self.jmsg_https = {
            'resource': 'challenge',
            'type': 'simpleHttp',
            'tls': True,
        }

        from acme.challenges import SimpleHTTP
        self.chall = SimpleHTTP(token=(b"x" * 16))
        self.resp_http = SimpleHTTPResponse(tls=False)
        self.resp_https = SimpleHTTPResponse(tls=True)
        self.good_headers = {'Content-Type': SimpleHTTPResponse.CONTENT_TYPE}
开发者ID:fmarier,项目名称:letsencrypt,代码行数:20,代码来源:challenges_test.py

示例5: test_from_json_hashable

 def test_from_json_hashable(self):
     from acme.challenges import SimpleHTTP
     hash(SimpleHTTP.from_json(self.jmsg))
开发者ID:kepstin,项目名称:letsencrypt,代码行数:3,代码来源:challenges_test.py

示例6: test_from_json

 def test_from_json(self):
     from acme.challenges import SimpleHTTP
     self.assertEqual(self.msg, SimpleHTTP.from_json(self.jmsg))
开发者ID:kepstin,项目名称:letsencrypt,代码行数:3,代码来源:challenges_test.py

示例7: SimpleHTTPResponseTest

class SimpleHTTPResponseTest(unittest.TestCase):
    # pylint: disable=too-many-instance-attributes

    def setUp(self):
        from acme.challenges import SimpleHTTPResponse
        self.msg_http = SimpleHTTPResponse(tls=False)
        self.msg_https = SimpleHTTPResponse(tls=True)
        self.jmsg_http = {
            'resource': 'challenge',
            'type': 'simpleHttp',
            'tls': False,
        }
        self.jmsg_https = {
            'resource': 'challenge',
            'type': 'simpleHttp',
            'tls': True,
        }

        from acme.challenges import SimpleHTTP
        self.chall = SimpleHTTP(token=(b"x" * 16))
        self.resp_http = SimpleHTTPResponse(tls=False)
        self.resp_https = SimpleHTTPResponse(tls=True)
        self.good_headers = {'Content-Type': SimpleHTTPResponse.CONTENT_TYPE}

    def test_to_partial_json(self):
        self.assertEqual(self.jmsg_http, self.msg_http.to_partial_json())
        self.assertEqual(self.jmsg_https, self.msg_https.to_partial_json())

    def test_from_json(self):
        from acme.challenges import SimpleHTTPResponse
        self.assertEqual(
            self.msg_http, SimpleHTTPResponse.from_json(self.jmsg_http))
        self.assertEqual(
            self.msg_https, SimpleHTTPResponse.from_json(self.jmsg_https))

    def test_from_json_hashable(self):
        from acme.challenges import SimpleHTTPResponse
        hash(SimpleHTTPResponse.from_json(self.jmsg_http))
        hash(SimpleHTTPResponse.from_json(self.jmsg_https))

    def test_scheme(self):
        self.assertEqual('http', self.msg_http.scheme)
        self.assertEqual('https', self.msg_https.scheme)

    def test_port(self):
        self.assertEqual(80, self.msg_http.port)
        self.assertEqual(443, self.msg_https.port)

    def test_uri(self):
        self.assertEqual(
            'http://example.com/.well-known/acme-challenge/'
            'eHh4eHh4eHh4eHh4eHh4eA', self.msg_http.uri(
                'example.com', self.chall))
        self.assertEqual(
            'https://example.com/.well-known/acme-challenge/'
            'eHh4eHh4eHh4eHh4eHh4eA', self.msg_https.uri(
                'example.com', self.chall))

    def test_gen_check_validation(self):
        account_key = jose.JWKRSA.load(test_util.load_vector('rsa512_key.pem'))
        self.assertTrue(self.resp_http.check_validation(
            validation=self.resp_http.gen_validation(self.chall, account_key),
            chall=self.chall, account_public_key=account_key.public_key()))

    def test_gen_check_validation_wrong_key(self):
        key1 = jose.JWKRSA.load(test_util.load_vector('rsa512_key.pem'))
        key2 = jose.JWKRSA.load(test_util.load_vector('rsa1024_key.pem'))
        self.assertFalse(self.resp_http.check_validation(
            validation=self.resp_http.gen_validation(self.chall, key1),
            chall=self.chall, account_public_key=key2.public_key()))

    def test_check_validation_wrong_payload(self):
        account_key = jose.JWKRSA.load(test_util.load_vector('rsa512_key.pem'))
        validations = tuple(
            jose.JWS.sign(payload=payload, alg=jose.RS256, key=account_key)
            for payload in (b'', b'{}', self.chall.json_dumps().encode('utf-8'),
                            self.resp_http.json_dumps().encode('utf-8'))
        )
        for validation in validations:
            self.assertFalse(self.resp_http.check_validation(
                validation=validation, chall=self.chall,
                account_public_key=account_key.public_key()))

    def test_check_validation_wrong_fields(self):
        resource = self.resp_http.gen_resource(self.chall)
        account_key = jose.JWKRSA.load(test_util.load_vector('rsa512_key.pem'))
        validations = tuple(
            jose.JWS.sign(payload=bad_resource.json_dumps().encode('utf-8'),
                          alg=jose.RS256, key=account_key)
            for bad_resource in (resource.update(tls=True),
                                 resource.update(token=(b'x' * 20)))
        )
        for validation in validations:
            self.assertFalse(self.resp_http.check_validation(
                validation=validation, chall=self.chall,
                account_public_key=account_key.public_key()))

    @mock.patch("acme.challenges.requests.get")
    def test_simple_verify_good_validation(self, mock_get):
        account_key = jose.JWKRSA.load(test_util.load_vector('rsa512_key.pem'))
#.........这里部分代码省略.........
开发者ID:fmarier,项目名称:letsencrypt,代码行数:101,代码来源:challenges_test.py


注:本文中的acme.challenges.SimpleHTTP类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。