Exemplo n.º 1
0
 def test_roles(self):
     """ A test """
     role = Role(id='none', role_id='none', ordinal=0)
     self.assertIsNotNone(role)
     role.put()
     found = Role.get_by_id('none')
     self.assertIsNotNone(found)
     self.assertEqual('none', found.key.id())
     self.assertEqual('none', found.role_id)
Exemplo n.º 2
0
    def delete(self, request):
        authorise(request.person, request.token)
        try:
            role = Role.get_by_id(request.id)
            role.key.delete();
            return message_types.VoidMessage()

        except (IndexError, TypeError):
            raise endpoints.NotFoundException('Role %s not found.' % (request.id,))
Exemplo n.º 3
0
    def test_user_role(self):
        """ A test """
        setup_roles()
        user = LocalUser.new_user(user_id='xyz', email='no@mail', roles=['user'])
        user.put()
        user_found = LocalUser.get_by_id('xyz')
        self.assertIsNotNone(user_found)
        self.assertEqual('xyz', user_found.user_id)
        self.assertEqual('no@mail', user_found.email)
        self.assertEqual('user', Role.get_by_id(user_found.get_role('user').id()).role_id)

        self.assertIsNone(user_found.get_role('admin'))
        self.assertEqual('user', user_found.get_role('user').id())
        self.assertEqual('user', user_found.get_role_id('user'))
        self.assertTrue(user_found.has_role('user'))
        self.assertFalse(user_found.has_role('admin'))