Extend registry auth to support notary JWTs.
This commit is contained in:
parent
f02d295dd8
commit
8323c51e6e
2 changed files with 35 additions and 9 deletions
|
@ -703,7 +703,7 @@ class V1RegistryLoginMixin(object):
|
|||
|
||||
|
||||
class V2RegistryLoginMixin(object):
|
||||
def do_login(self, username, password, scope, expect_success=True):
|
||||
def do_login(self, username, password, scope, expect_success=True, expected_failure_code=401):
|
||||
params = {
|
||||
'account': username,
|
||||
'scope': scope,
|
||||
|
@ -713,7 +713,7 @@ class V2RegistryLoginMixin(object):
|
|||
if expect_success:
|
||||
expected_code = 200
|
||||
else:
|
||||
expected_code = 401
|
||||
expected_code = expected_failure_code
|
||||
|
||||
auth = None
|
||||
if username and password:
|
||||
|
@ -1757,8 +1757,9 @@ class V2LoginTests(V2RegistryLoginMixin, LoginTests, RegistryTestCaseMixin, Base
|
|||
return cert_obj.public_key()
|
||||
|
||||
|
||||
def do_logincheck(self, username, password, scope, expected_actions=[], expect_success=True):
|
||||
response = self.do_login(username, password, scope, expect_success=expect_success)
|
||||
def do_logincheck(self, username, password, scope, expected_actions=[], expect_success=True,
|
||||
**kwargs):
|
||||
response = self.do_login(username, password, scope, expect_success=expect_success, **kwargs)
|
||||
|
||||
if not expect_success:
|
||||
return
|
||||
|
@ -1803,6 +1804,21 @@ class V2LoginTests(V2RegistryLoginMixin, LoginTests, RegistryTestCaseMixin, Base
|
|||
scope='repository:devtable/simple:pull',
|
||||
expected_actions=[])
|
||||
|
||||
def test_validuser_withendpoint(self):
|
||||
self.do_logincheck('devtable', 'password', expect_success=True,
|
||||
scope='repository:localhost:5000/devtable/simple:pull,push',
|
||||
expected_actions=['push', 'pull'])
|
||||
|
||||
def test_validuser_invalid_endpoint(self):
|
||||
self.do_logincheck('public', 'password', expect_success=False, expected_failure_code=400,
|
||||
scope='repository:someotherrepo.com/devtable/simple:pull,push',
|
||||
expected_actions=[])
|
||||
|
||||
def test_validuser_malformed_endpoint(self):
|
||||
self.do_logincheck('public', 'password', expect_success=False, expected_failure_code=400,
|
||||
scope='repository:localhost:5000/registryroot/devtable/simple:pull,push',
|
||||
expected_actions=[])
|
||||
|
||||
def test_validuser_noscope(self):
|
||||
self.do_logincheck('public', 'password', expect_success=True, scope=None)
|
||||
|
||||
|
|
Reference in a new issue