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


Python obj.Addr类代码示例

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


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

示例1: test_contains_list

 def test_contains_list(self):
     from certbot_nginx.obj import VirtualHost
     from certbot_nginx.obj import Addr
     from certbot_nginx.configurator import TEST_REDIRECT_BLOCK
     test_needle = TEST_REDIRECT_BLOCK
     test_haystack = [['listen', '80'], ['root', '/var/www/html'],
         ['index', 'index.html index.htm index.nginx-debian.html'],
         ['server_name', 'two.functorkitten.xyz'], ['listen', '443 ssl'],
         ['#', ' managed by Certbot'],
         ['ssl_certificate', '/etc/letsencrypt/live/two.functorkitten.xyz/fullchain.pem'],
         ['#', ' managed by Certbot'],
         ['ssl_certificate_key', '/etc/letsencrypt/live/two.functorkitten.xyz/privkey.pem'],
         ['#', ' managed by Certbot'],
         [['if', '($scheme != "https")'], [['return', '301 https://$host$request_uri']]],
         ['#', ' managed by Certbot'], []]
     vhost_haystack = VirtualHost(
         "filp",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), test_haystack, [])
     test_bad_haystack = [['listen', '80'], ['root', '/var/www/html'],
         ['index', 'index.html index.htm index.nginx-debian.html'],
         ['server_name', 'two.functorkitten.xyz'], ['listen', '443 ssl'],
         ['#', ' managed by Certbot'],
         ['ssl_certificate', '/etc/letsencrypt/live/two.functorkitten.xyz/fullchain.pem'],
         ['#', ' managed by Certbot'],
         ['ssl_certificate_key', '/etc/letsencrypt/live/two.functorkitten.xyz/privkey.pem'],
         ['#', ' managed by Certbot'],
         [['if', '($scheme != "https")'], [['return', '302 https://$host$request_uri']]],
         ['#', ' managed by Certbot'], []]
     vhost_bad_haystack = VirtualHost(
         "filp",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), test_bad_haystack, [])
     self.assertTrue(vhost_haystack.contains_list(test_needle))
     self.assertFalse(vhost_bad_haystack.contains_list(test_needle))
开发者ID:MichalMMac,项目名称:certbot,代码行数:35,代码来源:obj_test.py

示例2: test_default_listen_addresses_t_f

 def test_default_listen_addresses_t_f(self, ipv6_info):
     # pylint: disable=protected-access
     ipv6_info.return_value = (True, False)
     addrs = self.http01._default_listen_addresses()
     http_addr = Addr.fromstring("80")
     http_ipv6_addr = Addr.fromstring("[::]:80 ipv6only=on")
     self.assertEqual(addrs, [http_addr, http_ipv6_addr])
开发者ID:pconrad-fb,项目名称:certbot,代码行数:7,代码来源:http_01_test.py

示例3: test_set_inclusion

    def test_set_inclusion(self):
        from certbot_nginx.obj import Addr
        set_a = set([self.addr1, self.addr2])
        addr1b = Addr.fromstring("192.168.1.1")
        addr2b = Addr.fromstring("192.168.1.1:* ssl")
        set_b = set([addr1b, addr2b])

        self.assertEqual(set_a, set_b)
开发者ID:loenne,项目名称:homeAutomation,代码行数:8,代码来源:obj_test.py

示例4: setUp

 def setUp(self):
     from certbot_nginx.obj import VirtualHost
     from certbot_nginx.obj import Addr
     raw1 = [
         ['listen', '69.50.225.155:9000'],
         [['if', '($scheme', '!=', '"https") '],
             [['return', '301', 'https://$host$request_uri']]
         ],
         ['#', ' managed by Certbot']
     ]
     self.vhost1 = VirtualHost(
         "filep",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw1, [])
     raw2 = [
         ['listen', '69.50.225.155:9000'],
         [['if', '($scheme', '!=', '"https") '],
             [['return', '301', 'https://$host$request_uri']]
         ]
     ]
     self.vhost2 = VirtualHost(
         "filep",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw2, [])
     raw3 = [
         ['listen', '69.50.225.155:9000'],
         ['rewrite', '^(.*)$', '$scheme://www.domain.com$1', 'permanent']
     ]
     self.vhost3 = VirtualHost(
         "filep",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw3, [])
     raw4 = [
         ['listen', '69.50.225.155:9000'],
         ['server_name', 'return.com']
     ]
     self.vhost4 = VirtualHost(
         "filp",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw4, [])
     raw_has_hsts = [
         ['listen', '69.50.225.155:9000'],
         ['server_name', 'return.com'],
         ['add_header', 'always', 'set', 'Strict-Transport-Security', '\"max-age=31536000\"'],
     ]
     self.vhost_has_hsts = VirtualHost(
         "filep",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw_has_hsts, [])
开发者ID:J0WI,项目名称:lets-encrypt-preview,代码行数:49,代码来源:obj_test.py

示例5: setUp

 def setUp(self):
     from certbot_nginx.obj import VirtualHost
     from certbot_nginx.obj import Addr
     self.vhost1 = VirtualHost(
         "filep",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), [], [])
开发者ID:benileo,项目名称:certbot,代码行数:7,代码来源:obj_test.py

示例6: test_eq

    def test_eq(self):
        from certbot_nginx.obj import Addr
        from certbot_nginx.obj import VirtualHost
        vhost1b = VirtualHost(
            "filep",
            set([Addr.fromstring("localhost blah")]), False, False,
            set(['localhost']), [], [])

        self.assertEqual(vhost1b, self.vhost1)
        self.assertEqual(str(vhost1b), str(self.vhost1))
        self.assertFalse(vhost1b == 1234)
开发者ID:loenne,项目名称:homeAutomation,代码行数:11,代码来源:obj_test.py

示例7: setUp

 def setUp(self):
     from certbot_nginx.obj import VirtualHost
     from certbot_nginx.obj import Addr
     raw1 = [
         ['listen', '69.50.225.155:9000'],
         [['if', '($scheme != "https") '],
             [['return', '301 https://$host$request_uri']]
         ],
         ['#', ' managed by Certbot']
     ]
     self.vhost1 = VirtualHost(
         "filep",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw1, [])
     raw2 = [
         ['listen', '69.50.225.155:9000'],
         [['if', '($scheme != "https") '],
             [['return', '301 https://$host$request_uri']]
         ]
     ]
     self.vhost2 = VirtualHost(
         "filep",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw2, [])
     raw3 = [
         ['listen', '69.50.225.155:9000'],
         ['rewrite', '^(.*)$ $scheme://www.domain.com$1 permanent;']
     ]
     self.vhost3 = VirtualHost(
         "filep",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw3, [])
     raw4 = [
         ['listen', '69.50.225.155:9000'],
         ['server_name', 'return.com']
     ]
     self.vhost4 = VirtualHost(
         "filp",
         set([Addr.fromstring("localhost")]), False, False,
         set(['localhost']), raw4, [])
开发者ID:MichalMMac,项目名称:certbot,代码行数:40,代码来源:obj_test.py

示例8: test_equivalent_any_addresses

    def test_equivalent_any_addresses(self):
        from certbot_nginx.obj import Addr
        any_addresses = ("0.0.0.0:80 default_server ssl",
                         "80 default_server ssl",
                         "*:80 default_server ssl")
        for first, second in itertools.combinations(any_addresses, 2):
            self.assertEqual(Addr.fromstring(first), Addr.fromstring(second))

        # Also, make sure ports are checked.
        self.assertNotEqual(Addr.fromstring(any_addresses[0]),
                            Addr.fromstring("0.0.0.0:443 default_server ssl"))

        # And they aren't equivalent to a specified address.
        for any_address in any_addresses:
            self.assertNotEqual(
                Addr.fromstring("192.168.1.2:80 default_server ssl"),
                Addr.fromstring(any_address))
开发者ID:loenne,项目名称:homeAutomation,代码行数:17,代码来源:obj_test.py


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