From e0fab16bced07d17f5113f639fea61aeb13edfc2 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 8 Mar 2024 01:23:16 -0300 Subject: [PATCH] Control#feature! -> Control#feature --- README.md | 2 +- lib/bsd/control.rb | 4 ++-- test/superuser/enable_feature_test.rb | 6 +++--- test/superuser/feature_status_test.rb | 10 +++++----- test/unprivileged/enable_feature_test.rb | 2 +- .../{feature_bang_test.rb => feature_test.rb} | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) rename test/unprivileged/{feature_bang_test.rb => feature_test.rb} (72%) diff --git a/README.md b/README.md index 03d0e82..47ed475 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The example enables the mprotect feature for the emacs binary: # As a root account require 'hbsdctl' BSD::Control - .feature!(:mprotect) + .feature(:mprotect) .enable!("/usr/local/bin/emacs-29.2") ``` diff --git a/lib/bsd/control.rb b/lib/bsd/control.rb index c8f148e..bc3d062 100644 --- a/lib/bsd/control.rb +++ b/lib/bsd/control.rb @@ -18,7 +18,7 @@ module BSD::Control ## # @example # BSD::Control - # .feature!(:mprotect) + # .feature(:mprotect) # .enable!("/usr/local/bin/firefox") # # @param [String] name @@ -29,7 +29,7 @@ module BSD::Control # # @return [BSD::Control::Feature] # Returns an instance of BSD::Control::Feature. - def self.feature!(name) + def self.feature(name) feature = Feature.available.find { _1.name == name.to_s } feature ? feature : raise(Error, "feature '#{name}' wasn't found") end diff --git a/test/superuser/enable_feature_test.rb b/test/superuser/enable_feature_test.rb index 53a4d7f..1213d72 100644 --- a/test/superuser/enable_feature_test.rb +++ b/test/superuser/enable_feature_test.rb @@ -6,7 +6,7 @@ module BSD::Control def test_enable_mprotect touch(file) - assert BSD::Control.feature!(:mprotect).enable!(file), + assert BSD::Control.feature(:mprotect).enable!(file), "The enable! method should have returned true" ensure rm(file) @@ -15,7 +15,7 @@ module BSD::Control def test_enable_mprotect_zero_permissions touch(file) chmod(0, file) - assert BSD::Control.feature!(:mprotect).enable!(file), + assert BSD::Control.feature(:mprotect).enable!(file), "The enable! method should have returned true" ensure rm(file) @@ -23,7 +23,7 @@ module BSD::Control def test_enable_mprotect_nonexistent_file assert_raises(BSD::Control::Error) do - BSD::Control.feature!(:mprotect).enable!(file) + BSD::Control.feature(:mprotect).enable!(file) end end diff --git a/test/superuser/feature_status_test.rb b/test/superuser/feature_status_test.rb index 5395c6e..63ab751 100644 --- a/test/superuser/feature_status_test.rb +++ b/test/superuser/feature_status_test.rb @@ -7,16 +7,16 @@ module BSD::Control def test_mprotect_sysdef_status touch(file) assert_equal :sysdef, - BSD::Control.feature!(:mprotect).status(file) + BSD::Control.feature(:mprotect).status(file) ensure rm(file) end def test_mprotect_enabled_status touch(file) - BSD::Control.feature!(:mprotect).enable!(file) + BSD::Control.feature(:mprotect).enable!(file) assert_equal :enabled, - BSD::Control.feature!(:mprotect).status(file) + BSD::Control.feature(:mprotect).status(file) ensure rm(file) end @@ -24,9 +24,9 @@ module BSD::Control def test_mprotect_disabled_status touch(file) - BSD::Control.feature!(:mprotect).disable!(file) + BSD::Control.feature(:mprotect).disable!(file) assert_equal :disabled, - BSD::Control.feature!(:mprotect).status(file) + BSD::Control.feature(:mprotect).status(file) ensure rm(file) end diff --git a/test/unprivileged/enable_feature_test.rb b/test/unprivileged/enable_feature_test.rb index 1ad434a..77f264e 100644 --- a/test/unprivileged/enable_feature_test.rb +++ b/test/unprivileged/enable_feature_test.rb @@ -10,7 +10,7 @@ module BSD::Control BSD::Control::Error, "This operation requires root privileges." ) do - BSD::Control.feature!(:mprotect).enable!(file) + BSD::Control.feature(:mprotect).enable!(file) end ensure rm(file) diff --git a/test/unprivileged/feature_bang_test.rb b/test/unprivileged/feature_test.rb similarity index 72% rename from test/unprivileged/feature_bang_test.rb rename to test/unprivileged/feature_test.rb index 583c2c5..3a01e93 100644 --- a/test/unprivileged/feature_bang_test.rb +++ b/test/unprivileged/feature_test.rb @@ -3,12 +3,12 @@ module BSD::Control class FeatureBangTest < Test::Unit::TestCase def test_mprotect_feature assert_instance_of BSD::Control::Feature, - BSD::Control.feature!(:mprotect) + BSD::Control.feature(:mprotect) end def test_nonexistent_feature assert_raises(BSD::Control::Error) do - BSD::Control.feature!(:non_existent_feature) + BSD::Control.feature(:non_existent_feature) end end end