Skip to content

Commit

Permalink
Merge 25c9d7e into e914214
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Apr 13, 2021
2 parents e914214 + 25c9d7e commit 784182a
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 830 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
44 changes: 0 additions & 44 deletions library/general/src/lib/cfa/shadow_config.rb

This file was deleted.

7 changes: 4 additions & 3 deletions library/general/src/modules/ShadowConfig.rb
Expand Up @@ -18,13 +18,14 @@
# find current contact information at www.suse.com.

require "yast"
require "cfa/shadow_config"
require "cfa/login_defs"

module Yast
# This class allows to access the API to handle login.defs attributes from Perl
#
# In SLE 15 SP2, it relies on CFA::LoginDefs instead of CFA::ShadowConfig like later versions.
#
# @see CFA::LoginDefs
# @see CFA::ShadowConfig
class ShadowConfigClass < Module
include Logger

Expand Down Expand Up @@ -101,7 +102,7 @@ def check_attribute(attr)
def config
return @config if @config

@config = CFA::ShadowConfig.new
@config = CFA::LoginDefs.new
@config.load
@config
end
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
164 changes: 0 additions & 164 deletions library/general/test/cfa/shadow_config_test.rb

This file was deleted.

1 change: 0 additions & 1 deletion library/general/test/data/login.defs/custom/etc/login.defs

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 784182a

Please sign in to comment.