Skip to content

Commit

Permalink
Move SelinuxConfig to Y2Security namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Feb 3, 2021
1 parent dc71ad4 commit 8ebab8a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Expand Up @@ -20,20 +20,20 @@
require "yast"
require "yast2/execute"

module Security
module Y2Security
# Class for handling SELinux kernel params
#
# @example Querying the currently configured SELinux mode
# selinux = SelinuxConfig.new
# mode = selinux.mode
# puts mode.id #=> :permissive
# puts mode.name #=> "Permisive"
# mode.id #=> :permissive
# mode.name #=> "Permisive"
#
# @example Querying the currently running SELinux mode
# selinux= SelinuxConfig.new
# mode = selinux.running_mode
# puts mode.id #=> :enforcing
# puts mode.name #=> "Enforcing"
# mode.id #=> :enforcing
# mode.name #=> "Enforcing"
#
# @example Enabling SELinux in Permissive mode for next boot
# selinux = SelinuxConfig.new
Expand All @@ -58,7 +58,7 @@ class SelinuxConfig
Yast.import "Bootloader"
Yast.import "ProductFeatures"

# @return [Security::SelinuxConfig::Mode] the last set mode, which can be differrent to the
# @return [Y2Security::SelinuxConfig::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 @@ -73,7 +73,7 @@ def initialize
# It can be the proposed one if running in an installation or the configured mode for a
# running system
#
# @return [Security::SelinuxConfig::Mode]
# @return [Y2Security::SelinuxConfig::Mode]
def initial_mode
@initial_mode ||= Yast::Mode.installation ? propose_mode : configured_mode
end
Expand All @@ -95,7 +95,7 @@ def running_mode

# Returns a collection holding all known SELinux modes
#
# @return [Array<Security::SelinuxConfig::Mode>] a collection of known SELinux modes
# @return [Array<Y2Security::SelinuxConfig::Mode>] a collection of known SELinux modes
def modes
Mode.all
end
Expand All @@ -104,7 +104,7 @@ def modes
#
# @note using nil means to set SELinux mode as disabled.
#
# @param id [Security::SelinuxConfig::Mode, String, Symbol, nil] a SELinux mode or its identifier
# @param id [Y2Security::SelinuxConfig::Mode, String, Symbol, nil] a SELinux mode or its identifier
# @return [Mode] found SelinuxConfig::Mode by given id; disabled is none found or nil was given
def mode=(id)
@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 "security/selinux_config"
require "y2security/selinux_config"

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

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

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

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

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

context "when a known SELinux mode id is given" do
it "returns the mode" do
Expand Down Expand Up @@ -136,7 +136,7 @@
end

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

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

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

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

before do
allow(Yast::Bootloader).to receive(:modify_kernel_params)
Expand Down Expand Up @@ -222,12 +222,12 @@
end
end

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

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

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

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

0 comments on commit 8ebab8a

Please sign in to comment.