|
2 | 2 | from ..helpers import ctrl_with
|
3 | 3 | from ..helpers import requires_api_version
|
4 | 4 | from .base import BaseAPIIntegrationTest
|
5 |
| -from .base import TEST_IMG |
| 5 | +from .base import TEST_IMG, TEST_API_VERSION |
6 | 6 | from docker.utils.proxy import ProxyConfig
|
7 | 7 | from docker.utils.socket import next_frame_header
|
8 | 8 | from docker.utils.socket import read_exactly
|
@@ -35,17 +35,19 @@ def test_execute_command_with_proxy_env(self):
|
35 | 35 | for item in expected:
|
36 | 36 | assert item in output
|
37 | 37 |
|
38 |
| - # Overwrite some variables with a custom environment |
39 |
| - env = {'https_proxy': 'xxx', 'HTTPS_PROXY': 'XXX'} |
40 |
| - |
41 |
| - res = self.client.exec_create(container, cmd=cmd, environment=env) |
42 |
| - output = self.client.exec_start(res).decode('utf-8').split('\n') |
43 |
| - expected = [ |
44 |
| - 'ftp_proxy=a', 'https_proxy=xxx', 'http_proxy=c', 'no_proxy=d', |
45 |
| - 'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d' |
46 |
| - ] |
47 |
| - for item in expected: |
48 |
| - assert item in output |
| 38 | + # Setting environment for exec is not supported in API < 1.25 |
| 39 | + if TEST_API_VERSION > "1.24": |
| 40 | + # Overwrite some variables with a custom environment |
| 41 | + env = {'https_proxy': 'xxx', 'HTTPS_PROXY': 'XXX'} |
| 42 | + |
| 43 | + res = self.client.exec_create(container, cmd=cmd, environment=env) |
| 44 | + output = self.client.exec_start(res).decode('utf-8').split('\n') |
| 45 | + expected = [ |
| 46 | + 'ftp_proxy=a', 'https_proxy=xxx', 'http_proxy=c', 'no_proxy=d', |
| 47 | + 'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d' |
| 48 | + ] |
| 49 | + for item in expected: |
| 50 | + assert item in output |
49 | 51 |
|
50 | 52 | def test_execute_command(self):
|
51 | 53 | container = self.client.create_container(TEST_IMG, 'cat',
|
|
0 commit comments