linux_admin 1.2.2 → 2.0.2
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/README.md +1 -1
- data/lib/linux_admin.rb +0 -8
- data/lib/linux_admin/chrony.rb +1 -0
- data/lib/linux_admin/disk.rb +31 -8
- data/lib/linux_admin/fstab.rb +29 -14
- data/lib/linux_admin/partition.rb +1 -1
- 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 +36 -122
- 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 -246
- 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 -66
- 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
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
|
@@ -1,228 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::SubscriptionManager do
|
2
|
-
context "#run!" do
|
3
|
-
it "raises a CredentialError if the error message contained a credential error" do
|
4
|
-
result = AwesomeSpawn::CommandResult.new("stuff", "things", "invalid username or password", 1)
|
5
|
-
err = AwesomeSpawn::CommandResultError.new("things", result)
|
6
|
-
expect(LinuxAdmin::Common).to receive(:run!).and_raise(err)
|
7
|
-
|
8
|
-
expect { subject.run!("stuff") }.to raise_error(LinuxAdmin::CredentialError)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "raises a SubscriptionManagerError if the error message does not contain a credential error" do
|
12
|
-
result = AwesomeSpawn::CommandResult.new("stuff", "things", "not a credential error", 1)
|
13
|
-
err = AwesomeSpawn::CommandResultError.new("things", result)
|
14
|
-
expect(LinuxAdmin::Common).to receive(:run!).and_raise(err)
|
15
|
-
|
16
|
-
expect { subject.run!("stuff") }.to raise_error(LinuxAdmin::SubscriptionManagerError)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "#registered?" do
|
21
|
-
it "system with subscription-manager commands" do
|
22
|
-
expect(LinuxAdmin::Common).to receive(:run).once.with("subscription-manager identity")
|
23
|
-
.and_return(double(:exit_status => 0))
|
24
|
-
expect(described_class.new.registered?).to be_truthy
|
25
|
-
end
|
26
|
-
|
27
|
-
it "system without subscription-manager commands" do
|
28
|
-
expect(LinuxAdmin::Common).to receive(:run).once.with("subscription-manager identity")
|
29
|
-
.and_return(double(:exit_status => 255))
|
30
|
-
expect(described_class.new.registered?).to be_falsey
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "#refresh" do
|
35
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager refresh", {})
|
36
|
-
described_class.new.refresh
|
37
|
-
end
|
38
|
-
|
39
|
-
context "#register" do
|
40
|
-
it "no username" do
|
41
|
-
expect { described_class.new.register }.to raise_error(ArgumentError)
|
42
|
-
end
|
43
|
-
|
44
|
-
context "with username and password" do
|
45
|
-
let(:base_options) { {:username => "SomeUser@SomeDomain.org",
|
46
|
-
:password => "SomePass",
|
47
|
-
:environment => "Library",
|
48
|
-
:org => "IT",
|
49
|
-
:proxy_address => "1.2.3.4",
|
50
|
-
:proxy_username => "ProxyUser",
|
51
|
-
:proxy_password => "ProxyPass",
|
52
|
-
}
|
53
|
-
}
|
54
|
-
let(:run_params) { {:params=>{"--username="=>"SomeUser@SomeDomain.org", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass", "--environment="=>"Library"}} }
|
55
|
-
|
56
|
-
it "with server_url" do
|
57
|
-
run_params.store_path(:params, "--org=", "IT")
|
58
|
-
base_options.store_path(:server_url, "https://server.url")
|
59
|
-
|
60
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager register", run_params)
|
61
|
-
expect(LinuxAdmin::Rpm).to receive(:upgrade).with("http://server.url/pub/katello-ca-consumer-latest.noarch.rpm")
|
62
|
-
|
63
|
-
described_class.new.register(base_options)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "without server_url" do
|
67
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager register", run_params)
|
68
|
-
expect_any_instance_of(described_class).not_to receive(:install_server_certificate)
|
69
|
-
|
70
|
-
described_class.new.register(base_options)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "#subscribe" do
|
76
|
-
it "with pools" do
|
77
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
78
|
-
.with("subscription-manager attach", :params => [["--pool", 123], ["--pool", 456]])
|
79
|
-
described_class.new.subscribe({:pools => [123, 456]})
|
80
|
-
end
|
81
|
-
|
82
|
-
it "without pools" do
|
83
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
84
|
-
.with("subscription-manager attach", :params => {"--auto" => nil})
|
85
|
-
described_class.new.subscribe({})
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "#subscribed_products" do
|
90
|
-
it "subscribed" do
|
91
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager list --installed", {})
|
92
|
-
.and_return(double(:output => sample_output("subscription_manager/output_list_installed_subscribed")))
|
93
|
-
expect(described_class.new.subscribed_products).to eq(["69", "167"])
|
94
|
-
end
|
95
|
-
|
96
|
-
it "not subscribed" do
|
97
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager list --installed", {})
|
98
|
-
.and_return(double(:output => sample_output("subscription_manager/output_list_installed_not_subscribed")))
|
99
|
-
expect(described_class.new.subscribed_products).to eq(["167"])
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
it "#available_subscriptions" do
|
104
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager list --all --available", {})
|
105
|
-
.and_return(double(:output => sample_output("subscription_manager/output_list_all_available")))
|
106
|
-
expect(described_class.new.available_subscriptions).to eq({
|
107
|
-
"82c042fca983889b10178893f29b06e3" => {
|
108
|
-
:subscription_name => "Example Subscription",
|
109
|
-
:sku => "SER0123",
|
110
|
-
:pool_id => "82c042fca983889b10178893f29b06e3",
|
111
|
-
:quantity => "1690",
|
112
|
-
:service_level => "None",
|
113
|
-
:service_type => "None",
|
114
|
-
:multi_entitlement => "No",
|
115
|
-
:ends => Date.parse("2022-01-01"),
|
116
|
-
:system_type => "Physical",
|
117
|
-
},
|
118
|
-
"4f738052ec866192c775c62f408ab868" => {
|
119
|
-
:subscription_name => "My Private Subscription",
|
120
|
-
:sku => "SER9876",
|
121
|
-
:pool_id => "4f738052ec866192c775c62f408ab868",
|
122
|
-
:quantity => "Unlimited",
|
123
|
-
:service_level => "None",
|
124
|
-
:service_type => "None",
|
125
|
-
:multi_entitlement => "No",
|
126
|
-
:ends => Date.parse("2013-06-04"),
|
127
|
-
:system_type => "Virtual",
|
128
|
-
},
|
129
|
-
"3d81297f352305b9a3521981029d7d83" => {
|
130
|
-
:subscription_name => "Shared Subscription - With other characters, (2 sockets) (Up to 1 guest)",
|
131
|
-
:sku => "RH0123456",
|
132
|
-
:pool_id => "3d81297f352305b9a3521981029d7d83",
|
133
|
-
:quantity => "1",
|
134
|
-
:service_level => "Self-support",
|
135
|
-
:service_type => "L1-L3",
|
136
|
-
:multi_entitlement => "No",
|
137
|
-
:ends => Date.parse("2013-05-15"),
|
138
|
-
:system_type => "Virtual",
|
139
|
-
},
|
140
|
-
"87cefe63b67984d5c7e401d833d2f87f" => {
|
141
|
-
:subscription_name => "Example Subscription, Premium (up to 2 sockets) 3 year",
|
142
|
-
:sku => "MCT0123A9",
|
143
|
-
:pool_id => "87cefe63b67984d5c7e401d833d2f87f",
|
144
|
-
:quantity => "1",
|
145
|
-
:service_level => "Premium",
|
146
|
-
:service_type => "L1-L3",
|
147
|
-
:multi_entitlement => "No",
|
148
|
-
:ends => Date.parse("2013-07-05"),
|
149
|
-
:system_type => "Virtual",
|
150
|
-
},
|
151
|
-
})
|
152
|
-
end
|
153
|
-
|
154
|
-
context "#organizations" do
|
155
|
-
it "with valid credentials" do
|
156
|
-
run_options = ["subscription-manager orgs", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass"}}]
|
157
|
-
|
158
|
-
expect(LinuxAdmin::Rpm).to receive(:upgrade).with("http://192.168.1.1/pub/katello-ca-consumer-latest.noarch.rpm")
|
159
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with(*run_options)
|
160
|
-
.and_return(double(:output => sample_output("subscription_manager/output_orgs")))
|
161
|
-
|
162
|
-
expect(described_class.new.organizations({:username=>"SomeUser", :password=>"SomePass", :proxy_address=>"1.2.3.4", :proxy_username=>"ProxyUser", :proxy_password=>"ProxyPass", :server_url=>"192.168.1.1"})).to eq({"SomeOrg"=>{:name=>"SomeOrg", :key=>"1234567"}})
|
163
|
-
end
|
164
|
-
|
165
|
-
it "with invalid credentials" do
|
166
|
-
run_options = ["subscription-manager orgs", {:params=>{"--username="=>"BadUser", "--password="=>"BadPass"}}]
|
167
|
-
error = AwesomeSpawn::CommandResultError.new("",
|
168
|
-
double(
|
169
|
-
:error => "Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html",
|
170
|
-
:exit_status => 255
|
171
|
-
)
|
172
|
-
)
|
173
|
-
expect(AwesomeSpawn).to receive(:run!).once.with(*run_options).and_raise(error)
|
174
|
-
expect { described_class.new.organizations({:username=>"BadUser", :password=>"BadPass"}) }.to raise_error(LinuxAdmin::CredentialError)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
it "#enable_repo" do
|
179
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
180
|
-
.with("subscription-manager repos", :params => {"--enable=" => "abc"})
|
181
|
-
|
182
|
-
described_class.new.enable_repo("abc")
|
183
|
-
end
|
184
|
-
|
185
|
-
it "#disable_repo" do
|
186
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
187
|
-
.with("subscription-manager repos", :params => {"--disable=" => "abc"})
|
188
|
-
|
189
|
-
described_class.new.disable_repo("abc")
|
190
|
-
end
|
191
|
-
|
192
|
-
it "#all_repos" do
|
193
|
-
expected = [
|
194
|
-
{
|
195
|
-
:repo_id => "some-repo-source-rpms",
|
196
|
-
:repo_name => "Some Repo (Source RPMs)",
|
197
|
-
:repo_url => "https://my.host.example.com/repos/some-repo/source/rpms",
|
198
|
-
:enabled => true
|
199
|
-
},
|
200
|
-
{
|
201
|
-
:repo_id => "some-repo-rpms",
|
202
|
-
:repo_name => "Some Repo",
|
203
|
-
:repo_url => "https://my.host.example.com/repos/some-repo/rpms",
|
204
|
-
:enabled => true
|
205
|
-
},
|
206
|
-
{
|
207
|
-
:repo_id => "some-repo-2-beta-rpms",
|
208
|
-
:repo_name => "Some Repo (Beta RPMs)",
|
209
|
-
:repo_url => "https://my.host.example.com/repos/some-repo-2/beta/rpms",
|
210
|
-
:enabled => false
|
211
|
-
}
|
212
|
-
]
|
213
|
-
|
214
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager repos", {})
|
215
|
-
.and_return(double(:output => sample_output("subscription_manager/output_repos")))
|
216
|
-
|
217
|
-
expect(described_class.new.all_repos).to eq(expected)
|
218
|
-
end
|
219
|
-
|
220
|
-
it "#enabled_repos" do
|
221
|
-
expected = ["some-repo-source-rpms", "some-repo-rpms"]
|
222
|
-
|
223
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager repos", {})
|
224
|
-
.and_return(double(:output => sample_output("subscription_manager/output_repos")))
|
225
|
-
|
226
|
-
expect(described_class.new.enabled_repos).to eq(expected)
|
227
|
-
end
|
228
|
-
end
|