|
18 | 18 | from assertpy import assert_that
|
19 | 19 | from framework.credential_providers import run_pcluster_command
|
20 | 20 | from remote_command_executor import RemoteCommandExecutionError, RemoteCommandExecutor
|
21 |
| -from utils import add_keys_to_known_hosts, check_node_security_group, get_username_for_os, remove_keys_from_known_hosts |
| 21 | +from utils import ( |
| 22 | + add_keys_to_known_hosts, |
| 23 | + check_node_security_group, |
| 24 | + get_cidr_from_ip, |
| 25 | + get_local_ip, |
| 26 | + get_username_for_os, |
| 27 | + remove_keys_from_known_hosts, |
| 28 | +) |
22 | 29 |
|
23 | 30 | from tests.cloudwatch_logging.test_cloudwatch_logging import FeatureSpecificCloudWatchLoggingTestRunner
|
24 | 31 |
|
|
27 | 34 |
|
28 | 35 |
|
29 | 36 | def test_dcv_configuration(region, instance, os, scheduler, pcluster_config_reader, clusters_factory, test_datadir):
|
| 37 | + host_ip = get_local_ip() |
| 38 | + dcv_allowed_ips = get_cidr_from_ip(host_ip) if host_ip else "0.0.0.0/0" |
30 | 39 | _test_dcv_configuration(
|
31 |
| - 8443, "0.0.0.0/0", region, instance, os, scheduler, pcluster_config_reader, clusters_factory, test_datadir |
| 40 | + 8443, dcv_allowed_ips, region, instance, os, scheduler, pcluster_config_reader, clusters_factory, test_datadir |
32 | 41 | )
|
33 | 42 |
|
34 | 43 |
|
35 |
| -@pytest.mark.parametrize("dcv_port, access_from", [(8443, "0.0.0.0/0"), (5678, "192.168.1.1/32")]) |
| 44 | +@pytest.mark.parametrize("dcv_port, access_from", [(8443, "PLACEHOLDER_TEST_HOST_CIDR"), (5678, "192.168.1.1/32")]) |
36 | 45 | def test_dcv_with_remote_access(
|
37 | 46 | dcv_port, access_from, region, instance, os, scheduler, pcluster_config_reader, clusters_factory, test_datadir
|
38 | 47 | ):
|
| 48 | + if access_from == "PLACEHOLDER_TEST_HOST_CIDR": |
| 49 | + host_ip = get_local_ip() |
| 50 | + dcv_allowed_ips = get_cidr_from_ip(host_ip) if host_ip else "0.0.0.0/0" |
| 51 | + else: |
| 52 | + dcv_allowed_ips = access_from |
39 | 53 | _test_dcv_configuration(
|
40 |
| - dcv_port, access_from, region, instance, os, scheduler, pcluster_config_reader, clusters_factory, test_datadir |
| 54 | + dcv_port, |
| 55 | + dcv_allowed_ips, |
| 56 | + region, |
| 57 | + instance, |
| 58 | + os, |
| 59 | + scheduler, |
| 60 | + pcluster_config_reader, |
| 61 | + clusters_factory, |
| 62 | + test_datadir, |
41 | 63 | )
|
42 | 64 |
|
43 | 65 |
|
|
0 commit comments