Esempio n. 1
0
 def test_user_add_project(self):
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     user_add_project('charlie', 'acme-corp')
     user = api._must_find(User, 'charlie')
     project = api._must_find(model.Project, 'acme-corp')
     assert project in user.projects
     assert user in project.users
Esempio n. 2
0
 def test_user_add_project(self):
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     user_add_project('charlie', 'acme-corp')
     user = api._must_find(User, 'charlie')
     project = api._must_find(model.Project, 'acme-corp')
     assert project in user.projects
     assert user in project.users
Esempio n. 3
0
    def _new_user(self, is_admin):
        """Helper method for creating/switching to a new user.

        A new admin user will be created with the credentials:

        username: '******'
        password: '******'

        The argument is_admin determines whether the user has admin rights.

        Once the user has been created, the authentication info will be
        changed to that user.
        """
        user_create('charlie', 'foo', is_admin=is_admin)
        flask.request = FakeAuthRequest('charlie', 'foo')
        local.auth = User.query.filter_by(label='charlie').one()
Esempio n. 4
0
    def _new_user(self, is_admin):
        """Helper method for creating/switching to a new user.

        A new admin user will be created with the credentials:

        username: '******'
        password: '******'

        The argument is_admin determines whether the user has admin rights.

        Once the user has been created, the authentication info will be
        changed to that user.
        """
        user_create('charlie', 'foo', is_admin=is_admin)
        flask.request = FakeAuthRequest('charlie', 'foo')
        local.auth = User.query.filter_by(label='charlie').one()
Esempio n. 5
0
 def test_bad_user_remove_project(self):
     """Tests that removing a user from a project they're not in fails."""
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     with pytest.raises(api.NotFoundError):
         user_remove_project('charlie', 'acme-corp')
Esempio n. 6
0
 def test_duplicate_user_add_project(self):
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     user_add_project('charlie', 'acme-corp')
     with pytest.raises(api.DuplicateError):
         user_add_project('charlie', 'acme-corp')
Esempio n. 7
0
 def test_delete_user_twice(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
     with pytest.raises(api.NotFoundError):
         user_delete('charlie')
Esempio n. 8
0
 def test_delete_user(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
Esempio n. 9
0
 def test_duplicate_user(self):
     user_create('charlie', 'secret')
     with pytest.raises(api.DuplicateError):
             user_create('charlie', 'password')
Esempio n. 10
0
 def test_new_user(self):
     api._assert_absent(User, 'charlie')
     user_create('charlie', 'foo')
Esempio n. 11
0
 def test_bad_user_remove_project(self):
     """Tests that removing a user from a project they're not in fails."""
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     with pytest.raises(api.NotFoundError):
         user_remove_project('charlie', 'acme-corp')
Esempio n. 12
0
 def test_duplicate_user_add_project(self):
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     user_add_project('charlie', 'acme-corp')
     with pytest.raises(api.DuplicateError):
         user_add_project('charlie', 'acme-corp')
Esempio n. 13
0
 def test_delete_user_twice(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
     with pytest.raises(api.NotFoundError):
         user_delete('charlie')
Esempio n. 14
0
 def test_delete_user(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
Esempio n. 15
0
 def test_duplicate_user(self):
     user_create('charlie', 'secret')
     with pytest.raises(api.DuplicateError):
             user_create('charlie', 'password')
Esempio n. 16
0
 def test_new_user(self):
     api._assert_absent(User, 'charlie')
     user_create('charlie', 'foo')