Exemplo n.º 1
0
    def configure_ipa(usertype, fname, lname, kadmin, ktadmin, username):
        """Create user.
        """
        ipa_client = awscontext.GLOBAL.ipaclient
        if not kadmin:
            kadmin = os.getlogin()

        if not usertype:
            user = usermanager.get_ipa_user(ipa_client=ipa_client,
                                            user_name=username)
        else:
            if not fname:
                fname = username
            if not lname:
                lname = username

            user = usermanager.create_ipa_user(
                ipa_client=ipa_client,
                kadmin=kadmin,
                ktadmin=ktadmin,
                user_name=username,
                first_name=fname,
                last_name=lname,
                user_type=usertype,
            )

        cli.out(formatter(user))
    def test_create_ipa_user(self, resp_mock, subproc_mock):
        """Test create_ipa_user.
        """
        resp_mock.return_value = self.FakeResponse

        result = usermanager.create_ipa_user(ipa_client=self.ipaclient,
                                             kadmin='admin',
                                             ktadmin='/tmp/admin.keytab',
                                             user_name='foo',
                                             first_name='fname',
                                             last_name='lname',
                                             user_type='proid')

        subproc_mock.assert_called_with([
            'kadmin', '-p', 'admin', '-k', '-t', '/tmp/admin.keytab', 'cpw',
            '-randkey', 'foo'
        ])