Browse files

Add request.environ[reseller_request] = True

  • Loading branch information...
1 parent 35fff4d commit e94aeb7f1ca87bee41a8d33abbf1b8a81f866f16 @cschwede cschwede committed Mar 8, 2013
Showing with 12 additions and 0 deletions.
  1. +2 −0 swauth/middleware.py
  2. +10 −0 test_swauth/unit/test_middleware.py
View
2 swauth/middleware.py
@@ -210,6 +210,8 @@ def __call__(self, env, start_response):
'%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
10 test_swauth/unit/test_middleware.py
@@ -471,6 +471,16 @@ def test_authorize_acl_referrer_access(self):
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'

0 comments on commit e94aeb7

Please sign in to comment.