Skip to content

Commit

Permalink
Do not use commit config for root
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Sep 22, 2021
1 parent 0dfdcb1 commit 9ff5241
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
14 changes: 1 addition & 13 deletions src/lib/y2firstboot/clients/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
require "y2users/password"
require "y2users/linux/writer"
require "y2users/config_manager"
require "y2users/commit_config_collection"
require "y2users/commit_config"
require "users/dialogs/inst_root_first"
require "y2firstboot/clients/user"

Expand Down Expand Up @@ -79,8 +77,7 @@ def root_password_from_user?
def write_config
writer = Y2Users::Linux::Writer.new(
config,
Y2Users::ConfigManager.instance.system,
Y2Users::CommitConfigCollection.new.tap { |collection| collection.add(commit_config) }
Y2Users::ConfigManager.instance.system
)
writer.write
end
Expand All @@ -99,15 +96,6 @@ def save_password
Y2Firstboot::Clients::User.root_password = root_user.password_content
end

# Build and return a {Y2Users::CommitConfig} for #root_user
#
# @return [Y2Users::CommitConfig]
def commit_config
Y2Users::CommitConfig.new.tap do |config|
config.username = root_user.name
end
end

# The root user
#
# @return [Y2Users::User]
Expand Down
21 changes: 2 additions & 19 deletions test/y2firstboot/clients/root_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,32 +124,15 @@

context "when the dialog result is :next" do
let(:dialog_result) { :next }
let(:commit_config) { Y2Users::CommitConfig.new }
let(:commit_config_collection) { Y2Users::CommitConfigCollection.new }

before do
allow(Y2Users::CommitConfig).to receive(:new).and_return(commit_config)
allow(Y2Users::CommitConfigCollection).to receive(:new).and_return(commit_config_collection)

Y2Firstboot::Clients::User.user_password = "S3cr3T"
Y2Firstboot::Clients::User.root_password = "root-S3cr3T"
end

it "prepares commit configuration" do
expect(commit_config).to receive(:username=).with("root")

expect(commit_config).to_not receive(:move_home=)
expect(commit_config).to_not receive(:use_skel=)
expect(commit_config).to_not receive(:adapt_home_ownership=)

expect(commit_config_collection).to receive(:add).with(commit_config)

subject.run
end

it "prepares and writes the config to the system" do
it "writes the config to the system" do
expect(Y2Users::Linux::Writer).to receive(:new)
.with(config, system_config, commit_config_collection).and_call_original
.with(config, system_config).and_call_original

subject.run
end
Expand Down

0 comments on commit 9ff5241

Please sign in to comment.