Skip to content

Commit 3dcfac8

Browse files
address copilot feedback
1 parent 24b6fd0 commit 3dcfac8

2 files changed

Lines changed: 76 additions & 4 deletions

File tree

cloudsmith_cli/cli/commands/upstream.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,28 @@ def build_row(u):
7575
)
7676
)
7777
row.append(click.style(str(u.get("rsa_key_url", "") or ""), fg="yellow"))
78-
row.append(click.style(str(u.get("rsa_verification", "")), fg="yellow"))
7978
row.append(
80-
click.style(str(u.get("rsa_verification_status", "")), fg="yellow")
79+
click.style(str(u.get("rsa_verification", "") or ""), fg="yellow")
80+
)
81+
row.append(
82+
click.style(
83+
str(u.get("rsa_verification_status", "") or ""), fg="yellow"
84+
)
8185
)
8286

8387
if upstream_fmt == "deb":
8488
# `Component`, `Distribution Versions` and `Upstream Distribution` are deb-only
85-
row.append(click.style(str(u.get("component", None)), fg="yellow"))
89+
row.append(click.style(str(u.get("component", None) or ""), fg="yellow"))
8690
row.append(
8791
click.style(
8892
str(maybe_truncate_list(u.get("distro_versions", []))),
8993
fg="yellow",
9094
)
9195
)
9296
row.append(
93-
click.style(str(u.get("upstream_distribution", None)), fg="yellow")
97+
click.style(
98+
str(u.get("upstream_distribution", None) or ""), fg="yellow"
99+
)
94100
)
95101

96102
if upstream_fmt == "rpm":

cloudsmith_cli/cli/tests/commands/test_upstream.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,69 @@ def test_upstream_commands(
159159
assert result.exit_code == 0
160160
result_data = json.loads(result.output)["data"]
161161
assert not result_data # We should have no upstreams at this point
162+
163+
164+
@pytest.mark.usefixtures("set_api_key_env_var", "set_api_host_env_var")
165+
def test_alpine_upstream_ls_pretty_rsa_columns(
166+
runner, organization, tmp_repository, tmp_path
167+
):
168+
"""Pretty-output ls for alpine must render all four RSA columns with correct headers and values.
169+
170+
Alpine is the only format with RSA verification fields (rsa_key_inline, rsa_key_url,
171+
rsa_verification, rsa_verification_status). These are appended to the common column set
172+
inside print_upstreams(), so a regression in the branching logic or header list would
173+
silently drop or misalign them. This test catches that by asserting against the rendered
174+
table text rather than JSON output.
175+
"""
176+
rsa_key_url = "https://www.cloudsmith.io"
177+
upstream_config = {
178+
"name": "cli-test-upstream-alpine-rsa",
179+
"upstream_url": "https://www.cloudsmith.io",
180+
"rsa_key_url": rsa_key_url,
181+
}
182+
183+
upstream_config_file = tmp_path / "cli-test-upstream-alpine-rsa.json"
184+
upstream_config_file.write_text(json.dumps(upstream_config))
185+
186+
org_repo = f"{organization}/{tmp_repository['slug']}"
187+
188+
# Create the upstream and capture its slug_perm for later cleanup
189+
create_result = runner.invoke(
190+
upstream,
191+
args=["alpine", "create", org_repo, str(upstream_config_file), "-F", "json"],
192+
catch_exceptions=False,
193+
)
194+
assert create_result.exit_code == 0
195+
slug_perm = json.loads(create_result.output)["data"]["slug_perm"]
196+
197+
try:
198+
# Run ls with default pretty output — the path under test
199+
result = runner.invoke(
200+
upstream,
201+
args=["alpine", "ls", org_repo],
202+
catch_exceptions=False,
203+
)
204+
assert result.exit_code == 0
205+
206+
# All four RSA column headers must appear in the table header row
207+
assert "RSA Key Inline" in result.output
208+
assert "RSA Key URL" in result.output
209+
assert (
210+
"RSA Verification Status" in result.output
211+
) # most specific; covers "RSA Verification" too
212+
assert "RSA Verification" in result.output
213+
214+
# The rsa_key_url value we set must appear in the data row
215+
assert rsa_key_url in result.output
216+
217+
# Common non-RSA headers must still be present (guard against over-trimming)
218+
assert "Name" in result.output
219+
assert "Upstream Url" in result.output
220+
assert "Verify SSL" in result.output
221+
222+
finally:
223+
runner.invoke(
224+
upstream,
225+
args=["alpine", "delete", f"{org_repo}/{slug_perm}", "-y"],
226+
catch_exceptions=False,
227+
)

0 commit comments

Comments
 (0)