Esempio n. 1
0
 def test_set_exceptions(self):
     p = Permission(policy='open', exceptions=['foo'])
     # good
     p.exceptions = ['foo', 'bar']
     self.assertEqual(['foo', 'bar'], p.exceptions)
     p.exceptions.append('baz')
     self.assertEqual(['foo', 'bar', 'baz'], p.exceptions)
Esempio n. 2
0
 def test_set_policy(self):
     p = Permission(policy='closed')
     # good
     p.policy = 'open'
     self.assertEquals('open', p.policy)
     p.policy = 'closed'
     self.assertEquals('closed', p.policy)
Esempio n. 3
0
 def test_set_exceptions(self):
     p = Permission(policy='open', exceptions=['foo'])
     # good
     p.exceptions = ['foo', 'bar']
     self.assertEqual(['foo', 'bar'], p.exceptions)
     p.exceptions.append('baz')
     self.assertEqual(['foo', 'bar', 'baz'], p.exceptions)
Esempio n. 4
0
 def test_set_policy(self):
     p = Permission(policy='closed')
     # good
     p.policy = 'open'
     self.assertEquals('open', p.policy)
     p.policy = 'closed'
     self.assertEquals('closed', p.policy)
Esempio n. 5
0
 def test_init(self):
     # default
     p = Permission()
     self.assertEquals('open', p.policy)
     self.assertEquals([], p.exceptions)
     # overridden
     p = Permission(policy='closed', exceptions=[
         'foo',
     ])
     self.assertEquals('closed', p.policy)
     self.assertEquals([
         'foo',
     ], p.exceptions)
Esempio n. 6
0
 def testSet(self):
     p = Permissions(self.api.permissions.namespaces['test'])
     policy = Permission(policy='closed', exceptions=[
         'test',
     ])
     # good
     p['create'] = policy
     self.assertEquals(self.db.reqs[0],
                       ('PUT', '/permissions/namespaces/test', {
                           u'policy': 'closed',
                           u'exceptions': ['test']
                       }, {
                           u'action': 'create'
                       }, None))
     self.db.add_resp(200, 'application/json',
                      '{"policy": "closed", "exceptions": ["test"]}')
     check_policy = p['create']
     self.assertEquals(self.db.reqs[1],
                       ('GET', '/permissions/namespaces/test', NO_CONTENT, {
                           u'action': 'create'
                       }, None))
     self.assertEquals(policy.policy, check_policy.policy)
     self.assertEquals(policy.exceptions, check_policy.exceptions)