1
0
mirror of https://github.com/quay/quay.git synced 2026-01-29 08:42:15 +03:00
Files
quay/endpoints/api/test/test_superuser.py
Harish Govindarajulu 98811f5397 feat: Add auto-prune policy at repository level (PROJQUAY-6354) (#2691)
* feat: Add support for auto pruning at repository level (PROJQUAY-6354)

* Add repositoryautoprunepolicy table to alembic migration script

* Add repository auto-prune policy endpoints

* Add UI for repository auto-pruning policies

* case: apply repo auto-prune policy when no namespace policy given

* case: both namespace and repo pruning policy are given

* Add tests for repository autoprune endpoint

* Add cypress test for repository auto-prune

* Add repo auto-prune policy clean-up for repository deletion

* Add repository auto pruning tables to quay db snapshot for cypress tests

* Address review comments

* Add more tests + fix CI + reformat files

* Address review comments #2

---------

Signed-off-by: harishsurf <hgovinda@redhat.com>
2024-02-27 15:02:57 +05:30

70 lines
2.4 KiB
Python

import pytest
from data.database import DeletedNamespace, User
from endpoints.api.superuser import (
SuperUserList,
SuperUserManagement,
SuperUserOrganizationList,
)
from endpoints.api.test.shared import conduct_api_call
from endpoints.test.shared import client_with_identity
from test.fixtures import *
@pytest.mark.parametrize(
"disabled",
[
(True),
(False),
],
)
def test_list_all_users(disabled, app):
with client_with_identity("devtable", app) as cl:
params = {"disabled": disabled}
result = conduct_api_call(cl, SuperUserList, "GET", params, None, 200).json
assert len(result["users"])
for user in result["users"]:
if not disabled:
assert user["enabled"]
def test_list_all_orgs(app):
with client_with_identity("devtable", app) as cl:
result = conduct_api_call(cl, SuperUserOrganizationList, "GET", None, None, 200).json
assert len(result["organizations"]) == 7
def test_paginate_orgs(app):
with client_with_identity("devtable", app) as cl:
params = {"limit": 4}
firstResult = conduct_api_call(cl, SuperUserOrganizationList, "GET", params, None, 200).json
assert len(firstResult["organizations"]) == 4
assert firstResult["next_page"] is not None
params["next_page"] = firstResult["next_page"]
secondResult = conduct_api_call(
cl, SuperUserOrganizationList, "GET", params, None, 200
).json
assert len(secondResult["organizations"]) == 3
assert secondResult.get("next_page", None) is None
def test_paginate_test_list_all_users(app):
with client_with_identity("devtable", app) as cl:
params = {"limit": 7}
firstResult = conduct_api_call(cl, SuperUserList, "GET", params, None, 200).json
assert len(firstResult["users"]) == 7
assert firstResult["next_page"] is not None
params["next_page"] = firstResult["next_page"]
secondResult = conduct_api_call(cl, SuperUserList, "GET", params, None, 200).json
assert len(secondResult["users"]) == 4
assert secondResult.get("next_page", None) is None
def test_change_install_user(app):
with client_with_identity("devtable", app) as cl:
params = {"username": "randomuser"}
body = {"email": "new_email123@test.com"}
result = conduct_api_call(cl, SuperUserManagement, "PUT", params, body, 200).json
assert result["email"] == body["email"]