Add request.environ[reseller_request] = True

This commit is contained in:
Christian Schwede 2013-03-08 18:56:19 +01:00
parent 35fff4d4ef
commit e94aeb7f1c
2 changed files with 12 additions and 0 deletions

View File

@ -210,6 +210,8 @@ class Swauth(object):
'%s,%s' % (user, 's3' if s3 else token)
env['swift.authorize'] = self.authorize
env['swift.clean_acl'] = clean_acl
if '.reseller_admin' in groups:
env['reseller_request'] = True
else:
# Unauthorized token
if self.reseller_prefix and token and \

View File

@ -471,6 +471,16 @@ class TestAuth(unittest.TestCase):
req.acl = '.r:.example.com,.rlistings'
self.assertEquals(self.test_auth.authorize(req), None)
def test_detect_reseller_request(self):
req = self._make_request('/v1/AUTH_admin',
headers={'X-Auth-Token': 'AUTH_t'})
cache_key = 'AUTH_/auth/AUTH_t'
cache_entry = (time()+3600, '.reseller_admin')
req.environ['swift.cache'].set(cache_key, cache_entry)
resp = req.get_response(self.test_auth)
print req.environ
self.assertTrue(req.environ.get('reseller_request', False))
def test_account_put_permissions(self):
req = Request.blank('/v1/AUTH_new', environ={'REQUEST_METHOD': 'PUT'})
req.remote_user = 'act:usr,act'