Fix provider token request handling

This commit is contained in:
bearsyankees 2026-08-28 10:31:12 -04:00
parent de5fcfb283
commit bee88d95d2
3 changed files with 51 additions and 5 deletions

View file

@ -110,9 +110,10 @@ _TEST_USER_BODY = (
)
_GIT_TOKEN_BODY = (
P("token", required=True, help="Provider access token.", flag="provider-token"),
P("instance_url", help="Base URL for a self-hosted instance."),
P("workspace", help="Bitbucket workspace name."),
P("access_token", required=True, help="Provider access token.", flag="provider-token"),
P("instance_url", help="GitLab base URL, for example https://gitlab.com."),
P("account_email", help="Bitbucket account email address."),
P("installation_id", "int", help="Existing installation ID to update."),
)

View file

@ -296,10 +296,45 @@ def test_required_secret_body_field_can_come_from_stdin(
return FakeResponse(payload={"ok": True})
monkeypatch.setattr(http, "request", fake_request)
monkeypatch.setattr("sys.stdin", io.StringIO('{"token":"provider-secret"}'))
monkeypatch.setattr("sys.stdin", io.StringIO('{"access_token":"provider-secret"}'))
assert cloud.run_cloud(["integrations", "connect", "gitlab", "--data", "-", "--json"]) == 0
assert seen["body"] == {"token": "provider-secret"}
assert seen["body"] == {"access_token": "provider-secret"}
def test_provider_token_does_not_override_strix_api_auth(
monkeypatch: pytest.MonkeyPatch,
) -> None:
seen: dict[str, Any] = {}
def fake_request(_method: str, _path: str, **kwargs: Any) -> FakeResponse:
seen.update(token=kwargs.get("token"), body=kwargs.get("body"))
return FakeResponse(payload={"ok": True})
monkeypatch.setattr(http, "request", fake_request)
assert (
cloud.run_cloud(
[
"integrations",
"connect",
"gitlab",
"--provider-token",
"provider-secret",
"--instance-url",
"https://gitlab.com",
"--json",
]
)
== 0
)
assert seen == {
"token": None,
"body": {
"access_token": "provider-secret",
"instance_url": "https://gitlab.com",
},
}
def test_required_body_field_is_validated_after_data_merge(capsys: Any) -> None:

View file

@ -81,6 +81,16 @@ def test_exact_verbs_that_are_also_prefixes_keep_their_subverbs() -> None:
def test_contract_fix_flags_are_completed() -> None:
integration_connect = completion_candidates(
["cloud", "integrations", "connect", "gitlab", "--"]
)
assert {
"--provider-token",
"--instance-url",
"--account-email",
"--installation-id",
} <= set(integration_connect)
disconnect = completion_candidates(["cloud", "integrations", "disconnect", "--"])
assert "--installation-id" in disconnect