@@ 3606-3651 (lines=46) @@ | ||
3603 | # TODO - G.M - 2018-08-02 - Place cleanup outside of the test |
|
3604 | requests.delete('http://127.0.0.1:8025/api/v1/messages') |
|
3605 | ||
3606 | def test_api_delete_user__ok_200__admin(self): |
|
3607 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
3608 | admin = dbsession.query(models.User) \ |
|
3609 | .filter(models.User.email == '[email protected]') \ |
|
3610 | .one() |
|
3611 | uapi = UserApi( |
|
3612 | current_user=admin, |
|
3613 | session=dbsession, |
|
3614 | config=self.app_config, |
|
3615 | ) |
|
3616 | gapi = GroupApi( |
|
3617 | current_user=admin, |
|
3618 | session=dbsession, |
|
3619 | config=self.app_config, |
|
3620 | ) |
|
3621 | groups = [gapi.get_one_with_name('users')] |
|
3622 | test_user = uapi.create_user( |
|
3623 | email='[email protected]', |
|
3624 | password='pass', |
|
3625 | name='bob', |
|
3626 | groups=groups, |
|
3627 | timezone='Europe/Paris', |
|
3628 | lang='fr', |
|
3629 | do_save=True, |
|
3630 | do_notify=False, |
|
3631 | ) |
|
3632 | uapi.save(test_user) |
|
3633 | transaction.commit() |
|
3634 | user_id = int(test_user.user_id) |
|
3635 | ||
3636 | self.testapp.authorization = ( |
|
3637 | 'Basic', |
|
3638 | ( |
|
3639 | '[email protected]', |
|
3640 | '[email protected]' |
|
3641 | ) |
|
3642 | ) |
|
3643 | self.testapp.put( |
|
3644 | '/api/v2/users/{}/trashed'.format(user_id), |
|
3645 | status=204 |
|
3646 | ) |
|
3647 | res = self.testapp.get( |
|
3648 | '/api/v2/users/{}'.format(user_id), |
|
3649 | status=200 |
|
3650 | ).json_body |
|
3651 | assert res['is_deleted'] is True |
|
3652 | ||
3653 | def test_api_delete_user__err_400__admin_itself(self): |
|
3654 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
@@ 3738-3781 (lines=44) @@ | ||
3735 | ||
3736 | ||
3737 | ||
3738 | def test_api__get_user__err_403__normal_user(self): |
|
3739 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
3740 | admin = dbsession.query(models.User) \ |
|
3741 | .filter(models.User.email == '[email protected]') \ |
|
3742 | .one() |
|
3743 | uapi = UserApi( |
|
3744 | current_user=admin, |
|
3745 | session=dbsession, |
|
3746 | config=self.app_config, |
|
3747 | ) |
|
3748 | gapi = GroupApi( |
|
3749 | current_user=admin, |
|
3750 | session=dbsession, |
|
3751 | config=self.app_config, |
|
3752 | ) |
|
3753 | groups = [gapi.get_one_with_name('users')] |
|
3754 | test_user = uapi.create_user( |
|
3755 | email='[email protected]', |
|
3756 | password='pass', |
|
3757 | name='bob', |
|
3758 | groups=groups, |
|
3759 | timezone='Europe/Paris', |
|
3760 | lang='fr', |
|
3761 | do_save=True, |
|
3762 | do_notify=False, |
|
3763 | ) |
|
3764 | uapi.save(test_user) |
|
3765 | transaction.commit() |
|
3766 | user_id = int(test_user.user_id) |
|
3767 | ||
3768 | self.testapp.authorization = ( |
|
3769 | 'Basic', |
|
3770 | ( |
|
3771 | '[email protected]', |
|
3772 | 'pass' |
|
3773 | ) |
|
3774 | ) |
|
3775 | res = self.testapp.get( |
|
3776 | '/api/v2/users', |
|
3777 | status=403 |
|
3778 | ) |
|
3779 | assert isinstance(res.json, dict) |
|
3780 | assert 'code' in res.json.keys() |
|
3781 | assert res.json_body['code'] == error.INSUFFICIENT_USER_PROFILE |
|
3782 | ||
3783 | ||
3784 | class TestKnownMembersEndpoint(FunctionalTest): |