Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package yast2-firstboot for openSUSE:Factory
checked in at 2021-07-13 22:36:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-firstboot (Old)
and /work/SRC/openSUSE:Factory/.yast2-firstboot.new.2625 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-firstboot"
Tue Jul 13 22:36:50 2021 rev:106 rq:905297 version:4.4.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-firstboot/yast2-firstboot.changes
2021-07-02 13:26:48.101070357 +0200
+++
/work/SRC/openSUSE:Factory/.yast2-firstboot.new.2625/yast2-firstboot.changes
2021-07-13 22:36:53.862388251 +0200
@@ -1,0 +2,8 @@
+Fri Jul 9 11:59:31 UTC 2021 - Jos?? Iv??n L??pez Gonz??lez <[email protected]>
+
+- Remember plain passwords in order to provide a clean navigation
+ through the firstboot dialogs when going back and forward.
+- Skip client for root password when needed (bsc#1188068).
+- 4.4.3
+
+-------------------------------------------------------------------
Old:
----
yast2-firstboot-4.4.2.tar.bz2
New:
----
yast2-firstboot-4.4.3.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-firstboot.spec ++++++
--- /var/tmp/diff_new_pack.IJ5Cj6/_old 2021-07-13 22:36:54.318384579 +0200
+++ /var/tmp/diff_new_pack.IJ5Cj6/_new 2021-07-13 22:36:54.318384579 +0200
@@ -17,7 +17,7 @@
Name: yast2-firstboot
-Version: 4.4.2
+Version: 4.4.3
Release: 0
Summary: YaST2 - Initial System Configuration
License: GPL-2.0-only
++++++ yast2-firstboot-4.4.2.tar.bz2 -> yast2-firstboot-4.4.3.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-firstboot-4.4.2/.rubocop.yml
new/yast2-firstboot-4.4.3/.rubocop.yml
--- old/yast2-firstboot-4.4.2/.rubocop.yml 2021-06-30 15:47:16.000000000
+0200
+++ new/yast2-firstboot-4.4.3/.rubocop.yml 2021-07-09 15:37:09.000000000
+0200
@@ -12,6 +12,8 @@
Metrics/BlockLength:
Max: 90
+ Exclude:
+ - 'test/**/*.rb'
# Configuration parameters: CountComments.
Metrics/MethodLength:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-firstboot-4.4.2/package/yast2-firstboot.changes
new/yast2-firstboot-4.4.3/package/yast2-firstboot.changes
--- old/yast2-firstboot-4.4.2/package/yast2-firstboot.changes 2021-06-30
15:47:16.000000000 +0200
+++ new/yast2-firstboot-4.4.3/package/yast2-firstboot.changes 2021-07-09
15:37:09.000000000 +0200
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Fri Jul 9 11:59:31 UTC 2021 - Jos?? Iv??n L??pez Gonz??lez <[email protected]>
+
+- Remember plain passwords in order to provide a clean navigation
+ through the firstboot dialogs when going back and forward.
+- Skip client for root password when needed (bsc#1188068).
+- 4.4.3
+
+-------------------------------------------------------------------
Thu Jun 17 07:43:12 UTC 2021 - David Diaz <[email protected]>
- Adapt code to Y2Users (part of jsc#PM-2620).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-firstboot-4.4.2/package/yast2-firstboot.spec
new/yast2-firstboot-4.4.3/package/yast2-firstboot.spec
--- old/yast2-firstboot-4.4.2/package/yast2-firstboot.spec 2021-06-30
15:47:16.000000000 +0200
+++ new/yast2-firstboot-4.4.3/package/yast2-firstboot.spec 2021-07-09
15:37:09.000000000 +0200
@@ -17,7 +17,7 @@
Name: yast2-firstboot
-Version: 4.4.2
+Version: 4.4.3
Release: 0
Summary: YaST2 - Initial System Configuration
License: GPL-2.0-only
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/root.rb
new/yast2-firstboot-4.4.3/src/lib/y2firstboot/clients/root.rb
--- old/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/root.rb
2021-06-30 15:47:16.000000000 +0200
+++ new/yast2-firstboot-4.4.3/src/lib/y2firstboot/clients/root.rb
2021-07-09 15:37:09.000000000 +0200
@@ -1,8 +1,4 @@
-#!/usr/bin/env ruby
-#
-# encoding: utf-8
-
-# Copyright (c) [2016] SUSE LLC
+# Copyright (c) [2016-2021] SUSE LLC
#
# All Rights Reserved.
#
@@ -21,51 +17,92 @@
# 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 "y2users/password"
require "y2users/linux/writer"
require "y2users/config_manager"
-require "y2users/clients/inst_root_first"
+require "users/dialogs/inst_root_first"
+require "y2firstboot/clients/user"
+
+Yast.import "GetInstArgs"
module Y2Firstboot
module Clients
# Client for setting the root password
- class Root < Y2Users::Clients::InstRootFirst
- # Overload Y2Users::Clients::InstRootFirst#run to wipe the encrypted
password
- # @see #reset_password
+ class Root < Yast::Client
def run
- reset_password
+ return :auto unless run?
+
+ load_password
+
+ result = Yast::InstRootFirstDialog.new(root_user).run
- super
+ if result == :next
+ write_config
+ save_password
+ end
+
+ result
end
private
- # Wipes encrypted password
+ # Whether to run the client
+ #
+ # Note that this client should be automatically skipped when root was
configured to use the
+ # same password as a user.
#
- # @note This method can be considered a sort of workaround for supporting
- # as much as possible a "clean" navigation through the Firstboot dialogs
- # when going back and forward (just in case the admin decides to offer
- # such a feature), EVEN THOUGH is not the intended behavior since
- # Firstboot clients perform changes in the running system right away.
- def reset_password
- return unless root_user.password&.value&.encrypted?
+ # @return [Boolean]
+ def run?
+ force? || !root_password_from_user?
+ end
- root_user.password = Y2Users::Password.create_plain("")
+ # Whether the client is configured to always run it
+ #
+ # @return [Boolean]
+ def force?
+ Yast::GetInstArgs.argmap.fetch("force", false)
end
- # Updates the target configuration and writes it to the system
+ # Whether the user password was used for root
+ #
+ # @see Y2Firstboot::Clients::User
#
- # @see Y2Users::Clients::InstRootFirst#update_target_config
- def update_target_config
- super
+ # @return [Boolean]
+ def root_password_from_user?
+ Y2Firstboot::Clients::User.user_password ==
Y2Firstboot::Clients::User.root_password
+ end
+ # Writes the config to the system
+ def write_config
writer = Y2Users::Linux::Writer.new(
- Y2Users::ConfigManager.instance.target,
+ config,
Y2Users::ConfigManager.instance.system
)
writer.write
end
+ # Loads the saved plain password of the root user
+ #
+ # This is needed for supporting a "clean" navigation through the
Firstboot dialogs when going
+ # back and forward. See also {#save_password}.
+ def load_password
+ value = Y2Firstboot::Clients::User.root_password || ""
+ root_user.password = Y2Users::Password.create_plain(value)
+ end
+
+ # Saves the given root password
+ def save_password
+ Y2Firstboot::Clients::User.root_password = root_user.password_content
+ end
+
+ # The root user
+ #
+ # @return [Y2Users::User]
+ def root_user
+ @root_user ||= config.users.root
+ end
+
# System config, which contains all the current users on the system
#
# @return [Y2Users::Config]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/user.rb
new/yast2-firstboot-4.4.3/src/lib/y2firstboot/clients/user.rb
--- old/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/user.rb
2021-06-30 15:47:16.000000000 +0200
+++ new/yast2-firstboot-4.4.3/src/lib/y2firstboot/clients/user.rb
2021-07-09 15:37:09.000000000 +0200
@@ -1,8 +1,4 @@
-#!/usr/bin/env ruby
-#
-# encoding: utf-8
-
-# Copyright (c) [2016] SUSE LLC
+# Copyright (c) [2016-2021] SUSE LLC
#
# All Rights Reserved.
#
@@ -21,53 +17,60 @@
# 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 "y2users/password"
require "y2users/linux/writer"
require "y2users/config_manager"
require "users/dialogs/inst_user_first"
-Yast.import "Users"
-Yast.import "Progress"
-
module Y2Firstboot
module Clients
- # Client to set up the first user during the firstboot mode
+ # Client to set up the user during the firstboot mode
class User < Yast::Client
class << self
- # @return [String, nil] the username of the created/edited user as a
- # result of the execution of this client, if any. Needed for retrieving
- # the user when going back and forward. See {#user}
+ # The username of the created/edited user, if any.
+ #
+ # Needed for retrieving the user when going back and forward.
+ #
+ # @see #user
+ #
+ # @return [String, nil]
attr_accessor :username
+
+ # Plain password of the user, if any.
+ #
+ # Needed for retrieving the plain version of the password when going
back and forward. Note
+ # that the user is committed to the system right away in this step, so
when going back the
+ # password of the user would be already encrypted. The plain version
of the password is
+ # needed in order to fill the password field with the current value,
and also to determine
+ # whether that same password was used for root, see
Yast::InstUserFirstDialog.
+ #
+ # @return [String, nil]
+ attr_accessor :user_password
+
+ # Plain password of the root user, if any.
+ #
+ # @see #user_password
+ #
+ # @return [String, nil]
+ attr_accessor :root_password
end
def run
- reset_password
+ load_values
result = Yast::InstUserFirstDialog.new(config, user: user).run
- write_config if result == :next
-
- # Updates the username reference. See {#user}
- self.class.username = user.attached? ? user.name : nil
+ if result == :next
+ write_config
+ save_values
+ end
result
end
private
- # Wipes encrypted password
- #
- # @note This method can be considered a sort of workaround for supporting
- # as much as possible a "clean" navigation through the Firstboot dialogs
- # when going back and forward (just in case the admin decides to offer
- # such a feature), EVEN THOUGH is not the intended behavior since
- # Firstboot clients perform changes in the running system right away.
- def reset_password
- return unless user.password&.value&.encrypted?
-
- user.password = Y2Users::Password.create_plain("")
- end
-
# Writes config to the system
def write_config
writer = Y2Users::Linux::Writer.new(
@@ -78,11 +81,51 @@
writer.write
end
- # A copy of config holding all the users on the system
+ # Loads previously saved values
#
- # @return [Y2Users::Config]
- def config
- @config ||= Y2Users::ConfigManager.instance.system(force_read:
true).copy
+ # This is needed for supporting a "clean" navigation through the
Firstboot dialogs when going
+ # back and forward. See also {#save_values}.
+ def load_values
+ load_user_password
+ load_root_password
+ end
+
+ # Loads the saved plain password of the user
+ def load_user_password
+ user.password =
Y2Users::Password.create_plain(self.class.user_password || "")
+ end
+
+ # Loads the saved plain password of the root user
+ def load_root_password
+ return unless self.class.root_password
+
+ root_user.password =
Y2Users::Password.create_plain(self.class.root_password)
+ end
+
+ # Saves the given values
+ #
+ # @see #load_values
+ def save_values
+ save_username
+ save_user_password
+ save_root_password
+ end
+
+ # Saves the given username
+ def save_username
+ self.class.username = user.attached? ? user.name : nil
+ end
+
+ # Saves the given user password, if needed
+ def save_user_password
+ self.class.user_password = user.attached? ? user.password_content : nil
+ end
+
+ # Saves the given root password, if needed
+ def save_root_password
+ return if root_user.password&.value&.encrypted?
+
+ self.class.root_password = root_user&.password_content
end
# The user to be created/edited
@@ -92,6 +135,20 @@
@user ||= config.users.by_name(self.class.username) if
self.class.username
@user ||= Y2Users::User.new("")
end
+
+ # The root user
+ #
+ # @return [Y2Users::User]
+ def root_user
+ @root_user ||= config.users.root
+ end
+
+ # A copy of config holding all the users on the system
+ #
+ # @return [Y2Users::Config]
+ def config
+ @config ||= Y2Users::ConfigManager.instance.system(force_read:
true).copy
+ end
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-firstboot-4.4.2/test/y2firstboot/clients/root_test.rb
new/yast2-firstboot-4.4.3/test/y2firstboot/clients/root_test.rb
--- old/yast2-firstboot-4.4.2/test/y2firstboot/clients/root_test.rb
2021-06-30 15:47:16.000000000 +0200
+++ new/yast2-firstboot-4.4.3/test/y2firstboot/clients/root_test.rb
2021-07-09 15:37:09.000000000 +0200
@@ -1,5 +1,6 @@
#!/usr/bin/env rspec
-# Copyright (c) [2018] SUSE LLC
+
+# Copyright (c) [2018-2021] SUSE LLC
#
# All Rights Reserved.
#
@@ -24,87 +25,151 @@
describe Y2Firstboot::Clients::Root do
subject(:client) { described_class.new }
- let(:inst_root_dialog) { instance_double(Yast::InstRootFirstDialog, run:
result) }
- let(:result) { :next }
+ describe "#run" do
+ before do
+ allow(Yast::InstRootFirstDialog).to receive(:new).and_return(dialog)
- let(:writer) { instance_double(Y2Users::Linux::Writer, write: []) }
+ allow_any_instance_of(Y2Users::Linux::Writer).to receive(:write)
- let(:target_config) { Y2Users::Config.new }
- let(:system_config) { Y2Users::Config.new }
- let(:system_config_copy) { Y2Users::Config.new }
- let(:config_manager) { Y2Users::ConfigManager.instance }
- let(:root_user) { Y2Users::User.create_root }
- let(:root_password) { nil }
-
- before do
- root_user.password = root_password
- allow(Yast::InstRootFirstDialog).to
receive(:new).and_return(inst_root_dialog)
-
- allow(Y2Users::Linux::Writer).to receive(:new).and_return(writer)
-
- system_config_copy.attach([root_user])
- allow(system_config).to receive(:copy).and_return(system_config_copy)
- allow(config_manager).to receive(:target).and_return(target_config)
- allow(config_manager).to receive(:system).and_return(system_config)
- end
+ allow(Y2Users::ConfigManager.instance).to
receive(:system).and_return(system_config)
- describe "#run" do
- context "when root user has an encrypted password" do
- let(:root_password) { Y2Users::Password.create_encrypted("s3cr3t") }
+ allow(system_config).to receive(:copy).and_return(config)
+ end
- it "resets the root password" do
- expect(root_user.password.value).to be_encrypted
+ let(:system_config) { Y2Users::Config.new.attach(root, user) }
- subject.run
+ let(:config) { system_config.copy }
- expect(root_user.password.value).to_not be_encrypted
- expect(root_user.password_content).to be_empty
+ let(:root) do
+ Y2Users::User.create_root.tap do |root|
+ root.password = Y2Users::Password.create_encrypted("$xaadfd545dft")
end
end
- context "when root user has a plain password" do
- let(:root_password) { Y2Users::Password.create_plain("s3cr3t") }
+ let(:user) do
+ Y2Users::User.new("test").tap do |user|
+ user.password = Y2Users::Password.create_encrypted("$xa9545dft")
+ end
+ end
- it "does not reset the root password" do
- expect(root_user.password_content).to eq("s3cr3t")
+ let(:dialog) { instance_double(Yast::InstRootFirstDialog, run:
dialog_result) }
+
+ let(:dialog_result) { :back }
+
+ context "if the client was forced to be executed" do
+ before do
+ allow(Yast::GetInstArgs).to receive(:argmap).and_return("force" =>
true)
+ end
+
+ it "opens the dialog for configuring root" do
+ expect(dialog).to receive(:run)
subject.run
+ end
+
+ it "sets the plain password to the root user" do
+ Y2Firstboot::Clients::User.root_password = "S3cr3T"
+
+ expect(Yast::InstRootFirstDialog).to receive(:new) do |_root|
+ expect(config.users.root.password_content).to eq("S3cr3T")
+ end.and_return(dialog)
+
+ subject.run
+ end
+ end
- expect(root_user.password_content).to eq("s3cr3t")
+ context "if the client was not forced to be executed" do
+ before do
+ allow(Yast::GetInstArgs).to receive(:argmap).and_return("force" =>
false)
+ end
+
+ context "and the user password was used for root" do
+ before do
+ Y2Firstboot::Clients::User.user_password = "S3cr3T"
+ Y2Firstboot::Clients::User.root_password = "S3cr3T"
+ end
+
+ it "does not open the dialog for configuring root" do
+ expect(dialog).to_not receive(:run)
+
+ subject.run
+ end
+
+ it "returns :auto" do
+ expect(subject.run).to eq(:auto)
+ end
+ end
+
+ context "and the user password was not used for root" do
+ before do
+ Y2Firstboot::Clients::User.user_password = "S3cr3T"
+ Y2Firstboot::Clients::User.root_password = "root-S3cr3T"
+ end
+
+ it "opens the dialog for configuring root" do
+ expect(dialog).to receive(:run)
+
+ subject.run
+ end
+
+ it "sets the plain password to the root user" do
+ expect(Yast::InstRootFirstDialog).to receive(:new) do |_root|
+ expect(config.users.root.password_content).to eq("root-S3cr3T")
+ end.and_return(dialog)
+
+ subject.run
+ end
end
end
- context "when inst_root_dialog result is :next" do
- let(:result) { :next }
+ context "when the dialog result is :next" do
+ let(:dialog_result) { :next }
+
+ before do
+ Y2Firstboot::Clients::User.user_password = "S3cr3T"
+ Y2Firstboot::Clients::User.root_password = "root-S3cr3T"
+ end
- it "updates users target configuration" do
- expect(config_manager).to receive(:target=).with(system_config_copy)
+ it "writes the config to the system" do
+ expect(Y2Users::Linux::Writer).to receive(:new)
+ .with(config, system_config).and_call_original
subject.run
end
- it "writes the target users configuration" do
- expect(Y2Users::Linux::Writer).to receive(:new).with(target_config,
system_config)
- expect(writer).to receive(:write)
+ it "updates the plain root password for the next run" do
+ expect(Yast::InstRootFirstDialog).to receive(:new) do |root|
+ root.password = Y2Users::Password.create_plain("root-more-S3cr3T")
+ end.and_return(dialog)
subject.run
+
+ expect(Y2Firstboot::Clients::User.root_password).to
eq("root-more-S3cr3T")
end
end
- context "when inst_root_dialog result is not :next" do
- let(:result) { :back }
+ context "when dialog result is not :next" do
+ let(:dialog_result) { :back }
- it "does not update users target configuration" do
- expect(config_manager).to_not receive(:target=)
+ before do
+ Y2Firstboot::Clients::User.user_password = "S3cr3T"
+ Y2Firstboot::Clients::User.root_password = "root-S3cr3T"
+ end
+
+ it "does not write the users configuration" do
+ expect(Y2Users::Linux::Writer).to_not receive(:new)
subject.run
end
- it "does not write users configuration" do
- expect(Y2Users::Linux::Writer).to_not receive(:new)
- expect(writer).to_not receive(:write)
+ it "does not update the plain root password for the next run" do
+ expect(Yast::InstRootFirstDialog).to receive(:new) do |root|
+ root.password = Y2Users::Password.create_plain("root-more-S3cr3T")
+ end.and_return(dialog)
subject.run
+
+ expect(Y2Firstboot::Clients::User.root_password).to eq("root-S3cr3T")
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-firstboot-4.4.2/test/y2firstboot/clients/user_test.rb
new/yast2-firstboot-4.4.3/test/y2firstboot/clients/user_test.rb
--- old/yast2-firstboot-4.4.2/test/y2firstboot/clients/user_test.rb
2021-06-30 15:47:16.000000000 +0200
+++ new/yast2-firstboot-4.4.3/test/y2firstboot/clients/user_test.rb
2021-07-09 15:37:09.000000000 +0200
@@ -1,5 +1,6 @@
#!/usr/bin/env rspec
-# Copyright (c) [2018] SUSE LLC
+
+# Copyright (c) [2018-2021] SUSE LLC
#
# All Rights Reserved.
#
@@ -25,108 +26,149 @@
subject(:client) { described_class.new }
describe "#run" do
- let(:dialog) { instance_double(Yast::InstUserFirstDialog, run: result) }
- let(:result) { :next }
+ before do
+ allow(Yast::InstUserFirstDialog).to receive(:new).and_return(dialog)
- let(:user) { Y2Users::User.new(username) }
- let(:username) { "chamaleon" }
- let(:password) { nil }
- let(:attached) { false }
-
- let(:system_config) { Y2Users::Config.new }
- let(:system_config_copy) { Y2Users::Config.new }
- let(:config_manager) { Y2Users::ConfigManager.instance }
+ allow_any_instance_of(Y2Users::Linux::Writer).to receive(:write)
- let(:writer) { instance_double(Y2Users::Linux::Writer, write: []) }
+ allow(Y2Users::ConfigManager.instance).to
receive(:system).and_return(system_config)
- before do
- user.password = password
- system_config_copy.attach([user])
+ allow(system_config).to receive(:copy).and_return(config)
+ end
- allow(Yast::InstUserFirstDialog).to receive(:new).and_return(dialog)
+ let(:system_config) { Y2Users::Config.new.attach(root) }
- allow(Y2Users::Linux::Writer).to receive(:new).and_return(writer)
+ let(:config) { system_config.copy.attach(user) }
- allow(subject).to receive(:user).and_return(user)
- allow(user).to receive(:attached?).and_return(attached)
+ let(:root) do
+ Y2Users::User.create_root.tap do |root|
+ root.password = Y2Users::Password.create_encrypted("$xaadfd545dft")
+ end
+ end
- allow(system_config).to receive(:copy).and_return(system_config_copy)
- allow(config_manager).to receive(:system).and_return(system_config)
+ let(:user) do
+ Y2Users::User.new("test").tap do |user|
+ user.password = Y2Users::Password.create_encrypted("$xa9545dft")
+ end
end
- context "when user has an encrypted password" do
- let(:password) { Y2Users::Password.create_encrypted("s3cr3t") }
+ let(:dialog) { instance_double(Yast::InstUserFirstDialog, run:
dialog_result) }
+
+ let(:dialog_result) { :back }
- it "resets the user password" do
- expect(user.password.value).to be_encrypted
+ context "if the client is executed for first time" do
+ before do
+ described_class.username = nil
+ end
+
+ it "opens the dialog with a new user" do
+ expect(Yast::InstUserFirstDialog).to receive(:new) do |_config, params|
+ expect(params[:user].attached?).to eq(false)
+ end.and_return(dialog)
subject.run
+ end
- expect(user.password.value).to_not be_encrypted
- expect(user.password_content).to be_empty
+ it "returns the dialog result" do
+ expect(subject.run).to eq(dialog_result)
end
end
- context "when user has a plain password" do
- let(:password) { Y2Users::Password.create_plain("s3cr3t") }
+ context "if the client was already executed" do
+ before do
+ described_class.username = "test"
+ described_class.user_password = "S3cr3T"
+ described_class.root_password = "root-S3cr3T"
+ end
- it "does not reset the user password" do
- expect(user.password_content).to eq("s3cr3t")
+ it "opens the dialog with the previously created user" do
+ expect(Yast::InstUserFirstDialog).to receive(:new) do |_config, params|
+ expect(params[:user].attached?).to eq(true)
+ expect(params[:user].name).to eq("test")
+ end.and_return(dialog)
subject.run
+ end
- expect(user.password_content).to eq("s3cr3t")
+ it "sets the saved plain password to the user" do
+ expect(Yast::InstUserFirstDialog).to receive(:new) do |_config, params|
+ expect(params[:user].password_content).to eq("S3cr3T")
+ end.and_return(dialog)
+
+ subject.run
end
- end
- it "executes the inst_user_first dialog" do
- expect(Yast::InstUserFirstDialog).to
receive(:new).with(system_config_copy, user: user)
- expect(dialog).to receive(:run)
+ it "sets the plain password to the root user" do
+ expect(Yast::InstUserFirstDialog).to receive(:new) do |config, _params|
+ expect(config.users.root.password_content).to eq("root-S3cr3T")
+ end.and_return(dialog)
- subject.run
- end
+ subject.run
+ end
- it "returns the dialog result" do
- expect(subject.run).to eq(result)
+ it "returns the dialog result" do
+ expect(subject.run).to eq(dialog_result)
+ end
end
- context "when dialog result is :next" do
- it "writes the users configuration" do
- expect(Y2Users::Linux::Writer).to
receive(:new).with(system_config_copy, system_config)
- expect(writer).to receive(:write)
+ context "when the dialog result is :next" do
+ let(:dialog_result) { :next }
- subject.run
+ before do
+ described_class.username = "test"
end
- end
- context "when dialog result is not :next" do
- let(:result) { :back }
+ it "writes the config to the system" do
+ expect(Y2Users::Linux::Writer).to receive(:new)
+ .with(config, system_config).and_call_original
- it "does not write the users configuration" do
- expect(Y2Users::Linux::Writer).to_not receive(:new)
- expect(writer).to_not receive(:write)
+ subject.run
+ end
+
+ it "updates the saved user values for the next run" do
+ expect(Yast::InstUserFirstDialog).to receive(:new) do |config, params|
+ user = params[:user]
+ user.name = "test2"
+ user.password = Y2Users::Password.create_plain("more-S3cr3T")
+ config.users.root.password =
Y2Users::Password.create_plain("root-more-S3cr3T")
+ end.and_return(dialog)
subject.run
+
+ expect(described_class.username).to eq("test2")
+ expect(described_class.user_password).to eq("more-S3cr3T")
+ expect(described_class.root_password).to eq("root-more-S3cr3T")
end
end
- context "if user is attached" do
- let(:attached) { true }
+ context "when dialog result is not :next" do
+ let(:dialog_result) { :back }
- it "saves the username for future reference" do
- expect(described_class).to receive(:username=).with(username)
+ before do
+ described_class.username = "test"
+ described_class.user_password = "S3cr3T"
+ described_class.root_password = "root-S3cr3T"
+ end
+
+ it "does not write the users configuration" do
+ expect(Y2Users::Linux::Writer).to_not receive(:new)
subject.run
end
- end
- context "if user is not attached" do
- let(:attached) { false }
-
- it "deletes username reference" do
- expect(described_class).to receive(:username=).with(nil)
+ it "does not update the saved user values for the next run" do
+ expect(Yast::InstUserFirstDialog).to receive(:new) do |config, params|
+ user = params[:user]
+ user.name = "test2"
+ user.password = Y2Users::Password.create_plain("more-S3cr3T")
+ config.users.root.password =
Y2Users::Password.create_plain("more-root-S3cr3T")
+ end.and_return(dialog)
subject.run
+
+ expect(described_class.username).to eq("test")
+ expect(described_class.user_password).to eq("S3cr3T")
+ expect(described_class.root_password).to eq("root-S3cr3T")
end
end
end