Skip to content

Commit e72c7d0

Browse files
authored
Merge pull request #3784 from squidfunk/fix/docker-warning
Fix strict mode in Docker by removing 0.0.0.0 warning
2 parents d737625 + 52b4512 commit e72c7d0

File tree

3 files changed

+44
-72
lines changed

3 files changed

+44
-72
lines changed

mkdocs/config/config_options.py

-10
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,6 @@ def run_validation(self, value: object) -> _IpAddressValue:
488488

489489
return _IpAddressValue(host, port)
490490

491-
def post_validation(self, config: Config, key_name: str):
492-
host = config[key_name].host
493-
if key_name == 'dev_addr' and host in ['0.0.0.0', '::']:
494-
self.warnings.append(
495-
f"The use of the IP address '{host}' suggests a production environment "
496-
"or the use of a proxy to connect to the MkDocs server. However, "
497-
"the MkDocs' server is intended for local development purposes only. "
498-
"Please use a third party production-ready server instead."
499-
)
500-
501491

502492
class URL(OptionallyRequired[str]):
503493
"""

mkdocs/tests/config/config_options_legacy_tests.py

+22-31
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,28 @@ class Schema:
351351
self.assertEqual(conf['option'].host, '127.0.0.1')
352352
self.assertEqual(conf['option'].port, 8000)
353353

354+
def test_bind_all_IPv4_address(self):
355+
addr = '0.0.0.0:8000'
356+
357+
class Schema:
358+
option = c.IpAddress(default=addr)
359+
360+
conf = self.get_config(Schema, {'option': None})
361+
self.assertEqual(str(conf['option']), addr)
362+
self.assertEqual(conf['option'].host, '0.0.0.0')
363+
self.assertEqual(conf['option'].port, 8000)
364+
365+
def test_bind_all_IPv6_address(self):
366+
addr = ':::8000'
367+
368+
class Schema:
369+
option = c.IpAddress(default=addr)
370+
371+
conf = self.get_config(Schema, {'option': None})
372+
self.assertEqual(str(conf['option']), addr)
373+
self.assertEqual(conf['option'].host, '::')
374+
self.assertEqual(conf['option'].port, 8000)
375+
354376
@unittest.skipIf(
355377
sys.version_info < (3, 9, 5),
356378
"Leading zeros allowed in IP addresses before Python3.9.5",
@@ -381,37 +403,6 @@ def test_invalid_address_missing_port(self):
381403
with self.expect_error(option="Must be a string of format 'IP:PORT'"):
382404
self.get_config(self.Schema, {'option': '127.0.0.1'})
383405

384-
def test_unsupported_address(self):
385-
class Schema:
386-
dev_addr = c.IpAddress()
387-
388-
self.get_config(
389-
Schema,
390-
{'dev_addr': '0.0.0.0:8000'},
391-
warnings=dict(
392-
dev_addr="The use of the IP address '0.0.0.0' suggests a production "
393-
"environment or the use of a proxy to connect to the MkDocs "
394-
"server. However, the MkDocs' server is intended for local "
395-
"development purposes only. Please use a third party "
396-
"production-ready server instead."
397-
),
398-
)
399-
400-
def test_unsupported_IPv6_address(self):
401-
class Schema:
402-
dev_addr = c.IpAddress()
403-
404-
self.get_config(
405-
Schema,
406-
{'dev_addr': ':::8000'},
407-
warnings=dict(
408-
dev_addr="The use of the IP address '::' suggests a production environment "
409-
"or the use of a proxy to connect to the MkDocs server. However, "
410-
"the MkDocs' server is intended for local development purposes "
411-
"only. Please use a third party production-ready server instead."
412-
),
413-
)
414-
415406

416407
class URLTest(TestCase):
417408
def test_valid_url(self):

mkdocs/tests/config/config_options_tests.py

+22-31
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,28 @@ class Schema(Config):
339339
self.assertEqual(conf.option.host, '127.0.0.1')
340340
self.assertEqual(conf.option.port, 8000)
341341

342+
def test_bind_all_IPv4_address(self):
343+
addr = '0.0.0.0:8000'
344+
345+
class Schema(Config):
346+
option = c.IpAddress(default=addr)
347+
348+
conf = self.get_config(Schema, {'option': None})
349+
self.assertEqual(str(conf['option']), addr)
350+
self.assertEqual(conf['option'].host, '0.0.0.0')
351+
self.assertEqual(conf['option'].port, 8000)
352+
353+
def test_bind_all_IPv6_address(self):
354+
addr = ':::8000'
355+
356+
class Schema(Config):
357+
option = c.IpAddress(default=addr)
358+
359+
conf = self.get_config(Schema, {'option': None})
360+
self.assertEqual(str(conf['option']), addr)
361+
self.assertEqual(conf['option'].host, '::')
362+
self.assertEqual(conf['option'].port, 8000)
363+
342364
@unittest.skipIf(
343365
sys.version_info < (3, 9, 5),
344366
"Leading zeros allowed in IP addresses before Python3.9.5",
@@ -369,37 +391,6 @@ def test_invalid_address_missing_port(self) -> None:
369391
with self.expect_error(option="Must be a string of format 'IP:PORT'"):
370392
self.get_config(self.Schema, {'option': '127.0.0.1'})
371393

372-
def test_unsupported_address(self) -> None:
373-
class Schema(Config):
374-
dev_addr = c.IpAddress()
375-
376-
self.get_config(
377-
Schema,
378-
{'dev_addr': '0.0.0.0:8000'},
379-
warnings=dict(
380-
dev_addr="The use of the IP address '0.0.0.0' suggests a production "
381-
"environment or the use of a proxy to connect to the MkDocs "
382-
"server. However, the MkDocs' server is intended for local "
383-
"development purposes only. Please use a third party "
384-
"production-ready server instead."
385-
),
386-
)
387-
388-
def test_unsupported_IPv6_address(self) -> None:
389-
class Schema(Config):
390-
dev_addr = c.IpAddress()
391-
392-
self.get_config(
393-
Schema,
394-
{'dev_addr': ':::8000'},
395-
warnings=dict(
396-
dev_addr="The use of the IP address '::' suggests a production environment "
397-
"or the use of a proxy to connect to the MkDocs server. However, "
398-
"the MkDocs' server is intended for local development purposes "
399-
"only. Please use a third party production-ready server instead."
400-
),
401-
)
402-
403394

404395
class URLTest(TestCase):
405396
def test_valid_url(self) -> None:

0 commit comments

Comments
 (0)