Ejemplo n.º 1
0
 def setUp(self):
     model.rebuild_db()
     self.root, self.user1, self.user2 = Fixtures.create_users()
     self.app = Fixtures.create_app('')
     self.app.owner = self.root
     db.session.add(self.app)
     db.session.commit()
     self.task = model.Task(app_id=self.app.id, state='0', n_answers=10)
     self.task.app = self.app
     db.session.add(self.task)
     db.session.commit()
Ejemplo n.º 2
0
 def setUp(self):
     model.rebuild_db()
     self.root, self.user1, self.user2 = Fixtures.create_users()
     self.app = Fixtures.create_app('')
     self.app.owner = self.root
     db.session.add(self.app)
     db.session.commit()
     self.task = model.Task(app_id=self.app.id, state='0', n_answers=10)
     self.task.app = self.app
     db.session.add(self.task)
     db.session.commit()
Ejemplo n.º 3
0
 def test_get_breadth_first_task_user(self):
     user = Fixtures.create_users()[0]
     self._test_get_breadth_first_task(user)
Ejemplo n.º 4
0
 def test_get_breadth_first_task_user(self):
     user = Fixtures.create_users()[0]
     self._test_get_breadth_first_task(user)
Ejemplo n.º 5
0
class TestTokenAuthorization:

    auth_providers = ('twitter', 'facebook', 'google')
    root, user1, user2 = Fixtures.create_users()


    def test_anonymous_user_delete(self):
        """Test anonymous user is not allowed to delete an oauth token"""
        token_authorization.current_user = FakeCurrentUser()

        for token in self.auth_providers:
            assert not token_authorization.delete(token)

    def test_authenticated_user_delete(self):
        """Test authenticated user is not allowed to delete an oauth token"""
        token_authorization.current_user = FakeCurrentUser(self.root)

        for token in self.auth_providers:
            assert not token_authorization.delete(token)

    def test_anonymous_user_create(self):
        """Test anonymous user is not allowed to create an oauth token"""
        token_authorization.current_user = FakeCurrentUser()

        for token in self.auth_providers:
            assert not token_authorization.create(token)

    def test_authenticated_user_create(self):
        """Test authenticated user is not allowed to create an oauth token"""
        token_authorization.current_user = FakeCurrentUser(self.root)

        for token in self.auth_providers:
            assert not token_authorization.create(token)

    def test_anonymous_user_update(self):
        """Test anonymous user is not allowed to update an oauth token"""
        token_authorization.current_user = FakeCurrentUser()

        for token in self.auth_providers:
            assert not token_authorization.update(token)

    def test_authenticated_user_update(self):
        """Test authenticated user is not allowed to update an oauth token"""
        token_authorization.current_user = FakeCurrentUser(self.root)

        for token in self.auth_providers:
            assert not token_authorization.update(token)

    def test_anonymous_user_read(self):
        """Test anonymous user is not allowed to read an oauth token"""
        token_authorization.current_user = FakeCurrentUser()

        for token in self.auth_providers:
            assert not token_authorization.read(token)

    def test_authenticated_user_read(self):
        """Test authenticated user is allowed to read his own oauth tokens"""
        token_authorization.current_user = FakeCurrentUser(self.root)

        for token in self.auth_providers:
            assert token_authorization.read(token)