Skip to content

Commit

Permalink
Rename Y2Security::SelinuxConfig to Y2Security::Selinux
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Feb 9, 2021
1 parent 293df2e commit 0930349
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
Expand Up @@ -24,49 +24,49 @@ module Y2Security
# Class for handling SELinux kernel params
#
# @example Querying the currently configured SELinux mode
# selinux = SelinuxConfig.new
# selinux = Selinux.new
# mode = selinux.mode
# mode.id #=> :permissive
# mode.name #=> "Permisive"
#
# @example Querying the currently running SELinux mode
# selinux= SelinuxConfig.new
# selinux= Selinux.new
# mode = selinux.running_mode
# mode.id #=> :enforcing
# mode.name #=> "Enforcing"
#
# @example Enabling SELinux in Permissive mode for next boot
# selinux = SelinuxConfig.new
# selinux = Selinux.new
# selinux.mode = :permissive
# selinux.save #=> true
#
# @example Disabling SELinux for next boot
# selinux = SelinuxConfig.new
# selinux = Selinux.new
# selinux.mode = :disabled
# selinux.save #=> true
#
# @example Disabling SELinux for next boot (using nil)
# selinux = SelinuxConfig.new
# selinux = Selinux.new
# selinux.mode = nil
# selinux.mode.id #=> :disabled
# selinux.save #=> true
#
# @example Trying to enable SELinux during an installation set to be configurable
# selinux = SelinuxConfig.new
# selinux = Selinux.new
# selinux.mode = :permissive
# selinux.save #=> true
#
# @example Trying to enable SELinux during an installation set to not be configurable
# selinux = SelinuxConfig.new
# selinux = Selinux.new
# selinux.mode = :permissive
# selinux.save #=> false
class SelinuxConfig
class Selinux
include Yast::Logger

Yast.import "Bootloader"
Yast.import "ProductFeatures"

# @return [SelinuxConfig::Mode] the last set mode, which can be differrent to the
# @return [Selinux::Mode] the last set mode, which can be differrent to the
# {#running_mode} and {#configured_mode}. A call to {#save} is needed to make it the
# {#configured_mode} for the next boot.
attr_reader :mode
Expand All @@ -93,7 +93,7 @@ def running_mode

# Returns a collection holding all known SELinux modes
#
# @return [Array<SelinuxConfig::Mode>] a collection of known SELinux modes
# @return [Array<Selinux::Mode>] a collection of known SELinux modes
def modes
Mode.all
end
Expand Down Expand Up @@ -149,8 +149,8 @@ def configurable?
#
# @note using nil means to set SELinux mode as disabled.
#
# @param id [SelinuxConfig::Mode, String, Symbol, nil] a SELinux mode or its identifier
# @return [Mode] the SelinuxConfig::Mode by given id or disabled is none found or nil was given
# @param id [Selinux::Mode, String, Symbol, nil] a SELinux mode or its identifier
# @return [Mode] the Selinux::Mode by given id or disabled is none found or nil was given
def find_mode(id)
found_mode = Mode.find(id)

Expand Down
Expand Up @@ -19,9 +19,9 @@
# find current contact information at www.suse.com.

require_relative "../test_helper"
require "y2security/selinux_config"
require "y2security/selinux"

describe Y2Security::SelinuxConfig do
describe Y2Security::Selinux do
subject { described_class.new }

let(:installation_mode) { false }
Expand Down Expand Up @@ -102,7 +102,7 @@
end

describe "#mode" do
let(:enforcing_mode) { Y2Security::SelinuxConfig::Mode.find(:enforcing) }
let(:enforcing_mode) { Y2Security::Selinux::Mode.find(:enforcing) }

before do
subject.mode = enforcing_mode
Expand All @@ -114,8 +114,8 @@
end

describe "#mode=" do
let(:disabled_mode) { Y2Security::SelinuxConfig::Mode.find(:disabled) }
let(:permissive_mode) { Y2Security::SelinuxConfig::Mode.find(:permissive) }
let(:disabled_mode) { Y2Security::Selinux::Mode.find(:disabled) }
let(:permissive_mode) { Y2Security::Selinux::Mode.find(:permissive) }

context "when a known SELinux mode id is given" do
it "returns the mode" do
Expand Down Expand Up @@ -160,8 +160,8 @@
.and_return(getenforce_output)
end

it "it returns the running SelinuxConfig::Mode" do
expect(subject.running_mode).to be_a(Y2Security::SelinuxConfig::Mode)
it "it returns the running Selinux::Mode" do
expect(subject.running_mode).to be_a(Y2Security::Selinux::Mode)
expect(subject.running_mode.id).to eq(:enforcing)
end
end
Expand All @@ -186,7 +186,7 @@

describe "#modes" do
it "returns a collection of known SELinux modes" do
expect(subject.modes).to all(be_a(Y2Security::SelinuxConfig::Mode))
expect(subject.modes).to all(be_a(Y2Security::Selinux::Mode))
end

it "contains known mode ids" do
Expand All @@ -200,7 +200,7 @@

describe "#save" do
let(:write_result) { true }
let(:enforcing_mode) { Y2Security::SelinuxConfig::Mode.find(:enforcing) }
let(:enforcing_mode) { Y2Security::Selinux::Mode.find(:enforcing) }
let(:selinux_configurable) { true }

before do
Expand Down Expand Up @@ -309,12 +309,12 @@
end
end

describe Y2Security::SelinuxConfig::Mode do
describe Y2Security::Selinux::Mode do
subject { described_class }

describe ".all" do
it "returns a collection of known modes" do
expect(subject.all).to all(be_an(Y2Security::SelinuxConfig::Mode))
expect(subject.all).to all(be_an(Y2Security::Selinux::Mode))
end
end

Expand All @@ -339,7 +339,7 @@
let(:mode_id) { "permissive" }

it "returns the mode" do
expect(mode).to be_an(Y2Security::SelinuxConfig::Mode)
expect(mode).to be_an(Y2Security::Selinux::Mode)
expect(mode.id).to eq(mode_id.to_sym)
end
end
Expand Down

0 comments on commit 0930349

Please sign in to comment.