1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#
# Copyright (C) 2019-2025 Mathieu Parent <math.parent@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from gitlabracadabra.objects.user import GitLabracadabraUser
from gitlabracadabra.tests import my_vcr
from gitlabracadabra.tests.case import TestCaseWithManager
class TestUser(TestCaseWithManager):
@my_vcr.use_cassette
def test_no_create(self, cass):
obj = GitLabracadabraUser("memory", "no_create_user", {})
assert obj.errors() == []
obj.process()
assert cass.all_played
@my_vcr.use_cassette
def test_create(self, cass):
obj = GitLabracadabraUser(
"memory",
"create_user",
{
"create_object": True,
"email": "create_user@example.org",
"name": "Create User",
"password": "P@ssw0rdNot24get",
},
)
# FIXME: self.assertEqual(obj.errors(), [])
obj.process()
assert cass.all_played
@my_vcr.use_cassette
def test_delete(self, cass):
obj = GitLabracadabraUser("memory", "delete_this_user", {"delete_object": True})
assert obj.errors() == []
obj.process()
assert cass.all_played
@my_vcr.use_cassette
def test_exists(self, cass):
obj = GitLabracadabraUser("memory", "user_exists", {})
assert obj.errors() == []
obj.process()
assert cass.all_played
@my_vcr.use_cassette
def test_simple_parameters(self, cass):
obj = GitLabracadabraUser(
"memory",
"user_simple_parameters",
{
"name": "user-with-simple-parameters",
"email": "user-with-simple-parameters@example.org",
"skip_confirmation": True,
"skip_reconfirmation": True,
"public_email": "contact@example.org",
"password": "P@ss12345678",
# 'reset_password'
"projects_limit": 42,
"can_create_group": False,
"admin": True,
"external": True,
"shared_runners_minutes_limit": 42,
"extra_shared_runners_minutes_limit": 42,
# 'avatar'
"skype": "12345",
"linkedin": "linked_in",
"twitter": "t_w_i_t_t_e_r",
"website_url": "https://example.org",
"location": "Nowhere",
"organization": "My Corp",
"bio": "Not much",
"private_profile": True,
"note": "Fake account?",
"extern_uid": "12345678",
"provider": "github",
# 'color_scheme_id'
# 'theme_id'
# 'force_random_password'
# 'group_id_for_saml'
# 'view_diffs_file_by_file'
},
)
assert obj.errors() == []
obj.process()
assert cass.all_played
@my_vcr.use_cassette
def test_block(self, cass):
# from active
obj = GitLabracadabraUser("memory", "userfoo", {"state": "blocked"})
assert obj.errors() == []
obj.process()
assert cass.all_played
@my_vcr.use_cassette
def test_unblock(self, cass):
# from blocked
obj = GitLabracadabraUser("memory", "userfoo", {"state": "active"})
assert obj.errors() == []
obj.process()
assert cass.all_played
@my_vcr.use_cassette
def test_deactivate(self, cass):
# from active
obj = GitLabracadabraUser("memory", "userfoo", {"state": "deactivated"})
assert obj.errors() == []
obj.process()
assert cass.all_played
@my_vcr.use_cassette
def test_activate(self, cass):
# from deactivated
obj = GitLabracadabraUser("memory", "userfoo", {"state": "active"})
assert obj.errors() == []
obj.process()
assert cass.all_played
|