Skip to content

Commit

Permalink
Do not replace FileUtils by now.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Feb 29, 2016
1 parent d90fe92 commit 7ac404b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/lib/security/ctrl_alt_del_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module CtrlAltDelConfig
Yast.import "SCR"
Yast.import "Arch"
Yast.import "Package"
Yast.import "FileUtils"

SYSTEMD_FILE = "/etc/systemd/system/ctrl-alt-del.target"

Expand All @@ -37,7 +38,7 @@ def systemd?
end

def inittab?
File.exist?("/etc/inittab")
Yast::FileUtils.Exists("/etc/inittab")
end

def default
Expand All @@ -59,7 +60,7 @@ def current
end

def current_systemd
if !File.exist?(SYSTEMD_FILE)
if !Yast::FileUtils.Exists(SYSTEMD_FILE)
ret = nil
else
link = Yast::SCR.Read(Yast::Path.new(".target.symlink"), SYSTEMD_FILE).to_s
Expand Down
18 changes: 9 additions & 9 deletions test/security_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ def enabled?; true; end

context "when ctrl+alt+del file not exist" do
it "returns 'reboot'" do
allow(File).to receive(:exist?).with(ctrl_alt_del_file) { false }
allow(FileUtils).to receive(:Exists).with(ctrl_alt_del_file) { false }

expect(Security.ReadConsoleShutdown).to eql("reboot")
end
end

context "when ctrl+del+alt file exist" do
before do
allow(File).to receive(:exist?).with(ctrl_alt_del_file) { true }
allow(FileUtils).to receive(:Exists).with(ctrl_alt_del_file) { true }
end

it "returns 'ignore' by default" do
Expand Down Expand Up @@ -273,15 +273,15 @@ def enabled?; true; end

context "when ctrl+alt+del file not exist" do
it "returns 'reboot'" do
allow(File).to receive(:exist?).with(ctrl_alt_del_file) { false }
allow(FileUtils).to receive(:Exists).with(ctrl_alt_del_file) { false }

expect(Security.ReadConsoleShutdown).to eql("halt")
end
end

context "when ctrl+del+alt file exist" do
before do
allow(File).to receive(:exist?).with(ctrl_alt_del_file) { true }
allow(FileUtils).to receive(:Exists).with(ctrl_alt_del_file) { true }
end

it "returns 'ignore' by default" do
Expand Down Expand Up @@ -324,7 +324,7 @@ def enabled?; true; end
end

it "ever returns nil" do
allow(File).to receive(:exist?).with("/etc/inittab")
allow(FileUtils).to receive(:Exists).with("/etc/inittab")
.and_return(false, true)
allow(::Security::CtrlAltDelConfig).to receive(:current)
.and_return("reboot", "halt")
Expand All @@ -341,7 +341,7 @@ def enabled?; true; end

context "when no inittab ca entry" do
it "returns 'reboot'" do
allow(File).to receive(:exist?).with("/etc/inittab") { false }
allow(FileUtils).to receive(:Exists).with("/etc/inittab") { false }

Security.ReadConsoleShutdown
expect(Security.Settings["CONSOLE_SHUTDOWN"]).to eq("reboot")
Expand All @@ -350,7 +350,7 @@ def enabled?; true; end

context "when inittab ca entry exist" do
before do
allow(File).to receive(:exist?).with("/etc/inittab") { true }
allow(FileUtils).to receive(:Exists).with("/etc/inittab") { true }
end

it "sets settings for shutdown as 'ignore' by default" do
Expand Down Expand Up @@ -388,7 +388,7 @@ def enabled?; true; end

context "when no inittab ca entry" do
it "returns 'halt'" do
allow(File).to receive(:exist?).with("/etc/inittab") { false }
allow(FileUtils).to receive(:Exists).with("/etc/inittab") { false }

Security.ReadConsoleShutdown
expect(Security.Settings["CONSOLE_SHUTDOWN"]).to eq("halt")
Expand All @@ -397,7 +397,7 @@ def enabled?; true; end

context "when inittab ca entry exist" do
before do
allow(File).to receive(:exist?).with("/etc/inittab") { true }
allow(FileUtils).to receive(:Exists).with("/etc/inittab") { true }
end

it "sets settings for shutdown as 'ignore' by default" do
Expand Down

0 comments on commit 7ac404b

Please sign in to comment.