linux_admin 1.2.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/linux_admin.rb +0 -8
- data/lib/linux_admin/disk.rb +12 -5
- data/lib/linux_admin/registration_system.rb +8 -4
- data/lib/linux_admin/scap.rb +1 -1
- data/lib/linux_admin/service/sys_v_init_service.rb +2 -1
- data/lib/linux_admin/service/systemd_service.rb +6 -2
- data/lib/linux_admin/version.rb +1 -1
- metadata +8 -100
- data/lib/linux_admin/registration_system/rhn.rb +0 -111
- data/spec/chrony_spec.rb +0 -64
- data/spec/common_spec.rb +0 -37
- data/spec/data/rhn/output_rhn-channel_list +0 -2
- data/spec/data/rhn/output_rhn-channel_list_available +0 -4
- data/spec/data/rhn/systemid +0 -57
- data/spec/data/rhn/systemid.missing_system_id +0 -57
- data/spec/data/rpm/cmd_output_for_list_installed +0 -20
- data/spec/data/subscription_manager/output_list_all_available +0 -42
- data/spec/data/subscription_manager/output_list_installed_not_subscribed +0 -19
- data/spec/data/subscription_manager/output_list_installed_subscribed +0 -19
- data/spec/data/subscription_manager/output_orgs +0 -6
- data/spec/data/subscription_manager/output_repos +0 -18
- data/spec/data/time_date/timedatectl_output +0 -14
- data/spec/data/yum/first.repo +0 -19
- data/spec/data/yum/output_repo_list +0 -13
- data/spec/data/yum/output_repoquery_multiple +0 -3
- data/spec/data/yum/output_repoquery_single +0 -1
- data/spec/data/yum/second.repo +0 -9
- data/spec/deb_spec.rb +0 -52
- data/spec/disk_spec.rb +0 -307
- data/spec/distro_spec.rb +0 -77
- data/spec/dns_spec.rb +0 -105
- data/spec/etc_issue_spec.rb +0 -37
- data/spec/fstab_spec.rb +0 -132
- data/spec/hardware_spec.rb +0 -46
- data/spec/hosts_spec.rb +0 -150
- data/spec/ip_address_spec.rb +0 -148
- data/spec/logical_volume_spec.rb +0 -166
- data/spec/mountable_spec.rb +0 -182
- data/spec/network_interface/network_interface_rh_spec.rb +0 -291
- data/spec/network_interface_spec.rb +0 -284
- data/spec/partition_spec.rb +0 -24
- data/spec/physical_volume_spec.rb +0 -101
- data/spec/registration_system_spec.rb +0 -85
- data/spec/rhn_spec.rb +0 -144
- data/spec/rpm_spec.rb +0 -85
- data/spec/scap_spec.rb +0 -48
- data/spec/service/sys_v_init_service_spec.rb +0 -127
- data/spec/service/systemd_service_spec.rb +0 -133
- data/spec/service_spec.rb +0 -54
- data/spec/spec_helper.rb +0 -116
- data/spec/ssh_spec.rb +0 -53
- data/spec/subscription_manager_spec.rb +0 -228
- data/spec/system_spec.rb +0 -15
- data/spec/time_date_spec.rb +0 -106
- data/spec/volume_group_spec.rb +0 -99
- data/spec/yum_spec.rb +0 -155
@@ -1,127 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::SysVInitService do
|
2
|
-
before do
|
3
|
-
@service = described_class.new 'foo'
|
4
|
-
end
|
5
|
-
|
6
|
-
describe "#running?" do
|
7
|
-
it "checks service" do
|
8
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
9
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
10
|
-
:params => {nil => %w(foo status)}).and_return(double(:exit_status => 0))
|
11
|
-
@service.running?
|
12
|
-
end
|
13
|
-
|
14
|
-
context "service is running" do
|
15
|
-
it "returns true" do
|
16
|
-
@service = described_class.new :id => :foo
|
17
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
|
18
|
-
expect(@service).to be_running
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "service is not running" do
|
23
|
-
it "returns false" do
|
24
|
-
@service = described_class.new :id => :foo
|
25
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
|
26
|
-
expect(@service).not_to be_running
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#enable" do
|
32
|
-
it "enables service" do
|
33
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
34
|
-
.with(LinuxAdmin::Common.cmd(:chkconfig),
|
35
|
-
:params => {nil => %w(foo on)})
|
36
|
-
@service.enable
|
37
|
-
end
|
38
|
-
|
39
|
-
it "returns self" do
|
40
|
-
expect(LinuxAdmin::Common).to receive(:run!) # stub out cmd invocation
|
41
|
-
expect(@service.enable).to eq(@service)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#disable" do
|
46
|
-
it "disable service" do
|
47
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
48
|
-
.with(LinuxAdmin::Common.cmd(:chkconfig),
|
49
|
-
:params => {nil => %w(foo off)})
|
50
|
-
@service.disable
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns self" do
|
54
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
55
|
-
expect(@service.disable).to eq(@service)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#start" do
|
60
|
-
it "starts service" do
|
61
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
62
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
63
|
-
:params => {nil => %w(foo start)})
|
64
|
-
@service.start
|
65
|
-
end
|
66
|
-
|
67
|
-
it "returns self" do
|
68
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
69
|
-
expect(@service.start).to eq(@service)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#stop" do
|
74
|
-
it "stops service" do
|
75
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
76
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
77
|
-
:params => {nil => %w(foo stop)})
|
78
|
-
@service.stop
|
79
|
-
end
|
80
|
-
|
81
|
-
it "returns self" do
|
82
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
83
|
-
expect(@service.stop).to eq(@service)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "#restart" do
|
88
|
-
it "stops service" do
|
89
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
90
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
91
|
-
:params => {nil => %w(foo restart)}).and_return(double(:exit_status => 0))
|
92
|
-
@service.restart
|
93
|
-
end
|
94
|
-
|
95
|
-
context "service restart fails" do
|
96
|
-
it "manually stops/starts service" do
|
97
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
|
98
|
-
expect(@service).to receive(:stop)
|
99
|
-
expect(@service).to receive(:start)
|
100
|
-
@service.restart
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
it "returns self" do
|
105
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
|
106
|
-
expect(@service.restart).to eq(@service)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "#reload" do
|
111
|
-
it "reloads service" do
|
112
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
113
|
-
.with(LinuxAdmin::Common.cmd(:service), :params => %w(foo reload))
|
114
|
-
expect(@service.reload).to eq(@service)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe "#status" do
|
119
|
-
it "returns the service status" do
|
120
|
-
status = "service status here"
|
121
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
122
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
123
|
-
:params => %w(foo status)).and_return(double(:output => status))
|
124
|
-
expect(@service.status).to eq(status)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::SystemdService do
|
2
|
-
let(:command) { LinuxAdmin::Common.cmd(:systemctl) }
|
3
|
-
|
4
|
-
before do
|
5
|
-
@service = described_class.new 'foo'
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#running?" do
|
9
|
-
it "checks service" do
|
10
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
11
|
-
.with(command, :params => %w(status foo)).and_return(double(:success? => true))
|
12
|
-
@service.running?
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns true when service is running" do
|
16
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:success? => true))
|
17
|
-
expect(@service).to be_running
|
18
|
-
end
|
19
|
-
|
20
|
-
it "returns false when service is not running" do
|
21
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:success? => false))
|
22
|
-
expect(@service).not_to be_running
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#enable" do
|
27
|
-
it "enables service" do
|
28
|
-
expect(LinuxAdmin::Common).to receive(:run!) .with(command, :params => %w(enable foo))
|
29
|
-
@service.enable
|
30
|
-
end
|
31
|
-
|
32
|
-
it "returns self" do
|
33
|
-
expect(LinuxAdmin::Common).to receive(:run!) # stub out cmd invocation
|
34
|
-
expect(@service.enable).to eq(@service)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#disable" do
|
39
|
-
it "disables service" do
|
40
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(command, :params => %w(disable foo))
|
41
|
-
@service.disable
|
42
|
-
end
|
43
|
-
|
44
|
-
it "returns self" do
|
45
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
46
|
-
expect(@service.disable).to eq(@service)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#start" do
|
51
|
-
it "starts service" do
|
52
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(command, :params => %w(start foo))
|
53
|
-
@service.start
|
54
|
-
end
|
55
|
-
|
56
|
-
it "returns self" do
|
57
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
58
|
-
expect(@service.start).to eq(@service)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "#stop" do
|
63
|
-
it "stops service" do
|
64
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(command, :params => %w(stop foo))
|
65
|
-
@service.stop
|
66
|
-
end
|
67
|
-
|
68
|
-
it "returns self" do
|
69
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
70
|
-
expect(@service.stop).to eq(@service)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#restart" do
|
75
|
-
it "restarts service" do
|
76
|
-
expect(LinuxAdmin::Common).to receive(:run).with(command, :params => %w(restart foo)).and_return(double(:exit_status => 0))
|
77
|
-
@service.restart
|
78
|
-
end
|
79
|
-
|
80
|
-
it "manually stops then starts service when restart fails" do
|
81
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
|
82
|
-
expect(@service).to receive(:stop)
|
83
|
-
expect(@service).to receive(:start)
|
84
|
-
@service.restart
|
85
|
-
end
|
86
|
-
|
87
|
-
it "returns self" do
|
88
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
|
89
|
-
expect(@service.restart).to eq(@service)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "#reload" do
|
94
|
-
it "reloads service" do
|
95
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(command, :params => %w(reload foo))
|
96
|
-
expect(@service.reload).to eq(@service)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#status" do
|
101
|
-
it "returns the service status" do
|
102
|
-
status = "service status here"
|
103
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
104
|
-
.with(command, :params => %w(status foo)).and_return(double(:output => status))
|
105
|
-
expect(@service.status).to eq(status)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "#show" do
|
110
|
-
it "returns a hash of runtime information" do
|
111
|
-
output = <<-EOS
|
112
|
-
MainPID=29189
|
113
|
-
ExecMainStartTimestamp=Wed 2017-02-08 13:49:57 EST
|
114
|
-
ExecStart={ path=/bin/sh ; argv[]=/bin/sh -c /bin/evmserver.sh start ; status=0/0 }
|
115
|
-
ExecStop={ path=/bin/sh ; argv[]=/bin/sh -c /bin/evmserver.sh stop ; status=0/0 }
|
116
|
-
ControlGroup=/system.slice/evmserverd.service
|
117
|
-
MemoryCurrent=2865373184
|
118
|
-
EOS
|
119
|
-
|
120
|
-
hash = {
|
121
|
-
"MainPID" => 29_189,
|
122
|
-
"ExecMainStartTimestamp" => Time.new(2017, 2, 8, 13, 49, 57, "-05:00"),
|
123
|
-
"ExecStart" => {"path" => "/bin/sh", "argv[]" => "/bin/sh -c /bin/evmserver.sh start", "status" => "0/0"},
|
124
|
-
"ExecStop" => {"path" => "/bin/sh", "argv[]" => "/bin/sh -c /bin/evmserver.sh stop", "status" => "0/0"},
|
125
|
-
"ControlGroup" => "/system.slice/evmserverd.service",
|
126
|
-
"MemoryCurrent" => 2_865_373_184
|
127
|
-
}
|
128
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
129
|
-
.with(command, :params => %w(show foo)).and_return(double(:output => output))
|
130
|
-
expect(@service.show).to eq(hash)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
data/spec/service_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Service do
|
2
|
-
context ".service_type" do
|
3
|
-
it "on systemctl systems" do
|
4
|
-
stub_to_service_type(:systemd_service)
|
5
|
-
expect(described_class.service_type).to eq(LinuxAdmin::SystemdService)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "on sysv systems" do
|
9
|
-
stub_to_service_type(:sys_v_init_service)
|
10
|
-
expect(described_class.service_type).to eq(LinuxAdmin::SysVInitService)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should memoize results" do
|
14
|
-
expect(described_class).to receive(:service_type_uncached).once.and_return("anything_non_nil")
|
15
|
-
described_class.service_type
|
16
|
-
described_class.service_type
|
17
|
-
end
|
18
|
-
|
19
|
-
it "with reload should refresh results" do
|
20
|
-
expect(described_class).to receive(:service_type_uncached).twice.and_return("anything_non_nil")
|
21
|
-
described_class.service_type
|
22
|
-
described_class.service_type(true)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context ".new" do
|
27
|
-
it "on systemctl systems" do
|
28
|
-
stub_to_service_type(:systemd_service)
|
29
|
-
expect(described_class.new("xxx")).to be_kind_of(LinuxAdmin::SystemdService)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "on sysv systems" do
|
33
|
-
stub_to_service_type(:sys_v_init_service)
|
34
|
-
expect(described_class.new("xxx")).to be_kind_of(LinuxAdmin::SysVInitService)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "#id / #id=" do
|
39
|
-
s = described_class.new("xxx")
|
40
|
-
expect(s.id).to eq("xxx")
|
41
|
-
|
42
|
-
s.id = "yyy"
|
43
|
-
expect(s.id).to eq("yyy")
|
44
|
-
expect(s.name).to eq("yyy")
|
45
|
-
|
46
|
-
s.name = "zzz"
|
47
|
-
expect(s.id).to eq("zzz")
|
48
|
-
expect(s.name).to eq("zzz")
|
49
|
-
end
|
50
|
-
|
51
|
-
def stub_to_service_type(system)
|
52
|
-
allow(LinuxAdmin::Common).to receive(:cmd?).with(:systemctl).and_return(system == :systemd_service)
|
53
|
-
end
|
54
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
-
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
-
#
|
6
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
-
# individual file that may not need all of that loaded. Instead, make a
|
10
|
-
# separate helper file that requires this one and then use it only in the specs
|
11
|
-
# that actually need it.
|
12
|
-
#
|
13
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
-
# users commonly want.
|
15
|
-
#
|
16
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
-
RSpec.configure do |config|
|
18
|
-
# The settings below are suggested to provide a good initial experience
|
19
|
-
# with RSpec, but feel free to customize to your heart's content.
|
20
|
-
|
21
|
-
# These two settings work together to allow you to limit a spec run
|
22
|
-
# to individual examples or groups you care about by tagging them with
|
23
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
24
|
-
# get run.
|
25
|
-
config.filter_run :focus
|
26
|
-
config.run_all_when_everything_filtered = true
|
27
|
-
|
28
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
29
|
-
# file, and it's useful to allow more verbose output when running an
|
30
|
-
# individual spec file.
|
31
|
-
if config.files_to_run.one?
|
32
|
-
# Use the documentation formatter for detailed output,
|
33
|
-
# unless a formatter has already been configured
|
34
|
-
# (e.g. via a command-line flag).
|
35
|
-
config.default_formatter = 'doc'
|
36
|
-
end
|
37
|
-
|
38
|
-
# Print the 10 slowest examples and example groups at the
|
39
|
-
# end of the spec run, to help surface which specs are running
|
40
|
-
# particularly slow.
|
41
|
-
# config.profile_examples = 10
|
42
|
-
|
43
|
-
# Run specs in random order to surface order dependencies. If you find an
|
44
|
-
# order dependency and want to debug it, you can fix the order by providing
|
45
|
-
# the seed, which is printed after each run.
|
46
|
-
# --seed 1234
|
47
|
-
config.order = :random
|
48
|
-
|
49
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
50
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
51
|
-
# test failures related to randomization by passing the same `--seed` value
|
52
|
-
# as the one that triggered the failure.
|
53
|
-
Kernel.srand config.seed
|
54
|
-
|
55
|
-
# rspec-expectations config goes here. You can use an alternate
|
56
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
57
|
-
# assertions if you prefer.
|
58
|
-
config.expect_with :rspec do |expectations|
|
59
|
-
# Enable only the newer, non-monkey-patching expect syntax.
|
60
|
-
# For more details, see:
|
61
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
62
|
-
expectations.syntax = :expect
|
63
|
-
end
|
64
|
-
|
65
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
66
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
67
|
-
config.mock_with :rspec do |mocks|
|
68
|
-
# Enable only the newer, non-monkey-patching expect syntax.
|
69
|
-
# For more details, see:
|
70
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
71
|
-
mocks.syntax = :expect
|
72
|
-
|
73
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
74
|
-
# a real object. This is generally recommended.
|
75
|
-
mocks.verify_partial_doubles = true
|
76
|
-
end
|
77
|
-
|
78
|
-
config.after do
|
79
|
-
clear_caches
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
begin
|
84
|
-
require 'coveralls'
|
85
|
-
Coveralls.wear!
|
86
|
-
rescue LoadError
|
87
|
-
end
|
88
|
-
|
89
|
-
require 'linux_admin'
|
90
|
-
|
91
|
-
def etc_issue_contains(contents)
|
92
|
-
LinuxAdmin::EtcIssue.instance.send(:refresh)
|
93
|
-
allow(File).to receive(:exist?).with('/etc/issue').at_least(:once).and_return(true)
|
94
|
-
allow(File).to receive(:read).with('/etc/issue').at_least(:once).and_return(contents)
|
95
|
-
end
|
96
|
-
|
97
|
-
def stub_distro(distro = LinuxAdmin::Distros.rhel)
|
98
|
-
# simply alias test distro to redhat distro for time being
|
99
|
-
allow(LinuxAdmin::Distros).to receive_messages(:local => distro)
|
100
|
-
end
|
101
|
-
|
102
|
-
def data_file_path(to)
|
103
|
-
File.expand_path(to, File.join(File.dirname(__FILE__), "data"))
|
104
|
-
end
|
105
|
-
|
106
|
-
def sample_output(to)
|
107
|
-
File.read(data_file_path(to))
|
108
|
-
end
|
109
|
-
|
110
|
-
def clear_caches
|
111
|
-
LinuxAdmin::RegistrationSystem.instance_variable_set(:@registration_type, nil)
|
112
|
-
LinuxAdmin::Service.instance_variable_set(:@service_type, nil)
|
113
|
-
|
114
|
-
# reset the distro, tested in various placed & used extensively
|
115
|
-
LinuxAdmin::Distros.instance_variable_set(:@local, nil)
|
116
|
-
end
|
data/spec/ssh_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::SSH do
|
2
|
-
before(:each) do
|
3
|
-
require 'net/ssh'
|
4
|
-
@example_ssh_key = <<-eos
|
5
|
-
-----BEGIN RSA PRIVATE KEY-----
|
6
|
-
MIIEowIBAAKCAQEAasdvkMNteq7hjnqNE61ESnEHnaOtHxZffdsQ33R7BXcu9eCH
|
7
|
-
ncZadHmmfRZgMPQnHGX0NzboVKfdpdF40o+iGQKyy3wKqdgGnTAWqx/hxrsdsdgh
|
8
|
-
f/g7AABNjoWp1OiTX2Dn99SH9xPQtpdnwGlBmtPplV2wNcKouQwGbwb/u1EHHxnO
|
9
|
-
aSQk2tvKHRMgroLsyuM5ay7TrK5cip2QTMn9fieHIepH0qd8ETG+1Uf+XmZxhdMN
|
10
|
-
QsuiSbAAmuU9qwlXh6QOg1spJ97B/ZY6Ci4d5cdBCCtfjGDBm8CzbrfhYVNhGcNx
|
11
|
-
c3Y43ld6MJoE+hMuBrBSuZyBmf63AAMqJ8KeQwIDAQABAoIBAFMFXBoSWOy1V9z3
|
12
|
-
IkoY1ilBp5WKRvaPEMCgeCfZIjIG0Nmt5Knbkp2b3A8YWnGQlDHqdYz53t9RHaaU
|
13
|
-
KdCnJ9vUSYeeeNElMsCwMYVoZvA5Xpv9cw2YOeTrOzssX1VZv9WW1zHd0Srz9N3r
|
14
|
-
719MgpyK4dZACw6ODeD/gh8+OH5OAN9sVbIGniApHZENxJrZzL22qE2asf8vVfgu
|
15
|
-
9XNx3WhsdL6ktoeJWLKxTLwVP6xRK/ixvsayUFeMBC4E1+sBuz1z7p27kd8cEC5o
|
16
|
-
AEHSwF6nr+ix0JctbAYqPVFZi5zFH10WgxyF3asAiQPYrCrY9gT8OQSRDhhKyIXE
|
17
|
-
rHlLIfkCgYEA+RuY4vsqeU69APFXRCy9s/dcy8tS0Pslq/fq4KsdC4qRu39RjotN
|
18
|
-
/OXOtVMPRfjTiRHXi/0fvSfyMVgstCtfYpOcoz98tw2AX34AgAH6h57I29rVxk5q
|
19
|
-
OomgcauRYlmO9ge3429pvECL5EzBbRKwfwuMKHMNetLHdVMc7d165f0CgYEAzdGf
|
20
|
-
6VMnZkK66XP/RzMvwUwvdhy+vIUjXFMjotQXYcYcLZadiZET7riOSRyVRvlNg0va
|
21
|
-
CexWtX+0yOZOrXCvLzSpO8Z91VnkHbRhnpy4bvW/qcFpwIvYeaMgr5C1lBHCIvZS
|
22
|
-
wSojNrdjAbdQoqab9X7Mxj2ubYGxUSSg715wqT8CgYBaY20iT0imI6/o+6lSj3l2
|
23
|
-
J7eAKxKtybNtptOPF6RVq74dbqFFO77cmPZcTPspxJPdFKBFp18w36G9zeTKq0I9
|
24
|
-
HpqjkZHLShbej3XW/ODO/Qqc29bd0e4xt2aEWGC0cxKwqzRKTk7rg/A+sqsszK9G
|
25
|
-
KgZ9VuH5QyokpDfHB6pkcQKBgChsq8PgGTT0llGT/ue1HgQROqEwNCZC4BcaHT21
|
26
|
-
+oGxr4cktfx3Cjsw9IFXo9o0zQyksUaRrNYpJxDuazWVlFLpPPQIoF5vMWbELwhA
|
27
|
-
L9lbWzG0U1kGHpaFe73/5ioW8tJ7HvXhmNj+W+vSXXwUzT0CkqW9J61Kc9FEKHfb
|
28
|
-
TLVxAoGBAM8WKsTfEMxuv5pabGTo8BC1ruz4c5qLJGLGnH4kWJm5o6ippugFsOlK
|
29
|
-
rDUWive4uLSKi3Fsb2kPw6gHuRGerFN1CBpCENLib3xG5Bd4XhmKZMDxqU2bO0gd
|
30
|
-
sV1Tr/acrE0aWBkD9RYrR2/UwG1zfXuIJeufdWf8c0SY3X6J7jJN
|
31
|
-
-----END RSA PRIVATE KEY-----
|
32
|
-
eos
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should create a call using agent" do
|
36
|
-
expect(Net::SSH).to receive(:start).with("127.0.0.1", "root", :verify_host_key => false, :forward_agent => true, :number_of_password_prompts => 0, :agent_socket_factory => Proc).and_return(true)
|
37
|
-
ssh_agent = LinuxAdmin::SSHAgent.new(@example_ssh_key)
|
38
|
-
ssh_agent.with_service do |socket|
|
39
|
-
ssh = LinuxAdmin::SSH.new("127.0.0.1", "root")
|
40
|
-
ssh.perform_commands(%w("ls", "pwd"), socket)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should preform command using private key" do
|
45
|
-
expect(Net::SSH).to receive(:start).with("127.0.0.1", "root", :verify_host_key => false, :number_of_password_prompts => 0, :key_data => [@example_ssh_key]).and_return(true)
|
46
|
-
LinuxAdmin::SSH.new("127.0.0.1", "root", @example_ssh_key).perform_commands(%w("ls", "pwd"))
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should preform command using password" do
|
50
|
-
expect(Net::SSH).to receive(:start).with("127.0.0.1", "root", :verify_host_key => false, :number_of_password_prompts => 0, :password => "password").and_return(true)
|
51
|
-
LinuxAdmin::SSH.new("127.0.0.1", "root", nil, "password").perform_commands(%w("ls", "pwd"))
|
52
|
-
end
|
53
|
-
end
|