CI / checks (push) Skipped
CI / checks (pull_request) Successful in 5m17s
Every live test that touches a repository gets one of its own from e2e_support.fresh_repo, made by the test operator as an operator makes a project's (D4, D8): seeded from tests/integration/seed/ (the sandbox's package, without past runs' leftovers), the agent's account a collaborator with write access, main protected (pushes only by the owner, an approval to merge), and a deploy key generated for the run. It is deleted afterwards (NISSE_E2E_KEEP_REPOS keeps it); scripts/e2e-cleanup.sh deletes leftovers. - Both e2e fixtures use it; per-run base branches are gone. The merge helper approves first, as the protection now requires. - test_gitea_live uses it, so CI needs NISSE_OPERATOR_TOKEN and no longer writes the sandbox deploy key (NISSE_PUSH_KEY). - A live test of the helper: seeded, shared with the agent, protected against it, deleted. - nisse-test.yaml's project entry is a placeholder; pytest and ruff skip the seed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
"""The per-run test repository (e2e_support.fresh_repo): what the operator
|
|
provides for a project (D4, D8), made and deleted by the test operator."""
|
|
|
|
import uuid
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from e2e_support import fresh_repo, operator_gitea
|
|
|
|
from nisse_dev.config import AgentConfig
|
|
from nisse_dev.gitea import GiteaClient, GiteaError
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
|
|
def test_a_fresh_repository_is_seeded_shared_and_protected(
|
|
tmp_path: Path, live_config: AgentConfig, gitea: GiteaClient
|
|
) -> None:
|
|
operator = operator_gitea(live_config.gitea_url)
|
|
run = uuid.uuid4().hex[:8]
|
|
with fresh_repo(operator, run, tmp_path / "keys", agent=gitea.whoami()) as repo:
|
|
# Seeded: the package and its tests, and the README replaced.
|
|
text = gitea._request("GET", f"/repos/{repo.name}/contents/sandbox/text.py")
|
|
assert text["name"] == "text.py"
|
|
assert gitea._request("GET", f"/repos/{repo.name}/contents/tests")
|
|
# The agent sees it as a collaborator that may push, and main as
|
|
# protected against it (what D4's verification reads).
|
|
main = gitea._request("GET", f"/repos/{repo.name}/branches/main")
|
|
assert main["protected"] and not main["user_can_push"]
|
|
assert gitea._request("GET", f"/repos/{repo.name}")["permissions"]["push"]
|
|
assert repo.push_key.exists()
|
|
with pytest.raises(GiteaError, match="404"):
|
|
gitea._request("GET", f"/repos/{repo.name}")
|