Skip to content

Commit a40900e

Browse files
Merge branch 'dev' into feat-kubeconfig-inherit-args
2 parents ca3efe2 + 6566cc5 commit a40900e

File tree

4 files changed

+94
-13
lines changed

4 files changed

+94
-13
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # [email protected]
4343

4444
- name: Set up Docker Buildx
45-
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # pin@v3.10.0
45+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # pin@v3.11.1
4646

4747
- name: Login to Docker Hub
4848
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # [email protected]

linodecli/plugins/get-kubeconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def _get_kubeconfig_by_label(cluster_label, client):
132132
# Loads a yaml file
133133
def _load_config(filepath):
134134
with open(filepath, "r", encoding="utf-8") as file_descriptor:
135-
data = yaml.load(file_descriptor, Loader=yaml.Loader)
135+
data = yaml.safe_load(file_descriptor)
136136

137137
if not data:
138138
print(f"Could not load file at {filepath}", file=sys.stderr)

tests/integration/account/test_account.py

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import json
2+
13
import pytest
24

35
from tests.integration.helpers import (
@@ -202,14 +204,77 @@ def test_account_login_view(get_login_id):
202204
assert_headers_in_lines(headers, lines)
203205

204206

207+
@pytest.fixture
205208
def test_account_setting_view():
206-
res = exec_test_command(
209+
expected_headers = [
210+
"longview_subscription",
211+
"network_helper",
212+
"interfaces_for_new_linodes",
213+
]
214+
215+
settings_text = exec_test_command(
207216
BASE_CMDS["account"] + ["settings", "--text", "--delimiter=,"]
208217
)
209-
lines = res.splitlines()
218+
lines = settings_text.splitlines()
219+
headers = lines[0].split(",")
210220

211-
headers = ["longview_subscription", "network_helper"]
212-
assert_headers_in_lines(headers, lines)
221+
for expected in expected_headers:
222+
assert (
223+
expected in headers
224+
), f"Expected header '{expected}' not found in CLI output"
225+
226+
# Fetch current interfaces setting
227+
settings_json = exec_test_command(
228+
BASE_CMDS["account"] + ["settings", "--json"]
229+
)
230+
original_value = json.loads(settings_json)[0]["interfaces_for_new_linodes"]
231+
232+
yield original_value
233+
234+
# Restore original setting after test
235+
exec_test_command(
236+
BASE_CMDS["account"]
237+
+ [
238+
"settings-update",
239+
"--interfaces_for_new_linodes",
240+
original_value,
241+
]
242+
)
243+
244+
245+
def test_update_interfaces_setting(test_account_setting_view):
246+
original_value = test_account_setting_view
247+
248+
# Define valid values different from the original
249+
valid_options = [
250+
"legacy_config_only",
251+
"legacy_config_default_but_linode_allowed",
252+
"linode_default_but_legacy_config_allowed",
253+
"linode_only",
254+
]
255+
256+
# Select a different value for testing
257+
new_value = next(val for val in valid_options if val != original_value)
258+
259+
# Update the setting
260+
exec_test_command(
261+
BASE_CMDS["account"]
262+
+ [
263+
"settings-update",
264+
"--interfaces_for_new_linodes",
265+
new_value,
266+
]
267+
)
268+
269+
# Verify the setting was updated
270+
updated_json = exec_test_command(
271+
BASE_CMDS["account"] + ["settings", "--json"]
272+
)
273+
updated_value = json.loads(updated_json)[0]["interfaces_for_new_linodes"]
274+
275+
assert (
276+
updated_value == new_value
277+
), f"Expected {new_value}, got {updated_value}"
213278

214279

215280
def test_user_list():

tests/integration/networking/test_networking.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ def has_shared_ip(linode_id: int, ip: str) -> bool:
4949
["linode-cli", "linodes", "ips-list", "--json", linode_id]
5050
)
5151
)[0]["ipv4"]["shared"]
52+
for entry in shared_ips:
53+
if entry["address"] == ip:
54+
# Validate presence and type of interface_id
55+
assert "interface_id" in entry
56+
assert entry["interface_id"] is None or isinstance(
57+
entry["interface_id"], int
58+
)
59+
return True
5260

53-
# Ensure there is a matching shared IP
54-
return len([v for v in shared_ips if v["address"] == ip]) > 0
61+
return False
5562

5663

5764
def test_display_ips_for_available_linodes(test_linode_id):
@@ -92,15 +99,24 @@ def test_view_an_ip_address(test_linode_id):
9299
BASE_CMDS["networking"]
93100
+ [
94101
"ip-view",
95-
"--text",
96-
"--no-headers",
97-
"--delimiter",
98-
",",
102+
"--json",
99103
linode_ipv4,
100104
]
101105
)
102106

103-
assert re.search(r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}", result)
107+
data = json.loads(result)
108+
if isinstance(data, list):
109+
data = data[0]
110+
# Validate that the address is a proper IPv4 address
111+
assert re.match(r"^[0-9]{1,3}(\.[0-9]{1,3}){3}$", data["address"])
112+
113+
# Validate that interface_id is present and either None or int
114+
assert (
115+
"interface_id" in data
116+
), "`interface_id` field missing in IP view response"
117+
assert data["interface_id"] is None or isinstance(
118+
data["interface_id"], int
119+
), f"`interface_id` is not None or int: {data['interface_id']}"
104120

105121

106122
def test_allocate_additional_private_ipv4_address(test_linode_id):

0 commit comments

Comments
 (0)