コード例 #1
0
 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))
コード例 #2
0
 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, [])
コード例 #3
0
 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']), [], [])
コード例 #4
0
    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)