mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(FastAPI): add /pkgbase/{name}/adopt (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
72d6016da4
commit
305d077973
3 changed files with 65 additions and 4 deletions
|
@ -1849,6 +1849,39 @@ def test_pkgbase_disown(client: TestClient, user: User, maintainer: User,
|
|||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
|
||||
def test_pkgbase_adopt(client: TestClient, user: User, tu_user: User,
|
||||
maintainer: User, package: Package):
|
||||
# Unset the maintainer as if package is orphaned.
|
||||
with db.begin():
|
||||
package.PackageBase.Maintainer = None
|
||||
|
||||
pkgbasename = package.PackageBase.Name
|
||||
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
|
||||
endpoint = f"/pkgbase/{pkgbasename}/adopt"
|
||||
|
||||
# Adopt the package base.
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies, allow_redirects=False)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
assert package.PackageBase.Maintainer == maintainer
|
||||
|
||||
# Try to adopt it when it already has a maintainer; nothing changes.
|
||||
user_cookies = {"AURSID": user.login(Request(), "testPassword")}
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=user_cookies,
|
||||
allow_redirects=False)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
assert package.PackageBase.Maintainer == maintainer
|
||||
|
||||
# Steal the package as a TU.
|
||||
tu_cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=tu_cookies,
|
||||
allow_redirects=False)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
assert package.PackageBase.Maintainer == tu_user
|
||||
|
||||
|
||||
def test_pkgbase_delete_unauthorized(client: TestClient, user: User,
|
||||
package: Package):
|
||||
pkgbase = package.PackageBase
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue