-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enable non-admins to cache images via pull-thru (PROJQUAY-3806) (#…
…1366) (#1379) introduces a check of the OrganizationMemberPermission for pulls against a proxy org. if the proxy cache feature is disabled, or the org is not a proxy org the check is not performed and Quay will behave normally. this check does not mean pulls will work transparently though - non-admin users need to be added to a team in the proxy org with the member role, and default read and write permissions need to be given to that team so that non-admin users can pull and update the cache for images they do not own (the user who first pulls an image ends up owning the repository since that is when the repo gets created).
- Loading branch information
1 parent
5487b26
commit 6090bd0
Showing
7 changed files
with
1,329 additions
and
1,266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,45 @@ | ||
from playhouse.test_utils import assert_query_count | ||
|
||
from data.model import InvalidOrganizationException | ||
from data.model.proxy_cache import * | ||
import pytest | ||
|
||
from data.model import InvalidOrganizationException, InvalidProxyCacheConfigException | ||
from data.model.proxy_cache import ( | ||
create_proxy_cache_config, | ||
get_proxy_cache_config_for_org, | ||
delete_proxy_cache_config, | ||
has_proxy_cache_config, | ||
) | ||
from data.database import DEFAULT_PROXY_CACHE_EXPIRATION | ||
from data.model.organization import create_organization | ||
from data.database import ProxyCacheConfig, DEFAULT_PROXY_CACHE_EXPIRATION | ||
from test.fixtures import * | ||
from data.model.user import create_user_noverify | ||
from test.fixtures import * # noqa: F401, F403 | ||
|
||
|
||
def create_org(user_name, user_email, org_name, org_email): | ||
user_obj = create_user_noverify(user_name, user_email) | ||
return create_organization(org_name, org_email, user_obj) | ||
|
||
|
||
def test_has_proxy_cache_config_with_proxy_cache_org(initialized_db): | ||
org = create_org( | ||
user_name="test", | ||
user_email="[email protected]", | ||
org_name="foobar", | ||
org_email="[email protected]", | ||
) | ||
create_proxy_cache_config(org.username, "quay.io") | ||
assert has_proxy_cache_config(org.username) | ||
|
||
|
||
def test_has_proxy_cache_config_with_regular_org(initialized_db): | ||
org = create_org( | ||
user_name="test", | ||
user_email="[email protected]", | ||
org_name="foobar", | ||
org_email="[email protected]", | ||
) | ||
assert not has_proxy_cache_config(org.username) | ||
|
||
|
||
def test_create_proxy_cache_config_with_defaults(initialized_db): | ||
upstream_registry = "quay.io" | ||
org = create_org( | ||
|
Oops, something went wrong.