Hello community, here is the log from the commit of package yast2-users for openSUSE:Factory checked in at 2020-07-01 14:25:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-users (Old) and /work/SRC/openSUSE:Factory/.yast2-users.new.3060 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-users" Wed Jul 1 14:25:57 2020 rev:232 rq:817857 version:4.3.3 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-users/yast2-users.changes 2020-06-10 00:36:22.409069470 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-users.new.3060/yast2-users.changes 2020-07-01 14:26:05.574655540 +0200 @@ -1,0 +2,8 @@ +Mon Jun 29 15:28:01 UTC 2020 - Imobach Gonzalez Sosa <[email protected]> + +- Honor the 'target' argument when cloning the system. If it is + set to 'compact', a reduced list of users and groups is generated + (bsc#1172749). +- 4.3.3 + +------------------------------------------------------------------- Old: ---- yast2-users-4.3.2.tar.bz2 New: ---- yast2-users-4.3.3.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-users.spec ++++++ --- /var/tmp/diff_new_pack.0imsrC/_old 2020-07-01 14:26:06.350657946 +0200 +++ /var/tmp/diff_new_pack.0imsrC/_new 2020-07-01 14:26:06.350657946 +0200 @@ -17,7 +17,7 @@ Name: yast2-users -Version: 4.3.2 +Version: 4.3.3 Release: 0 Summary: YaST2 - User and Group Configuration License: GPL-2.0-only @@ -32,8 +32,8 @@ BuildRequires: libtool BuildRequires: perl-Digest-SHA1 BuildRequires: update-desktop-files -# CLI readonly -BuildRequires: yast2 >= 4.2.57 +# 'target' argument for Installation::AutoClient#export method +BuildRequires: yast2 >= 4.3.10 BuildRequires: yast2-core-devel BuildRequires: yast2-devtools >= 4.2.2 BuildRequires: yast2-perl-bindings @@ -57,8 +57,8 @@ # this forces using yast2-ldap with correct LDAP object names (fate#303596) Requires: yast2-ldap >= 3.1.2 -# CLI readonly -Requires: yast2 >= 4.2.57 +# 'target' argument for Installation::AutoClient#export method +Requires: yast2 >= 4.3.10 # cryptsha256, cryptsha516 Requires: yast2-core >= 2.21.0 ++++++ yast2-users-4.3.2.tar.bz2 -> yast2-users-4.3.3.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/package/yast2-users.changes new/yast2-users-4.3.3/package/yast2-users.changes --- old/yast2-users-4.3.2/package/yast2-users.changes 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/package/yast2-users.changes 2020-06-30 13:07:33.000000000 +0200 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Mon Jun 29 15:28:01 UTC 2020 - Imobach Gonzalez Sosa <[email protected]> + +- Honor the 'target' argument when cloning the system. If it is + set to 'compact', a reduced list of users and groups is generated + (bsc#1172749). +- 4.3.3 + +------------------------------------------------------------------- Wed May 27 11:55:44 UTC 2020 - David Diaz <[email protected]> - Dropped legacy testsuite (related to bsc#1138668). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/package/yast2-users.spec new/yast2-users-4.3.3/package/yast2-users.spec --- old/yast2-users-4.3.2/package/yast2-users.spec 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/package/yast2-users.spec 2020-06-30 13:07:33.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-users -Version: 4.3.2 +Version: 4.3.3 Release: 0 Summary: YaST2 - User and Group Configuration License: GPL-2.0-only @@ -32,8 +32,8 @@ BuildRequires: libtool BuildRequires: perl-Digest-SHA1 BuildRequires: update-desktop-files -# CLI readonly -BuildRequires: yast2 >= 4.2.57 +# 'target' argument for Installation::AutoClient#export method +BuildRequires: yast2 >= 4.3.10 BuildRequires: yast2-core-devel BuildRequires: yast2-devtools >= 4.2.2 BuildRequires: yast2-perl-bindings @@ -57,8 +57,8 @@ # this forces using yast2-ldap with correct LDAP object names (fate#303596) Requires: yast2-ldap >= 3.1.2 -# CLI readonly -Requires: yast2 >= 4.2.57 +# 'target' argument for Installation::AutoClient#export method +Requires: yast2 >= 4.3.10 # cryptsha256, cryptsha516 Requires: yast2-core >= 2.21.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/src/Makefile.am new/yast2-users-4.3.3/src/Makefile.am --- old/yast2-users-4.3.2/src/Makefile.am 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/src/Makefile.am 2020-06-30 13:07:33.000000000 +0200 @@ -38,6 +38,7 @@ ylibclientdir = @ylibdir@/users/clients ylibclient_DATA = \ + lib/users/clients/auto.rb \ lib/users/clients/users_finish.rb yncludedir = @yncludedir@/users diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/src/clients/users_auto.rb new/yast2-users-4.3.3/src/clients/users_auto.rb --- old/yast2-users-4.3.2/src/clients/users_auto.rb 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/src/clients/users_auto.rb 2020-06-30 13:07:33.000000000 +0200 @@ -19,167 +19,5 @@ # current contact information at www.novell.com. # ------------------------------------------------------------------------------ -# File: -# users_auto.ycp -# -# Package: -# Configuration of Users -# -# Summary: -# Client for autoinstallation -# -# Authors: -# Anas Nashif <[email protected]> -# -# $Id$ -# -# This is a client for autoinstallation. It takes its arguments, -# goes through the configuration and return the setting. -# Does not do any changes to the configuration. - -Yast.import "Report" - -module Yast - class UsersAutoClient < Client - - def main - Yast.import "UI" - textdomain "users" - Yast.import "Mode" - Yast.import "Users" - Yast.import "UsersSimple" - Yast.import "Wizard" - - Yast.include self, "users/wizards.rb" - - @ret = nil - @func = "" - @param = {} - # Check arguments - if Ops.greater_than(Builtins.size(WFM.Args), 0) && - Ops.is_string?(WFM.Args(0)) - @func = Convert.to_string(WFM.Args(0)) - if Ops.greater_than(Builtins.size(WFM.Args), 1) && - Ops.is_map?(WFM.Args(1)) - @param = Convert.convert( - WFM.Args(1), - :from => "any", - :to => "map <string, any>" - ) - end - end - Builtins.y2debug("func=%1", @func) - Builtins.y2debug("param=%1", @param) - - - @users = [ - { - "username" => "my_user", - "user_password" => "passw", - "encrypted" => false, - # "uid":501, - "gid" => 100, - "password_settings" => { "expire" => "" }, - "grouplist" => "audio" - }, - { - "username" => "daemon", - "user_password" => "pass", - "encrypted" => false - }, - { "username" => "root", "uidNumber" => 0, "user_password" => "pass" } - ] - - # param = $["users": users]; - - if @func == "Import" - check_users(@param["users"] || []) - @ret = Users.Import(@param) - # create a summary - elsif @func == "Summary" - @ret = Users.Summary - elsif @func == "Reset" - Users.Import({}) - @ret = {} - elsif @func == "Packages" - @ret = {} - elsif @func == "Change" - @start_dialog = "summary" #look to users.ycp for possible values - Wizard.CreateDialog - Wizard.SetDesktopIcon("org.opensuse.yast.Users") - @ret = AutoSequence(@start_dialog) - Wizard.CloseDialog - elsif @func == "Export" - if Stage.initial - # Importing all users/groups from the UI if we are - # in the installation workflow - Users.SetExportAll(true) - setup_all_users - end - - @ret = Users.Export - - if Stage.initial - #Setting root password in the return value. We are in the inst_sys. - #The root password has not been written but is only available in - #UserSimple model. We have to set it manually. - root = @ret["users"].find { |u| u["uid"] == "0" } - root["user_password"] = Users.CryptPassword(UsersSimple.GetRootPassword, "system") if root - end - Users.SetExportAll(false) - elsif @func == "Read" - Yast.import "Progress" - Users.SetExportAll(true) - @progress_orig = Progress.set(false) - @ret = Users.Read == "" - Progress.set(@progress_orig) - elsif @func == "Write" - # NOTE: this code is not executed during autoinstallation (instead, the - # users_finish is used). - Yast.import "Progress" - Users.SetWriteOnly(true) - @progress_orig = Progress.set(false) - @ret = Users.Write == "" - Progress.set(@progress_orig) - # Return if configuration was changed - # return boolean - elsif @func == "GetModified" - @ret = Users.Modified - # Set all modified flags - # return boolean - elsif @func == "SetModified" - Users.SetModified(true) - @ret = true - else - Builtins.y2error("unknown function: %1", @func) - @ret = false - end - - Builtins.y2debug("ret=%1", @ret) - Builtins.y2milestone("users auto finished") - Builtins.y2milestone("----------------------------------------") - - deep_copy(@ret) - end - - private - - # Checking double user entries - # (double username or UID) - # @param [Array] users to check - def check_users(users) - if users.size > users.uniq { |u| u["username"]}.size - Report.Error(_("Found users in profile with equal <username>.")) - end - # Do not check users without defined UID. (bnc#996823) - check_users = users.dup - check_users.reject! { |u| !u.key?("uid")} - if check_users.size > check_users.uniq { |u| u["uid"]}.size - Report.Error(_("Found users in profile with equal <uid>.")) - end - end - - end -end - -Yast::UsersAutoClient.new.main +require "users/clients/auto" +Y2Users::Clients::Auto.new.run diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/src/lib/users/clients/auto.rb new/yast2-users-4.3.3/src/lib/users/clients/auto.rb --- old/yast2-users-4.3.2/src/lib/users/clients/auto.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-users-4.3.3/src/lib/users/clients/auto.rb 2020-06-30 13:07:33.000000000 +0200 @@ -0,0 +1,111 @@ +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# 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 General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "yast" +require "installation/auto_client" + +Yast.import "Users" +Yast.import "UsersSimple" +Yast.import "Mode" +Yast.import "Progress" +Yast.import "Report" +Yast.import "Stage" +Yast.import "Wizard" + +module Y2Users + module Clients + # AutoYaST users client + class Auto < ::Installation::AutoClient + def initialize + textdomain "users" + + Yast.include self, "users/wizards.rb" + end + + protected + + def import(param) + check_users(param["users"] || []) + Yast::Users.Import(param) + end + + def summary + Yast::Users.Summary + end + + def change + Yast::Wizard.CreateDialog + Yast::Wizard.SetDesktopIcon("org.opensuse.yast.Users") + ret = AutoSequence("summary") + Yast::Wizard.CloseDialog + ret + end + + def export(target:) + Yast::Users.Export(target.to_s) + end + + def read + Yast::Users.SetExportAll(true) + progress_orig = Yast::Progress.set(false) + ret = Yast::Users.Read == "" + Yast::Progress.set(progress_orig) + ret + end + + # @note This code is not executed during autoinstallation (instead, the + # users_finish is used). However, it is used when running ayast_setup. + # + # @return [Boolean] true if configuration was changed; false otherwise. + def write + Yast::Users.SetWriteOnly(true) + progress_orig = Yast::Progress.set(false) + ret = Yast::Users.Write == "" + Yast::Progress.set(progress_orig) + ret + end + + def modified? + Yast::Users.Modified + end + + def modified + Yast::Users.SetModified(true) + true + end + + private + + # Checking double user entries + # (double username or UID) + # @param [Array] users to check + def check_users(users) + if users.size > users.uniq { |u| u["username"] }.size + Yast::Report.Error(_("Found users in profile with equal <username>.")) + end + # Do not check users without defined UID. (bnc#996823) + check_users = users.dup + check_users.reject! { |u| !u.key?("uid") } + if check_users.size > check_users.uniq { |u| u["uid"] }.size + Yast::Report.Error(_("Found users in profile with equal <uid>.")) + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/src/lib/users/dialogs/inst_user_first.rb new/yast2-users-4.3.3/src/lib/users/dialogs/inst_user_first.rb --- old/yast2-users-4.3.2/src/lib/users/dialogs/inst_user_first.rb 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/src/lib/users/dialogs/inst_user_first.rb 2020-06-30 13:07:33.000000000 +0200 @@ -200,8 +200,8 @@ help += _( "<p>\nA previous Linux installation with local users has been detected.\n" \ "The information there can be used to create users in the system being installed.\n" \ - "Use the <b>Choose Users</b> button to select some users. Their basic information will\n" \ - "be imported.\n</p>\n" + "Use the <b>Choose Users</b> button to select some users. Their basic information will" \ + "\nbe imported.\n</p>\n" ) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/src/lib/users/proposal.rb new/yast2-users-4.3.3/src/lib/users/proposal.rb --- old/yast2-users-4.3.2/src/lib/users/proposal.rb 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/src/lib/users/proposal.rb 2020-06-30 13:07:33.000000000 +0200 @@ -66,7 +66,7 @@ when "users--encryption" client = "users_encryption_method" else - raise "Unknown action id: #{param['chosen_id']}" + raise "Unknown action id: #{param["chosen_id"]}" end result = WFM.CallFunction(client, [args]) @@ -87,7 +87,8 @@ # menu button label { "id" => "users--root", "title" => _("&Root Password") }, # menu button label - { "id" => "users--encryption", "title" => _("Password &Encryption Type") }] + { "id" => "users--encryption", "title" => _("Password &Encryption Type") } + ] id = "users" end @@ -104,8 +105,8 @@ def users_ay export = Users.Export() ret = _("Number of defined users/groups:") - ret += "<ul>\n<li>" + format(_("Users: %d"), export["users"].count()) + "</li>\n" - ret += "<li>" + format(_("Groups: %d"), export["groups"].count()) + "</li></ul>" + ret += "<ul>\n<li>" + format(_("Users: %d"), export["users"].count) + "</li>\n" + ret += "<li>" + format(_("Groups: %d"), export["groups"].count) + "</li></ul>" ret end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/src/modules/Users.pm new/yast2-users-4.3.3/src/modules/Users.pm --- old/yast2-users-4.3.2/src/modules/Users.pm 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/src/modules/Users.pm 2020-06-30 13:07:33.000000000 +0200 @@ -6564,32 +6564,38 @@ # (For use by autoinstallation.) # @return map Dumped settings (later acceptable by Import ()) BEGIN { $TYPEINFO{Export} = ["function", - ["map", "string", "any"]]; + ["map", "string", "any"], "string"]; } sub Export { my $self = shift; + my $target = shift; + $target = "default" if not defined $target; + my $export_system = ($target ne "compact"); my @exported_users = (); # local users when modified if (defined $users{"local"}) { - foreach my $user (values %{$users{"local"}}) { - if ($export_all || defined $user->{"modified"}) { - push @exported_users, $self->ExportUser ($user); - } - } + foreach my $user (values %{$users{"local"}}) { + if ($export_all || defined $user->{"modified"}) { + push @exported_users, $self->ExportUser ($user); + } + } } # modified system users: - if (defined $users{"system"}) { - foreach my $user (values %{$users{"system"}}) { - if ($export_all || defined $user->{"modified"}) { - push @exported_users, $self->ExportUser ($user); - } - } + if (defined($users{"system"})) { + foreach my $user (values %{$users{"system"}}) { + if ($export_all || defined $user->{"modified"}) { + if ($export_system || $user->{"uid"} eq "root") { + push @exported_users, $self->ExportUser ($user); + } + } + } } my @exported_groups = (); # modified local system groups: + if (defined $groups{"local"}) { foreach my $group (values %{$groups{"local"}}) { if ($export_all || defined $group->{"modified"}) { @@ -6599,7 +6605,7 @@ } # modified system groups: - if (defined $groups{"system"}) { + if ($export_system && defined($groups{"system"})) { foreach my $group (values %{$groups{"system"}}) { if ($export_all || defined $group->{"modified"}) { push @exported_groups, $self->ExportGroup ($group); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/test/Makefile.am new/yast2-users-4.3.3/test/Makefile.am --- old/yast2-users-4.3.2/test/Makefile.am 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/test/Makefile.am 2020-06-30 13:07:33.000000000 +0200 @@ -6,6 +6,7 @@ lib/users/users_database_test.rb \ lib/users/leaf_blk_device_test.rb \ lib/users/ssh_public_key_test.rb \ + lib/users/clients/auto_test.rb \ lib/users/dialogs/inst_root_first_test.rb \ lib/users/dialogs/inst_user_first_test.rb \ lib/users/widgets/inst_root_first_test.rb \ @@ -13,7 +14,6 @@ dialogs_test.rb \ ssh_authorized_keys_test.rb \ users_test.rb \ - users_auto_test.rb \ users_finish_test.rb \ users_simple_test.rb \ widgets_test.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/test/dialogs_test.rb new/yast2-users-4.3.3/test/dialogs_test.rb --- old/yast2-users-4.3.2/test/dialogs_test.rb 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/test/dialogs_test.rb 2020-06-30 13:07:33.000000000 +0200 @@ -1,6 +1,6 @@ require_relative "./test_helper" -require "yast2/execute"; +require "yast2/execute" Yast.import "UI" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/test/lib/users/clients/auto_test.rb new/yast2-users-4.3.3/test/lib/users/clients/auto_test.rb --- old/yast2-users-4.3.2/test/lib/users/clients/auto_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-users-4.3.3/test/lib/users/clients/auto_test.rb 2020-06-30 13:07:33.000000000 +0200 @@ -0,0 +1,120 @@ +#!/usr/bin/env rspec + +require_relative "../../../test_helper" +require "yaml" +require "users/clients/auto" +Yast.import "Report" + +describe Y2Users::Clients::Auto do + let(:mode) { "autoinstallation" } + let(:args) { [func] } + + before do + allow(Yast).to receive(:import).and_call_original + allow(Yast).to receive(:import).with("Ldap") + allow(Yast).to receive(:import).with("LdapPopup") + allow(Yast::Mode).to receive(:mode).and_return(mode) + allow(Yast::WFM).to receive(:Args).and_return(args) + end + + describe "#run" do + context "Import" do + let(:func) { "Import" } + let(:args) { [func, users] } + + context "when double users have been given in the profile" do + let(:users) { YAML.load_file(FIXTURES_PATH.join("users_error.yml")) } + + it "report error" do + expect(Yast::Report).to receive(:Error) + .with(_("Found users in profile with equal <username>.")) + expect(Yast::Report).to receive(:Error) + .with(_("Found users in profile with equal <uid>.")) + expect(subject.run).to eq(true) + end + end + + context "when users without any UID are defined in the profile" do + let(:users) { YAML.load_file(FIXTURES_PATH.join("users_no_error.yml")) } + + it "will not be checked for double UIDs" do + expect(Yast::Report).not_to receive(:Error) + .with(_("Found users in profile with equal <username>.")) + expect(Yast::Report).not_to receive(:Error) + .with(_("Found users in profile with equal <uid>.")) + expect(subject.run).to eq(true) + end + end + end + + context "Change" do + let(:func) { "Change" } + + it "returns the 'summary' autosequence result" do + expect(subject).to receive(:AutoSequence).and_return(:next) + expect(subject.run).to eq(:next) + end + end + + context "Summary" do + let(:func) { "Summary" } + + before do + allow(Yast::Users).to receive(:Summary).and_return("summary") + end + + it "returns the users summary" do + expect(subject.run).to eq("summary") + end + end + + context "Export" do + let(:func) { "Export" } + let(:args) { [func] } + + let(:local_users) { double("local_users") } + let(:all_users) { double("all_users") } + + before do + allow(Yast::WFM).to receive(:Args).and_return(args) + allow(Yast::Users).to receive(:Export).with("default") + .and_return(all_users) + allow(Yast::Users).to receive(:Export).with("compact") + .and_return(local_users) + end + + it "exports all users and groups" do + expect(subject.run).to eq(all_users) + end + + context "when 'compact' export is wanted" do + let(:args) { [func, "target" => "compact"] } + + it "it exports only local users and groups" do + expect(subject.run).to eq(local_users) + end + end + end + + context "Modified" do + let(:func) { "GetModified" } + + before do + allow(Yast::Users).to receive(:Modified).and_return(true) + end + + it "returns whether the data in Users module has been modified" do + expect(subject.run).to eq(true) + end + end + + context "SetModified" do + let(:func) { "SetModified" } + + it "sets the Users module as modified" do + expect(Yast::Users).to receive(:SetModified).with(true) + subject.run + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/test/users_auto_test.rb new/yast2-users-4.3.3/test/users_auto_test.rb --- old/yast2-users-4.3.2/test/users_auto_test.rb 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/test/users_auto_test.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,58 +0,0 @@ -#!/usr/bin/env rspec - -require_relative "test_helper" -require "yaml" - -describe "Yast::UsersAutoClient" do - Yast.import "WFM" - Yast.import "Users" - Yast.import "Users" - Yast.import "Report" - - subject { Yast::UsersAutoClient.new } - let(:mode) { "autoinstallation" } - - before do - allow(Yast).to receive(:import).and_call_original - allow(Yast).to receive(:import).with("Ldap") - allow(Yast).to receive(:import).with("LdapPopup") - - allow(Yast::Mode).to receive(:mode).and_return(mode) - - # this actually executes the client 8-O - require_relative "../src/clients/users_auto" - end - - describe "#AutoYaST" do - context "Import" do - before do - allow(Yast::WFM).to receive(:Args).with(no_args).and_return([func, users]) - allow(Yast::WFM).to receive(:Args).with(0).and_return(func) - allow(Yast::WFM).to receive(:Args).with(1).and_return(users) - end - - let(:func) { "Import" } - - context "when double users have been given in the profile" do - let(:users) { YAML.load_file(FIXTURES_PATH.join("users_error.yml")) } - it "report error" do - expect(Yast::Report).to receive(:Error) - .with(_("Found users in profile with equal <username>.")) - expect(Yast::Report).to receive(:Error) - .with(_("Found users in profile with equal <uid>.")) - expect(subject.main).to eq(true) - end - end - context "when users without any UID are defined in the profile" do - let(:users) { YAML.load_file(FIXTURES_PATH.join("users_no_error.yml")) } - it "will not be checked for double UIDs" do - expect(Yast::Report).not_to receive(:Error) - .with(_("Found users in profile with equal <username>.")) - expect(Yast::Report).not_to receive(:Error) - .with(_("Found users in profile with equal <uid>.")) - expect(subject.main).to eq(true) - end - end - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/test/users_simple_test.rb new/yast2-users-4.3.3/test/users_simple_test.rb --- old/yast2-users-4.3.2/test/users_simple_test.rb 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/test/users_simple_test.rb 2020-06-30 13:07:33.000000000 +0200 @@ -70,7 +70,8 @@ end it "returns non-empty string for invalid username" do - expect(users.CheckUsernameContents("abc; touch > /tmp/hacker.was.here; echo abc", "ldap")).to_not be_empty + expect(users.CheckUsernameContents("abc; touch > /tmp/hacker.was.here; echo abc", "ldap")) + .to_not be_empty end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.3.2/test/users_test.rb new/yast2-users-4.3.3/test/users_test.rb --- old/yast2-users-4.3.2/test/users_test.rb 2020-05-27 14:37:36.000000000 +0200 +++ new/yast2-users-4.3.3/test/users_test.rb 2020-06-30 13:07:33.000000000 +0200 @@ -45,4 +45,71 @@ end end end + + describe "#Export" do + let(:root_user) { { "username" => "root", "uid" => "0" } } + let(:local_user) { { "username" => "user1", "uid" => "1000" } } + let(:system_user) { { "username" => "messagebus", "uid" => "499" } } + + let(:local_group) { { "groupname" => "devops", "gid" => "1000" } } + let(:users_group) { { "groupname" => "users", "gid" => "100" } } + let(:system_group) { { "groupname" => "messagebus", "gid" => "480" } } + + before do + Yast::Users.Import( + "users" => [root_user, local_user, system_user], + "groups" => [users_group, local_group, system_group], + "login_settings" => { "autologin_user" => "root", "password_less_login" => true }, + "user_defaults" => { "group" => "100", "home" => "/srv/Users" } + ) + end + + it "exports users" do + exported = subject.Export + expect(exported["users"]).to contain_exactly( + a_hash_including(root_user), + a_hash_including(local_user), + a_hash_including(system_user) + ) + end + + it "exports groups" do + exported = subject.Export + expect(exported["groups"]).to contain_exactly( + a_hash_including(users_group), + a_hash_including(local_group), + a_hash_including(system_group) + ) + end + + it "export login settings" do + exported = subject.Export + expect(exported["login_settings"]).to eq( + "autologin_user" => "root", "password_less_login" => true + ) + end + + it "exports user defaults" do + exported = subject.Export + expect(exported["user_defaults"]).to include("home" => "/srv/Users") + end + + context "when 'compact' target is required" do + it "exports 'root' and local users" do + exported = subject.Export("compact") + expect(exported["users"]).to contain_exactly( + a_hash_including(root_user), + a_hash_including(local_user) + ) + end + + it "exports 'users' and local groups" do + exported = subject.Export("compact") + expect(exported["groups"]).to contain_exactly( + a_hash_including(users_group), + a_hash_including(local_group) + ) + end + end + end end
