Ensure that we limit the length of repository names
Until now, they'd simply be truncated by the database. Now, we properly check their lengths. Fixes https://jira.coreos.com/browse/QUAY-963
This commit is contained in:
parent
beebe6d5ed
commit
a572fd33c7
6 changed files with 41 additions and 7 deletions
|
@ -96,3 +96,24 @@ def test_list_starred_repos(client):
|
|||
repos = {r['namespace'] + '/' + r['name'] for r in response['repositories']}
|
||||
assert 'devtable/simple' in repos
|
||||
assert 'public/publicrepo' not in repos
|
||||
|
||||
|
||||
@pytest.mark.parametrize('repo_name, expected_status', [
|
||||
pytest.param('x' * 255, 201, id='Maximum allowed length'),
|
||||
pytest.param('x' * 256, 400, id='Over allowed length'),
|
||||
pytest.param('a|b', 400, id='Invalid name'),
|
||||
])
|
||||
def test_create_repository(repo_name, expected_status, client):
|
||||
with client_with_identity('devtable', client) as cl:
|
||||
body = {
|
||||
'namespace': 'devtable',
|
||||
'repository': repo_name,
|
||||
'visibility': 'public',
|
||||
'description': 'foo',
|
||||
}
|
||||
|
||||
result = conduct_api_call(client, RepositoryList, 'post', None, body,
|
||||
expected_code=expected_status).json
|
||||
if expected_status == 201:
|
||||
assert result['name'] == repo_name
|
||||
assert model.repository.get_repository('devtable', repo_name).name == repo_name
|
||||
|
|
Reference in a new issue