Update TLS version configuration code. Tests.
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
commit
e7a8b2fed5
4 changed files with 49 additions and 4 deletions
|
|
@ -2,10 +2,12 @@ from __future__ import absolute_import
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import ssl
|
||||
|
||||
import pytest
|
||||
|
||||
from compose.cli.command import get_config_path_from_options
|
||||
from compose.cli.command import get_tls_version
|
||||
from compose.config.environment import Environment
|
||||
from compose.const import IS_WINDOWS_PLATFORM
|
||||
from tests import mock
|
||||
|
|
@ -46,3 +48,20 @@ class TestGetConfigPathFromOptions(object):
|
|||
def test_no_path(self):
|
||||
environment = Environment.from_env_file('.')
|
||||
assert not get_config_path_from_options('.', {}, environment)
|
||||
|
||||
|
||||
class TestGetTlsVersion(object):
|
||||
def test_get_tls_version_default(self):
|
||||
environment = {}
|
||||
assert get_tls_version(environment) is None
|
||||
|
||||
def test_get_tls_version_upgrade(self):
|
||||
environment = {'COMPOSE_TLS_VERSION': 'TLSv1_2'}
|
||||
assert get_tls_version(environment) == ssl.PROTOCOL_TLSv1_2
|
||||
|
||||
def test_get_tls_version_unavailable(self):
|
||||
environment = {'COMPOSE_TLS_VERSION': 'TLSv5_5'}
|
||||
with mock.patch('compose.cli.command.log') as mock_log:
|
||||
tls_version = get_tls_version(environment)
|
||||
mock_log.warn.assert_called_once_with(mock.ANY)
|
||||
assert tls_version is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue