Beispiel #1
0
class UserTest(unittest.TestCase):
    def runTest(self):
        unittest.main()

    def setUp(self):
        # Generate random 16 byte username
        u = uuid4()
        m = md5(u.bytes)
        self.username = m.hexdigest()[:16]

        # Use full username as temporary password
        self.password = m.hexdigest()

        self.user = User()

    def test_add_user(self):
        home = '/home/' + self.username

        assert self.user.adduser(
            self.username, 
            self.password, 
            home
        )

    def test_delete_user(self):
        assert self.user.deluser(self.username)
Beispiel #2
0
        soft_quota = opts.soft_quota,
        hard_quota = opts.hard_quota,
        pusher_link = pusher_link
    )
)

confirm_answer = raw_input('Confirm with yes or no: ')
if confirm_answer != 'yes':
    exit(0)

try:
    user.adduser(
        username = username, 
        password = encrypted_password, 
        home = opts.directory, 
        groups = opts.groups.split(','), 
        comment = opts.comment.decode('utf-8'),
        email = opts.email,
        phone = opts.phone,
        quota = (opts.soft_quota, opts.hard_quota)
    )

    # 4d-bug
    #print(username, encrypted_password, opts.directory, opts.groups.split(','), opts.comment)
except Exception as e:
    print('Problem adding user=%s, groups=%s: %s' % (
        username.encode('utf-8'), 
        opts.groups.split(','), 
        str(e)
    ), file=stderr)
    exit(1)