Make test more resilient to changes in IDs
This commit is contained in:
parent
a3aa4592cf
commit
b5b2df2063
2 changed files with 22 additions and 15 deletions
|
@ -184,8 +184,8 @@ class QuayDeferredPermissionUser(Identity):
|
|||
return super(QuayDeferredPermissionUser, self).can(permission)
|
||||
|
||||
# Check for namespace and/or repository permissions.
|
||||
perm_namespace = getattr(permission, 'namespace', None)
|
||||
perm_repo_name = getattr(permission, 'repo_name', None)
|
||||
perm_namespace = permission.namespace
|
||||
perm_repo_name = permission.repo_name
|
||||
perm_repository = None
|
||||
|
||||
if perm_namespace and perm_repo_name:
|
||||
|
@ -212,7 +212,13 @@ class QuayDeferredPermissionUser(Identity):
|
|||
return super(QuayDeferredPermissionUser, self).can(permission)
|
||||
|
||||
|
||||
class ModifyRepositoryPermission(Permission):
|
||||
class QuayPermission(Permission):
|
||||
""" Base for all permissions in Quay. """
|
||||
namespace = None
|
||||
repo_name = None
|
||||
|
||||
|
||||
class ModifyRepositoryPermission(QuayPermission):
|
||||
def __init__(self, namespace, name):
|
||||
admin_need = _RepositoryNeed(namespace, name, 'admin')
|
||||
write_need = _RepositoryNeed(namespace, name, 'write')
|
||||
|
@ -226,7 +232,7 @@ class ModifyRepositoryPermission(Permission):
|
|||
org_write_need)
|
||||
|
||||
|
||||
class ReadRepositoryPermission(Permission):
|
||||
class ReadRepositoryPermission(QuayPermission):
|
||||
def __init__(self, namespace, name):
|
||||
admin_need = _RepositoryNeed(namespace, name, 'admin')
|
||||
write_need = _RepositoryNeed(namespace, name, 'write')
|
||||
|
@ -242,7 +248,7 @@ class ReadRepositoryPermission(Permission):
|
|||
org_admin_need, org_read_need, org_write_need)
|
||||
|
||||
|
||||
class AdministerRepositoryPermission(Permission):
|
||||
class AdministerRepositoryPermission(QuayPermission):
|
||||
def __init__(self, namespace, name):
|
||||
admin_need = _RepositoryNeed(namespace, name, 'admin')
|
||||
org_admin_need = _OrganizationRepoNeed(namespace, 'admin')
|
||||
|
@ -254,7 +260,7 @@ class AdministerRepositoryPermission(Permission):
|
|||
org_admin_need)
|
||||
|
||||
|
||||
class CreateRepositoryPermission(Permission):
|
||||
class CreateRepositoryPermission(QuayPermission):
|
||||
def __init__(self, namespace):
|
||||
admin_org = _OrganizationNeed(namespace, 'admin')
|
||||
create_repo_org = _OrganizationNeed(namespace, 'creator')
|
||||
|
@ -264,26 +270,26 @@ class CreateRepositoryPermission(Permission):
|
|||
super(CreateRepositoryPermission, self).__init__(admin_org,
|
||||
create_repo_org)
|
||||
|
||||
class SuperUserPermission(Permission):
|
||||
class SuperUserPermission(QuayPermission):
|
||||
def __init__(self):
|
||||
need = _SuperUserNeed()
|
||||
super(SuperUserPermission, self).__init__(need)
|
||||
|
||||
|
||||
class UserAdminPermission(Permission):
|
||||
class UserAdminPermission(QuayPermission):
|
||||
def __init__(self, username):
|
||||
user_admin = _UserNeed(username, 'admin')
|
||||
super(UserAdminPermission, self).__init__(user_admin)
|
||||
|
||||
|
||||
class UserReadPermission(Permission):
|
||||
class UserReadPermission(QuayPermission):
|
||||
def __init__(self, username):
|
||||
user_admin = _UserNeed(username, 'admin')
|
||||
user_read = _UserNeed(username, 'read')
|
||||
super(UserReadPermission, self).__init__(user_read, user_admin)
|
||||
|
||||
|
||||
class AdministerOrganizationPermission(Permission):
|
||||
class AdministerOrganizationPermission(QuayPermission):
|
||||
def __init__(self, org_name):
|
||||
admin_org = _OrganizationNeed(org_name, 'admin')
|
||||
|
||||
|
@ -292,7 +298,7 @@ class AdministerOrganizationPermission(Permission):
|
|||
super(AdministerOrganizationPermission, self).__init__(admin_org)
|
||||
|
||||
|
||||
class OrganizationMemberPermission(Permission):
|
||||
class OrganizationMemberPermission(QuayPermission):
|
||||
def __init__(self, org_name):
|
||||
admin_org = _OrganizationNeed(org_name, 'admin')
|
||||
repo_creator_org = _OrganizationNeed(org_name, 'creator')
|
||||
|
@ -304,7 +310,7 @@ class OrganizationMemberPermission(Permission):
|
|||
repo_creator_org)
|
||||
|
||||
|
||||
class ViewTeamPermission(Permission):
|
||||
class ViewTeamPermission(QuayPermission):
|
||||
def __init__(self, org_name, team_name):
|
||||
team_admin = _TeamNeed(org_name, team_name, 'admin')
|
||||
team_creator = _TeamNeed(org_name, team_name, 'creator')
|
||||
|
@ -317,7 +323,7 @@ class ViewTeamPermission(Permission):
|
|||
team_member, admin_org)
|
||||
|
||||
|
||||
class AlwaysFailPermission(Permission):
|
||||
class AlwaysFailPermission(QuayPermission):
|
||||
def can(self):
|
||||
return False
|
||||
|
||||
|
|
|
@ -2286,9 +2286,10 @@ class TestListAndDeleteTag(ApiTestCase):
|
|||
def test_listtagpagination(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
latest_image = model.tag.get_tag_image(ADMIN_ACCESS_USER, "complex", "prod")
|
||||
|
||||
for i in xrange(1, 100):
|
||||
model.tag.create_or_update_tag(ADMIN_ACCESS_USER, "complex", "tag" + str(i),
|
||||
"1d8cbff4e0363d1826c6a0b64ef0bc501d8cbff4e0363d1826c6a0b64ef0bc50")
|
||||
model.tag.create_or_update_tag(ADMIN_ACCESS_USER, "complex", "tag" + str(i), latest_image.docker_image_id)
|
||||
|
||||
json = self.getJsonResponse(ListRepositoryTags,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/complex', page=2))
|
||||
|
|
Reference in a new issue