Ejemplo n.º 1
0
    def test_create_with_attr(self, stageduser2, user, user_activated):
        """ Tests creating a user with various valid attributes listed
        in 'options_ok' list"""
        # create staged user with specified parameters
        user.ensure_exists()  # necessary for manager test
        stageduser2.ensure_missing()
        command = stageduser2.make_create_command()
        result = command()
        stageduser2.track_create()
        stageduser2.check_create(result)

        # activate user, verify that specified values were preserved
        # after activation
        user_activated.ensure_missing()
        user_activated = UserTracker(stageduser2.uid, stageduser2.givenname,
                                     stageduser2.sn, **stageduser2.kwargs)
        user_activated.create_from_staged(stageduser2)
        command = stageduser2.make_activate_command()
        result = command()
        user_activated.check_activate(result)

        # verify the staged user does not exist after activation
        command = stageduser2.make_retrieve_command()
        with raises_exact(
                errors.NotFound(reason=u'%s: stage user not found' %
                                stageduser2.uid)):
            command()

        user_activated.delete()
Ejemplo n.º 2
0
 def test_create_with_username_starting_with_numeric(self):
     """Successfully create a user with name starting with numeric chars"""
     testuser = UserTracker(
         name=u'1234user', givenname=u'First1234', sn=u'Surname1234',
     )
     testuser.create()
     testuser.delete()
Ejemplo n.º 3
0
    def test_create_with_attr(self, stageduser2, user, user_activated):
        """ Tests creating a user with various valid attributes listed
        in 'options_ok' list"""
        # create staged user with specified parameters
        user.ensure_exists()  # necessary for manager test
        stageduser2.ensure_missing()
        command = stageduser2.make_create_command()
        result = command()
        stageduser2.track_create()
        stageduser2.check_create(result)

        # activate user, verify that specified values were preserved
        # after activation
        user_activated.ensure_missing()
        user_activated = UserTracker(
            stageduser2.uid, stageduser2.givenname,
            stageduser2.sn, **stageduser2.kwargs)
        user_activated.create_from_staged(stageduser2)
        command = stageduser2.make_activate_command()
        result = command()
        user_activated.check_activate(result)

        # verify the staged user does not exist after activation
        command = stageduser2.make_retrieve_command()
        with raises_exact(errors.NotFound(
                reason=u'%s: stage user not found' % stageduser2.uid)):
            command()

        user_activated.delete()
Ejemplo n.º 4
0
 def test_create_with_username_starting_with_numeric(self):
     """Successfully create a user with name starting with numeric chars"""
     testuser = UserTracker(
         name=u'1234user', givenname=u'First1234', sn=u'Surname1234',
     )
     testuser.create()
     testuser.delete()
Ejemplo n.º 5
0
 def test_create_with_uppercase_principal(self):
     """ Create user with upper-case principal """
     testuser = UserTracker(name=u'tuser1',
                            givenname=u'Test',
                            sn=u'Tuser1',
                            krbprincipalname=u'tuser1'.upper())
     testuser.create()
     testuser.delete()
Ejemplo n.º 6
0
 def test_create_with_uppercase_principal(self):
     """ Create user with upper-case principal """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test', sn=u'Tuser1',
         krbprincipalname=u'tuser1'.upper()
     )
     testuser.create()
     testuser.delete()
Ejemplo n.º 7
0
 def test_create_with_full_address(self):
     """ Create user with full address set """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test', sn=u'Tuser1',
         street=u'123 Maple Rd', l=u'Anytown', st=u'MD',
         postalcode=u'01234-5678', mobile=u'410-555-1212'
     )
     testuser.create()
     testuser.delete()
Ejemplo n.º 8
0
 def test_create_with_full_address(self):
     """ Create user with full address set """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test', sn=u'Tuser1',
         street=u'123 Maple Rd', l=u'Anytown', st=u'MD',
         postalcode=u'01234-5678', mobile=u'410-555-1212'
     )
     testuser.create()
     testuser.delete()
Ejemplo n.º 9
0
 def test_create_with_ssh_pubkey(self):
     """ Create user with an assigned SSH public key """
     testuser = UserTracker(name=u'tuser1',
                            givenname=u'Test',
                            sn=u'Tuser1',
                            ipasshpubkey=sshpubkey)
     testuser.track_create()
     # fingerprint is expected in the tracker attrs
     testuser.attrs.update(sshpubkeyfp=[sshpubkeyfp])
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 10
0
 def test_create_with_uid_999(self):
     """ Check that server return uid and gid 999
     when a new client asks for uid 999 """
     testuser = UserTracker(name=u'tuser1',
                            givenname=u'Test',
                            sn=u'Tuser1',
                            uidnumber=999)
     testuser.track_create()
     testuser.attrs.update(uidnumber=[u'999'], gidnumber=[u'999'])
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 11
0
 def test_create_with_ssh_pubkey(self):
     """ Create user with an assigned SSH public key """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test',
         sn=u'Tuser1', ipasshpubkey=sshpubkey
     )
     testuser.track_create()
     # fingerprint is expected in the tracker attrs
     testuser.attrs.update(sshpubkeyfp=[sshpubkeyfp])
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 12
0
 def test_create_with_uid_999(self):
     """ Check that server return uid and gid 999
     when a new client asks for uid 999 """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test', sn=u'Tuser1', uidnumber=999
     )
     testuser.track_create()
     testuser.attrs.update(
         uidnumber=[u'999'],
         gidnumber=[u'999']
     )
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 13
0
    def test_activate(self, stageduser3, user2):
        stageduser3.ensure_exists()
        user2.ensure_missing()
        user2 = UserTracker(
            stageduser3.uid, stageduser3.givenname, stageduser3.sn)
        user2.create_from_staged(stageduser3)
        command = stageduser3.make_activate_command()
        result = command()
        user2.check_activate(result)

        command = stageduser3.make_retrieve_command()
        with raises_exact(errors.NotFound(
                reason=u'%s: stage user not found' % stageduser3.uid)):
            command()
        user2.delete()
Ejemplo n.º 14
0
    def test_activate(self, stageduser3, user2):
        stageduser3.ensure_exists()
        user2.ensure_missing()
        user2 = UserTracker(
            stageduser3.uid, stageduser3.givenname, stageduser3.sn)
        user2.create_from_staged(stageduser3)
        command = stageduser3.make_activate_command()
        result = command()
        user2.check_activate(result)

        command = stageduser3.make_retrieve_command()
        with raises_exact(errors.NotFound(
                reason=u'%s: stage user not found' % stageduser3.uid)):
            command()
        user2.delete()
Ejemplo n.º 15
0
 def test_create_with_old_DNA_MAGIC_999(self):
     """ Check that server picks suitable uid and gid
     when an old client asks for the magic uid 999 """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test', sn=u'Tuser1',
         uidnumber=999, version=u'2.49'
     )
     testuser.track_create()
     testuser.attrs.update(
         uidnumber=[lambda v: int(v) != 999],
         gidnumber=[lambda v: int(v) != 999],
     )
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 16
0
 def test_create_with_old_DNA_MAGIC_999(self):
     """ Check that server picks suitable uid and gid
     when an old client asks for the magic uid 999 """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test', sn=u'Tuser1',
         uidnumber=999, version=u'2.49'
     )
     testuser.track_create()
     testuser.attrs.update(
         uidnumber=[lambda v: int(v) != 999],
         gidnumber=[lambda v: int(v) != 999],
     )
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 17
0
 def test_create_with_random_passwd(self):
     """ Create user with random password """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test', sn=u'Tuser1', random=True
     )
     testuser.track_create()
     testuser.attrs.update(
         randompassword=fuzzy_password,
         has_keytab=True, has_password=True,
         krbextradata=[Fuzzy(type=bytes)],
         krbpasswordexpiration=[fuzzy_dergeneralizedtime],
         krblastpwdchange=[fuzzy_dergeneralizedtime]
     )
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 18
0
 def test_create_without_upg_with_gid_set(self):
     """ Create user without User's Primary GID with GID set """
     testuser = UserTracker(name=u'tuser1',
                            givenname=u'Test',
                            sn=u'Tuser1',
                            noprivate=True,
                            gidnumber=1000)
     testuser.track_create()
     del testuser.attrs['mepmanagedentry']
     testuser.attrs.update(gidnumber=[u'1000'])
     testuser.attrs.update(description=[],
                           objectclass=add_oc(objectclasses.user_base,
                                              u'ipantuserattrs'))
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result, [u'description'])
     testuser.delete()
Ejemplo n.º 19
0
 def test_create_with_random_passwd(self):
     """ Create user with random password """
     testuser = UserTracker(name=u'tuser1',
                            givenname=u'Test',
                            sn=u'Tuser1',
                            random=True)
     testuser.track_create()
     testuser.attrs.update(randompassword=fuzzy_password,
                           has_keytab=True,
                           has_password=True,
                           krbextradata=[Fuzzy(type=bytes)],
                           krbpasswordexpiration=[fuzzy_dergeneralizedtime],
                           krblastpwdchange=[fuzzy_dergeneralizedtime])
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 20
0
 def test_create_without_upg_with_gid_set(self):
     """ Create user without User's Primary GID with GID set """
     testuser = UserTracker(
         name=u'tuser1', givenname=u'Test', sn=u'Tuser1',
         noprivate=True, gidnumber=1000
     )
     testuser.track_create()
     del testuser.attrs['mepmanagedentry']
     testuser.attrs.update(gidnumber=[u'1000'])
     testuser.attrs.update(
         description=[],
         objectclass=add_oc(objectclasses.user_base, u'ipantuserattrs')
     )
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result, [u'description'])
     testuser.delete()
Ejemplo n.º 21
0
 def test_create_with_uid_999(self):
     """ Check that server return uid and gid 999
     when a new client asks for uid 999 """
     testuser = UserTracker(name=u'tuser1',
                            givenname=u'Test',
                            sn=u'Tuser1',
                            uidnumber=999)
     testuser.track_create()
     # When uid is outside of IPA id range, no SID is generated
     del testuser.attrs['ipantsecurityidentifier']
     testuser.attrs.update(uidnumber=[u'999'],
                           gidnumber=[u'999'],
                           objectclass=objectclasses.user_base +
                           ['mepOriginEntry'])
     command = testuser.make_create_command()
     result = command()
     testuser.check_create(result)
     testuser.delete()
Ejemplo n.º 22
0
    def test_create_without_upg_with_gid_set(self):
        """ Create user without User's Primary GID with GID set

        The UPG plugin is disabled, but the user is provided with a group
        """
        testuser = UserTracker(name=u'tuser1',
                               givenname=u'Test',
                               sn=u'Tuser1',
                               gidnumber=1000)
        testuser.track_create()
        del testuser.attrs['mepmanagedentry']
        testuser.attrs.update(gidnumber=[u'1000'])
        testuser.attrs.update(
            description=[],
            objectclass=objectclasses.user_base + [u'ipantuserattrs'],
        )
        command = testuser.make_create_command()
        result = command()
        testuser.check_create(result, [u'description'])
        testuser.delete()
Ejemplo n.º 23
0
    def test_create_where_managed_group_exists(self, user, group):
        """ Create a managed group and then try to create user
        with the same name the group has

        As the UPG plugin is disabled, there is no conflict
        """
        group.create()
        testuser = UserTracker(name=group.cn,
                               givenname=u'Test',
                               sn=u'Tuser1',
                               gidnumber=1000)
        testuser.track_create()
        del testuser.attrs['mepmanagedentry']
        testuser.attrs.update(gidnumber=[u'1000'])
        testuser.attrs.update(description=[],
                              objectclass=add_oc(objectclasses.user_base,
                                                 u'ipantuserattrs'))
        command = testuser.make_create_command()
        result = command()
        testuser.check_create(result, [u'description'])
        testuser.delete()