@@ 4489-4545 (lines=57) @@ | ||
4486 | assert not user.validate_password('pass') |
|
4487 | assert user.validate_password('mynewpassword') |
|
4488 | ||
4489 | def test_api__set_user_email__err_403__other_normal_user(self): |
|
4490 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
4491 | admin = dbsession.query(models.User) \ |
|
4492 | .filter(models.User.email == '[email protected]') \ |
|
4493 | .one() |
|
4494 | uapi = UserApi( |
|
4495 | current_user=admin, |
|
4496 | session=dbsession, |
|
4497 | config=self.app_config, |
|
4498 | ) |
|
4499 | gapi = GroupApi( |
|
4500 | current_user=admin, |
|
4501 | session=dbsession, |
|
4502 | config=self.app_config, |
|
4503 | ) |
|
4504 | groups = [gapi.get_one_with_name('users')] |
|
4505 | test_user = uapi.create_user( |
|
4506 | email='[email protected]', |
|
4507 | password='pass', |
|
4508 | name='bob', |
|
4509 | groups=groups, |
|
4510 | lang='fr', |
|
4511 | timezone='Europe/Paris', |
|
4512 | do_save=True, |
|
4513 | do_notify=False, |
|
4514 | ) |
|
4515 | test_user2 = uapi.create_user( |
|
4516 | email='[email protected]', |
|
4517 | password='pass', |
|
4518 | name='bob2', |
|
4519 | groups=groups, |
|
4520 | timezone='Europe/Paris', |
|
4521 | lang='fr', |
|
4522 | do_save=True, |
|
4523 | do_notify=False, |
|
4524 | ) |
|
4525 | uapi.save(test_user2) |
|
4526 | uapi.save(test_user) |
|
4527 | transaction.commit() |
|
4528 | user_id = int(test_user.user_id) |
|
4529 | ||
4530 | self.testapp.authorization = ( |
|
4531 | 'Basic', |
|
4532 | ( |
|
4533 | '[email protected]', |
|
4534 | 'pass' |
|
4535 | ) |
|
4536 | ) |
|
4537 | # Set password |
|
4538 | params = { |
|
4539 | 'email': '[email protected]', |
|
4540 | 'loggedin_user_password': '[email protected]', |
|
4541 | } |
|
4542 | self.testapp.put_json( |
|
4543 | '/api/v2/users/{}/email'.format(user_id), |
|
4544 | params=params, |
|
4545 | status=403, |
|
4546 | ) |
|
4547 | ||
4548 | ||
@@ 4168-4224 (lines=57) @@ | ||
4165 | res = res.json_body |
|
4166 | assert res['email'] == '[email protected]' |
|
4167 | ||
4168 | def test_api__set_user_email__err_403__other_normal_user(self): |
|
4169 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
4170 | admin = dbsession.query(models.User) \ |
|
4171 | .filter(models.User.email == '[email protected]') \ |
|
4172 | .one() |
|
4173 | uapi = UserApi( |
|
4174 | current_user=admin, |
|
4175 | session=dbsession, |
|
4176 | config=self.app_config, |
|
4177 | ) |
|
4178 | gapi = GroupApi( |
|
4179 | current_user=admin, |
|
4180 | session=dbsession, |
|
4181 | config=self.app_config, |
|
4182 | ) |
|
4183 | groups = [gapi.get_one_with_name('users')] |
|
4184 | test_user = uapi.create_user( |
|
4185 | email='[email protected]', |
|
4186 | password='pass', |
|
4187 | name='bob', |
|
4188 | groups=groups, |
|
4189 | timezone='Europe/Paris', |
|
4190 | lang='fr', |
|
4191 | do_save=True, |
|
4192 | do_notify=False, |
|
4193 | ) |
|
4194 | test_user2 = uapi.create_user( |
|
4195 | email='[email protected]', |
|
4196 | password='pass', |
|
4197 | name='bob2', |
|
4198 | groups=groups, |
|
4199 | timezone='Europe/Paris', |
|
4200 | lang='fr', |
|
4201 | do_save=True, |
|
4202 | do_notify=False, |
|
4203 | ) |
|
4204 | uapi.save(test_user2) |
|
4205 | uapi.save(test_user) |
|
4206 | transaction.commit() |
|
4207 | user_id = int(test_user.user_id) |
|
4208 | ||
4209 | self.testapp.authorization = ( |
|
4210 | 'Basic', |
|
4211 | ( |
|
4212 | '[email protected]', |
|
4213 | 'pass' |
|
4214 | ) |
|
4215 | ) |
|
4216 | # Set password |
|
4217 | params = { |
|
4218 | 'email': '[email protected]', |
|
4219 | 'loggedin_user_password': '[email protected]', |
|
4220 | } |
|
4221 | self.testapp.put_json( |
|
4222 | '/api/v2/users/{}/email'.format(user_id), |
|
4223 | params=params, |
|
4224 | status=403, |
|
4225 | ) |
|
4226 | ||
4227 | ||
@@ 4888-4943 (lines=56) @@ | ||
4885 | assert res['user_id'] == user_id |
|
4886 | assert res['profile'] == 'users' |
|
4887 | ||
4888 | def test_api__set_user_email__err_403__other_normal_user(self): |
|
4889 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
4890 | admin = dbsession.query(models.User) \ |
|
4891 | .filter(models.User.email == '[email protected]') \ |
|
4892 | .one() |
|
4893 | uapi = UserApi( |
|
4894 | current_user=admin, |
|
4895 | session=dbsession, |
|
4896 | config=self.app_config, |
|
4897 | ) |
|
4898 | gapi = GroupApi( |
|
4899 | current_user=admin, |
|
4900 | session=dbsession, |
|
4901 | config=self.app_config, |
|
4902 | ) |
|
4903 | groups = [gapi.get_one_with_name('users')] |
|
4904 | test_user = uapi.create_user( |
|
4905 | email='[email protected]', |
|
4906 | password='pass', |
|
4907 | name='bob', |
|
4908 | groups=groups, |
|
4909 | timezone='Europe/Paris', |
|
4910 | lang='fr', |
|
4911 | do_save=True, |
|
4912 | do_notify=False, |
|
4913 | ) |
|
4914 | test_user2 = uapi.create_user( |
|
4915 | email='[email protected]', |
|
4916 | password='pass', |
|
4917 | name='test', |
|
4918 | groups=groups, |
|
4919 | timezone='Europe/Paris', |
|
4920 | lang='fr', |
|
4921 | do_save=True, |
|
4922 | do_notify=False, |
|
4923 | ) |
|
4924 | uapi.save(test_user2) |
|
4925 | uapi.save(test_user) |
|
4926 | transaction.commit() |
|
4927 | user_id = int(test_user.user_id) |
|
4928 | ||
4929 | self.testapp.authorization = ( |
|
4930 | 'Basic', |
|
4931 | ( |
|
4932 | '[email protected]', |
|
4933 | 'pass', |
|
4934 | ) |
|
4935 | ) |
|
4936 | # Set params |
|
4937 | params = { |
|
4938 | 'profile': 'administrators', |
|
4939 | } |
|
4940 | self.testapp.put_json( |
|
4941 | '/api/v2/users/{}/profile'.format(user_id), |
|
4942 | params=params, |
|
4943 | status=403, |
|
4944 | ) |
|
4945 | ||
4946 | ||
@@ 3684-3737 (lines=54) @@ | ||
3681 | assert res[1]['public_name'] == test_user2.display_name |
|
3682 | assert res[1]['avatar_url'] is None |
|
3683 | ||
3684 | def test_api__get_user__err_403__admin__too_small_acp(self): |
|
3685 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
3686 | admin = dbsession.query(models.User) \ |
|
3687 | .filter(models.User.email == '[email protected]') \ |
|
3688 | .one() |
|
3689 | uapi = UserApi( |
|
3690 | current_user=admin, |
|
3691 | session=dbsession, |
|
3692 | config=self.app_config, |
|
3693 | ) |
|
3694 | gapi = GroupApi( |
|
3695 | current_user=admin, |
|
3696 | session=dbsession, |
|
3697 | config=self.app_config, |
|
3698 | ) |
|
3699 | groups = [gapi.get_one_with_name('users')] |
|
3700 | test_user = uapi.create_user( |
|
3701 | email='[email protected]', |
|
3702 | password='pass', |
|
3703 | name='bob', |
|
3704 | groups=groups, |
|
3705 | timezone='Europe/Paris', |
|
3706 | lang='fr', |
|
3707 | do_save=True, |
|
3708 | do_notify=False, |
|
3709 | ) |
|
3710 | test_user2 = uapi.create_user( |
|
3711 | email='[email protected]', |
|
3712 | password='pass', |
|
3713 | name='bob2', |
|
3714 | groups=groups, |
|
3715 | timezone='Europe/Paris', |
|
3716 | lang='fr', |
|
3717 | do_save=True, |
|
3718 | do_notify=False, |
|
3719 | ) |
|
3720 | uapi.save(test_user) |
|
3721 | transaction.commit() |
|
3722 | user_id = int(admin.user_id) |
|
3723 | ||
3724 | self.testapp.authorization = ( |
|
3725 | 'Basic', |
|
3726 | ( |
|
3727 | '[email protected]', |
|
3728 | '[email protected]' |
|
3729 | ) |
|
3730 | ) |
|
3731 | params = { |
|
3732 | 'acp': 't', |
|
3733 | } |
|
3734 | res = self.testapp.get( |
|
3735 | '/api/v2/users/{user_id}/known_members'.format(user_id=user_id), |
|
3736 | status=400, |
|
3737 | params=params |
|
3738 | ) |
|
3739 | ||
3740 | def test_api__get_user__ok_200__normal_user_by_email(self): |