~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to test/unit/common/middleware/test_keystoneauth.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, James Page, Chuck Short
  • Date: 2013-08-13 10:37:13 UTC
  • mfrom: (1.2.21)
  • Revision ID: package-import@ubuntu.com-20130813103713-1ctbx4zifyljs2aq
Tags: 1.9.1-0ubuntu1
[ James Page ]
* d/control: Update VCS fields for new branch locations.

[ Chuck Short ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
        account = tenant_id = 'foo'
117
117
        self.assertTrue(test_auth._reseller_check(account, tenant_id))
118
118
 
 
119
    def test_reseller_prefix_added_underscore(self):
 
120
        conf = {'reseller_prefix': 'AUTH'}
 
121
        test_auth = keystoneauth.filter_factory(conf)(FakeApp())
 
122
        self.assertEqual(test_auth.reseller_prefix, "AUTH_")
 
123
 
 
124
    def test_reseller_prefix_not_added_double_underscores(self):
 
125
        conf = {'reseller_prefix': 'AUTH_'}
 
126
        test_auth = keystoneauth.filter_factory(conf)(FakeApp())
 
127
        self.assertEqual(test_auth.reseller_prefix, "AUTH_")
 
128
 
119
129
    def test_override_asked_for_but_not_allowed(self):
120
130
        conf = {'allow_overrides': 'false'}
121
131
        self.test_auth = keystoneauth.filter_factory(conf)(FakeApp())
192
202
        req = self._make_request(path, headers=headers, environ=default_env)
193
203
        req.acl = acl
194
204
        result = self.test_auth.authorize(req)
195
 
        if exception:
 
205
 
 
206
        # if we have requested an exception but nothing came back then
 
207
        if exception and not result:
 
208
            self.fail("error %s was not returned" % (str(exception)))
 
209
        elif exception:
196
210
            self.assertEquals(result.status_int, exception)
197
211
        else:
198
212
            self.assertTrue(result is None)
325
339
        self.assertEqual(self.test_auth._authorize_cross_tenant('userID',
326
340
            'userA', 'tenantID', 'tenantNAME', ['tenantXYZ:userA']), None)
327
341
 
 
342
    def test_delete_own_account_not_allowed(self):
 
343
        roles = self.test_auth.operator_roles.split(',')
 
344
        identity = self._get_identity(roles=roles)
 
345
        account = self._get_account(identity)
 
346
        self._check_authenticate(account=account,
 
347
                                 identity=identity,
 
348
                                 exception=HTTP_FORBIDDEN,
 
349
                                 path='/v1/' + account,
 
350
                                 env={'REQUEST_METHOD': 'DELETE'})
 
351
 
 
352
    def test_delete_own_account_when_reseller_allowed(self):
 
353
        roles = [self.test_auth.reseller_admin_role]
 
354
        identity = self._get_identity(roles=roles)
 
355
        account = self._get_account(identity)
 
356
        req = self._check_authenticate(account=account,
 
357
                                       identity=identity,
 
358
                                       path='/v1/' + account,
 
359
                                       env={'REQUEST_METHOD': 'DELETE'})
 
360
        self.assertEqual(bool(req.environ.get('swift_owner')), True)
328
361
 
329
362
if __name__ == '__main__':
330
363
    unittest.main()