Make sure we don't internal error when signing is disabled
This commit is contained in:
parent
14054a237a
commit
8981fcab78
2 changed files with 11 additions and 2 deletions
|
@ -378,7 +378,7 @@ class Repository(RepositoryParamResource):
|
|||
'is_organization': repo.namespace_user.organization,
|
||||
'is_starred': is_starred,
|
||||
'status_token': repo.badge_token if not is_public else '',
|
||||
'trust_enabled': features.SIGNING and repo.trust_enabled,
|
||||
'trust_enabled': bool(features.SIGNING) and repo.trust_enabled,
|
||||
}
|
||||
|
||||
if stats is not None:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import pytest
|
||||
|
||||
from endpoints.api.test.shared import client_with_identity, conduct_api_call
|
||||
from endpoints.api.repository import RepositoryTrust
|
||||
from endpoints.api.repository import RepositoryTrust, Repository
|
||||
from features import FeatureNameValue
|
||||
from test.fixtures import app, appconfig, database_uri, init_db_path, sqlitedb_file
|
||||
from mock import patch, ANY, MagicMock
|
||||
|
||||
|
@ -40,3 +41,11 @@ def test_post_changetrust(trust_enabled, repo_found, expected_body, expected_sta
|
|||
params = {'repository': 'devtable/repo'}
|
||||
request_body = {'trust_enabled': trust_enabled}
|
||||
assert expected_body == conduct_api_call(cl, RepositoryTrust, 'POST', params, request_body, expected_status).json
|
||||
|
||||
|
||||
def test_signing_disabled(client):
|
||||
with patch('features.SIGNING', FeatureNameValue('SIGNING', False)):
|
||||
with client_with_identity('devtable', client) as cl:
|
||||
params = {'repository': 'devtable/simple'}
|
||||
response = conduct_api_call(cl, Repository, 'GET', params).json
|
||||
assert not response['trust_enabled']
|
||||
|
|
Reference in a new issue