mirror of
https://github.com/certbot/certbot.git
synced 2026-06-03 22:08:07 -04:00
obj.py was failing to write out all parameters. let's fix that.
This commit is contained in:
parent
e0f760099c
commit
dd090401d9
2 changed files with 16 additions and 6 deletions
|
|
@ -36,7 +36,7 @@ class Addr(common.Addr):
|
|||
UNSPECIFIED_IPV4_ADDRESSES = ('', '*', '0.0.0.0')
|
||||
CANONICAL_UNSPECIFIED_ADDRESS = UNSPECIFIED_IPV4_ADDRESSES[0]
|
||||
|
||||
def __init__(self, host, port, ssl, default, ipv6, ipv6only):
|
||||
def __init__(self, host, port, ssl, default, ipv6, ipv6only, otherparts=None):
|
||||
# pylint: disable=too-many-arguments
|
||||
super(Addr, self).__init__((host, port))
|
||||
self.ssl = ssl
|
||||
|
|
@ -44,6 +44,7 @@ class Addr(common.Addr):
|
|||
self.ipv6 = ipv6
|
||||
self.ipv6only = ipv6only
|
||||
self.unspecified_address = host in self.UNSPECIFIED_IPV4_ADDRESSES
|
||||
self.otherparts = otherparts
|
||||
|
||||
@classmethod
|
||||
def fromstring(cls, str_addr):
|
||||
|
|
@ -84,6 +85,7 @@ class Addr(common.Addr):
|
|||
port = tup[2]
|
||||
|
||||
# The rest of the parts are options; we only care about ssl and default
|
||||
otherparts = set()
|
||||
while len(parts) > 0:
|
||||
nextpart = parts.pop()
|
||||
if nextpart == 'ssl':
|
||||
|
|
@ -94,8 +96,10 @@ class Addr(common.Addr):
|
|||
default = True
|
||||
elif nextpart == "ipv6only=on":
|
||||
ipv6only = True
|
||||
else:
|
||||
otherparts.add(nextpart)
|
||||
|
||||
return cls(host, port, ssl, default, ipv6, ipv6only)
|
||||
return cls(host, port, ssl, default, ipv6, ipv6only, otherparts)
|
||||
|
||||
def to_string(self, include_default=True):
|
||||
"""Return string representation of Addr"""
|
||||
|
|
@ -111,6 +115,12 @@ class Addr(common.Addr):
|
|||
parts += ' default_server'
|
||||
if self.ssl:
|
||||
parts += ' ssl'
|
||||
if self.ipv6only:
|
||||
parts += ' ipv6only=on'
|
||||
if self.otherparts:
|
||||
for word in self.otherparts:
|
||||
parts += ' '
|
||||
parts += word
|
||||
|
||||
return parts
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class AddrTest(unittest.TestCase):
|
|||
self.assertEqual(str(self.addr3), "192.168.1.1:80")
|
||||
self.assertEqual(str(self.addr4), "*:80 default_server ssl")
|
||||
self.assertEqual(str(self.addr5), "myhost")
|
||||
self.assertEqual(str(self.addr6), "80 default_server")
|
||||
self.assertEqual(str(self.addr6), "80 default_server spdy")
|
||||
self.assertEqual(str(self.addr8), "*:80 default_server ssl")
|
||||
|
||||
def test_to_string(self):
|
||||
|
|
@ -67,8 +67,8 @@ class AddrTest(unittest.TestCase):
|
|||
self.assertEqual(self.addr4.to_string(), "*:80 default_server ssl")
|
||||
self.assertEqual(self.addr4.to_string(include_default=False), "*:80 ssl")
|
||||
self.assertEqual(self.addr5.to_string(), "myhost")
|
||||
self.assertEqual(self.addr6.to_string(), "80 default_server")
|
||||
self.assertEqual(self.addr6.to_string(include_default=False), "80")
|
||||
self.assertEqual(self.addr6.to_string(), "80 default_server spdy")
|
||||
self.assertEqual(self.addr6.to_string(include_default=False), "80 spdy")
|
||||
|
||||
def test_eq(self):
|
||||
from certbot_nginx.obj import Addr
|
||||
|
|
@ -163,7 +163,7 @@ class VirtualHostTest(unittest.TestCase):
|
|||
from certbot_nginx.obj import VirtualHost
|
||||
vhost1b = VirtualHost(
|
||||
"filep",
|
||||
set([Addr.fromstring("localhost blah")]), False, False,
|
||||
set([Addr.fromstring("localhost")]), False, False,
|
||||
set(['localhost']), [], [])
|
||||
|
||||
self.assertEqual(vhost1b, self.vhost1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue