Show starred public repositories in the starred repos list
We forgot to check if the repository was public in the filter Fixes https://jira.coreos.com/browse/QUAY-857
This commit is contained in:
parent
9d30a0a216
commit
8ee98c1c48
4 changed files with 37 additions and 6 deletions
|
@ -13,7 +13,7 @@ from data.database import (
|
||||||
Repository, Namespace, RepositoryTag, Star, Image, ImageStorage, User, Visibility, Tag,
|
Repository, Namespace, RepositoryTag, Star, Image, ImageStorage, User, Visibility, Tag,
|
||||||
RepositoryPermission, RepositoryActionCount, Role, RepositoryAuthorizedEmail, TagManifest,
|
RepositoryPermission, RepositoryActionCount, Role, RepositoryAuthorizedEmail, TagManifest,
|
||||||
DerivedStorageForImage, Label, TagManifestLabel, db_for_update, get_epoch_timestamp,
|
DerivedStorageForImage, Label, TagManifestLabel, db_for_update, get_epoch_timestamp,
|
||||||
db_random_func, db_concat_func, RepositorySearchScore)
|
db_random_func, db_concat_func, RepositorySearchScore, RepositoryKind)
|
||||||
from data.text import prefix_search
|
from data.text import prefix_search
|
||||||
from util.itertoolrecipes import take
|
from util.itertoolrecipes import take
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,8 @@ class PreOCIModel(RepositoryDataInterface):
|
||||||
if starred:
|
if starred:
|
||||||
# Return the full list of repos starred by the current user that are still visible to them.
|
# Return the full list of repos starred by the current user that are still visible to them.
|
||||||
def can_view_repo(repo):
|
def can_view_repo(repo):
|
||||||
return ReadRepositoryPermission(repo.namespace_user.username, repo.name).can()
|
can_view = ReadRepositoryPermission(repo.namespace_user.username, repo.name).can()
|
||||||
|
return can_view or model.repository.is_repository_public(repo)
|
||||||
|
|
||||||
unfiltered_repos = model.repository.get_user_starred_repositories(user,
|
unfiltered_repos = model.repository.get_user_starred_repositories(user,
|
||||||
kind_filter=repo_kind)
|
kind_filter=repo_kind)
|
||||||
|
|
|
@ -2,8 +2,9 @@ import pytest
|
||||||
|
|
||||||
from mock import patch, ANY, MagicMock
|
from mock import patch, ANY, MagicMock
|
||||||
|
|
||||||
|
from data import model
|
||||||
from endpoints.api.test.shared import conduct_api_call
|
from endpoints.api.test.shared import conduct_api_call
|
||||||
from endpoints.api.repository import RepositoryTrust, Repository
|
from endpoints.api.repository import RepositoryTrust, Repository, RepositoryList
|
||||||
from endpoints.test.shared import client_with_identity
|
from endpoints.test.shared import client_with_identity
|
||||||
from features import FeatureNameValue
|
from features import FeatureNameValue
|
||||||
|
|
||||||
|
@ -67,6 +68,31 @@ def test_signing_disabled(client):
|
||||||
assert not response['trust_enabled']
|
assert not response['trust_enabled']
|
||||||
|
|
||||||
|
|
||||||
def test_sni_support():
|
def test_list_starred_repos(client):
|
||||||
import ssl
|
with client_with_identity('devtable', client) as cl:
|
||||||
assert ssl.HAS_SNI
|
params = {
|
||||||
|
'starred': 'true',
|
||||||
|
}
|
||||||
|
|
||||||
|
response = conduct_api_call(cl, RepositoryList, 'GET', params).json
|
||||||
|
repos = {r['namespace'] + '/' + r['name'] for r in response['repositories']}
|
||||||
|
assert 'devtable/simple' in repos
|
||||||
|
assert 'public/publicrepo' not in repos
|
||||||
|
|
||||||
|
# Add a star on publicrepo.
|
||||||
|
publicrepo = model.repository.get_repository('public', 'publicrepo')
|
||||||
|
model.repository.star_repository(model.user.get_user('devtable'), publicrepo)
|
||||||
|
|
||||||
|
# Ensure publicrepo shows up.
|
||||||
|
response = conduct_api_call(cl, RepositoryList, 'GET', params).json
|
||||||
|
repos = {r['namespace'] + '/' + r['name'] for r in response['repositories']}
|
||||||
|
assert 'devtable/simple' in repos
|
||||||
|
assert 'public/publicrepo' in repos
|
||||||
|
|
||||||
|
# Make publicrepo private and ensure it disappears.
|
||||||
|
model.repository.set_repository_visibility(publicrepo, 'private')
|
||||||
|
|
||||||
|
response = conduct_api_call(cl, RepositoryList, 'GET', params).json
|
||||||
|
repos = {r['namespace'] + '/' + r['name'] for r in response['repositories']}
|
||||||
|
assert 'devtable/simple' in repos
|
||||||
|
assert 'public/publicrepo' not in repos
|
||||||
|
|
4
test/test_sni.py
Normal file
4
test/test_sni.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import ssl
|
||||||
|
|
||||||
|
def test_sni_support():
|
||||||
|
assert ssl.HAS_SNI
|
Reference in a new issue