Skip to content

Commit

Permalink
Merge e0e5109 into 2d7e2bf
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Apr 13, 2021
2 parents 2d7e2bf + e0e5109 commit 093cfbc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
6 changes: 4 additions & 2 deletions library/general/src/lib/cfa/login_defs.rb
Expand Up @@ -65,6 +65,8 @@ class LoginDefs < BaseModel
:userdel_precmd
].freeze

DEFAULT_PATH = "/etc/login.defs".freeze

class << self
# Returns the list of known attributes
#
Expand All @@ -80,7 +82,7 @@ def known_attributes
# @param file_handler [#read,#write] something able to read/write a string (like File)
# @param file_path [String] File path
# @return [LoginDefs] File with the already loaded content
def load(file_path:, file_handler: Yast::TargetFile)
def load(file_path: DEFAULT_PATH, file_handler: Yast::TargetFile)
new(file_path: file_path, file_handler: file_handler).tap(&:load)
end
end
Expand All @@ -98,7 +100,7 @@ def load(file_path:, file_handler: Yast::TargetFile)
# @param file_path [String] File path
#
# @see CFA::BaseModel#initialize
def initialize(file_path:, file_handler: Yast::TargetFile)
def initialize(file_path: DEFAULT_PATH, file_handler: Yast::TargetFile)
super(AugeasParser.new("login_defs.lns"), file_path, file_handler: file_handler)
end

Expand Down
1 change: 0 additions & 1 deletion library/general/src/modules/ShadowConfig.rb
Expand Up @@ -23,7 +23,6 @@
module Yast
# This class allows to access the API to handle login.defs attributes from Perl
#
# @see CFA::LoginDefs
# @see CFA::ShadowConfig
class ShadowConfigClass < Module
include Logger
Expand Down
18 changes: 18 additions & 0 deletions library/general/test/cfa/login_defs_test.rb
Expand Up @@ -90,4 +90,22 @@
end
end
end

describe "#present_attributes" do
it "returns the list of present attributes" do
expect(login_defs.present_attributes).to include(*ATTRS_VALUES.keys)
end
end

describe "#conflicts" do
subject(:other) { described_class.new(file_path: file_path, file_handler: file_handler) }

before do
other.encrypt_method = "SHA256"
end

it "returns the list of attributes with different values" do
expect(login_defs.conflicts(other)).to eq([:encrypt_method])
end
end
end
File renamed without changes.
6 changes: 6 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Apr 12 15:12:41 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Add a default value for file_path argument in ::new and ::load
methods of CFA::LoginDefs class.

-------------------------------------------------------------------
Mon Mar 29 09:46:31 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down

0 comments on commit 093cfbc

Please sign in to comment.