Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ def metastore_scope_available(url: str, token: str) -> bool:
mc.list_items(SEMANTIC_TYPES[0]) # ty: ignore[invalid-argument-type] # probe; str vs SemanticType Literal
return True
except KeboolaApiError as exc:
if exc.status_code == 502 or "scope" in (exc.message or "").lower():
# Skip cleanly when the scope is genuinely unavailable (502 / "scope")
# OR the metastore host is simply unreachable (network / DNS -- e.g. a
# malformed or accidentally doubled stack URL). Both mean "no usable
# metastore here"; raising would turn one preflight failure into a wall
# of errors across every dependent test.
msg = (exc.message or "").lower()
if exc.status_code == 502 or "scope" in msg or "cannot connect" in msg:
return False
raise

Expand Down
24 changes: 18 additions & 6 deletions tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -1895,15 +1895,25 @@ def _test_workspace_detail(self, workspace_id: int) -> None:
assert detail["workspace_id"] == workspace_id

def _test_workspace_password(self, workspace_id: int) -> None:
"""Reset workspace password and verify a new password is returned."""
data = self._run_ok(
"""Reset workspace password and verify a new password is returned.

Keypair-auth workspaces (Snowflake ``person-keypair`` login) have no
password, so the API rejects the reset with HTTP 400 "Reset password is
not supported for login type ...". That is an environment property of
the project, not a failure -- skip cleanly when it happens.
"""
result = self._run(
"workspace",
"password",
"--project",
self.alias,
"--workspace-id",
str(workspace_id),
)
if result.exit_code != 0 and "not supported for login type" in result.output:
print(f" {_DIM}skip: keypair-auth workspace has no password to reset{_RESET}")
return
data = _json_ok(result)
assert data["data"]["password"] # non-empty password

def _test_workspace_load(self, workspace_id: int, table_id: str) -> None:
Expand Down Expand Up @@ -7393,7 +7403,9 @@ def test_swap_without_branch_is_rejected(self) -> None:
assert result.exit_code == 5, result.output
payload = json.loads(result.output)
assert payload["status"] == "error"
assert "dev branch" in payload["error"]["message"]
# Wording corrected in #373 (swap works on any branch, incl. production);
# match the stable part of the message, not the old "dev branch" phrasing.
assert "requires a branch" in payload["error"]["message"]


# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -11307,7 +11319,7 @@ def test_config_create_and_update_encrypt_secret(self) -> None:
"--no-validate",
"--configuration",
'{"parameters":{"#password":"e2e-canary-create"}}',
)
)["data"]
config_id = str(created["id"])
self._created.append((self.COMPONENT, config_id))

Expand Down Expand Up @@ -11353,7 +11365,7 @@ def test_config_update_dry_run_is_not_encrypted(self) -> None:
"--no-validate",
"--configuration",
'{"parameters":{"user":"probe"}}',
)
)["data"]
config_id = str(created["id"])
self._created.append((self.COMPONENT, config_id))

Expand All @@ -11370,6 +11382,6 @@ def test_config_update_dry_run_is_not_encrypted(self) -> None:
"--configuration",
'{"parameters":{"#password":"e2e-canary-dryrun"}}',
"--dry-run",
)
)["data"]
new_pw = data["new_configuration"]["parameters"]["#password"]
assert new_pw == "e2e-canary-dryrun", f"dry-run encrypted the diff: {new_pw!r}"
Loading