This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/endpoints/api/test/test_permission.py

24 lines
1.2 KiB
Python
Raw Permalink Normal View History

2019-11-12 16:09:47 +00:00
import pytest
from endpoints.api.test.shared import conduct_api_call
from endpoints.api.permission import RepositoryUserPermission
from endpoints.test.shared import client_with_identity
from test.fixtures import *
@pytest.mark.parametrize('repository, username, expected_code', [
pytest.param('devtable/simple', 'public', 200, id='valid user under user'),
pytest.param('devtable/simple', 'devtable+dtrobot', 200, id='valid robot under user'),
pytest.param('devtable/simple', 'buynlarge+coolrobot', 400, id='invalid robot under user'),
pytest.param('buynlarge/orgrepo', 'devtable', 200, id='valid user under org'),
pytest.param('buynlarge/orgrepo', 'devtable+dtrobot', 400, id='invalid robot under org'),
pytest.param('buynlarge/orgrepo', 'buynlarge+coolrobot', 200, id='valid robot under org'),
])
def test_robot_permission(repository, username, expected_code, client):
with client_with_identity('devtable', client) as cl:
conduct_api_call(cl, RepositoryUserPermission, 'PUT',
{'repository': repository, 'username': username},
body={
'role': 'read',
},
expected_code=expected_code)