@@ -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