linux_admin 1.2.2 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/linux_admin.rb +0 -8
  4. data/lib/linux_admin/chrony.rb +1 -0
  5. data/lib/linux_admin/disk.rb +31 -8
  6. data/lib/linux_admin/fstab.rb +29 -14
  7. data/lib/linux_admin/partition.rb +1 -1
  8. data/lib/linux_admin/registration_system.rb +8 -4
  9. data/lib/linux_admin/scap.rb +1 -1
  10. data/lib/linux_admin/service/sys_v_init_service.rb +2 -1
  11. data/lib/linux_admin/service/systemd_service.rb +6 -2
  12. data/lib/linux_admin/version.rb +1 -1
  13. metadata +36 -122
  14. data/lib/linux_admin/registration_system/rhn.rb +0 -111
  15. data/spec/chrony_spec.rb +0 -64
  16. data/spec/common_spec.rb +0 -37
  17. data/spec/data/rhn/output_rhn-channel_list +0 -2
  18. data/spec/data/rhn/output_rhn-channel_list_available +0 -4
  19. data/spec/data/rhn/systemid +0 -57
  20. data/spec/data/rhn/systemid.missing_system_id +0 -57
  21. data/spec/data/rpm/cmd_output_for_list_installed +0 -20
  22. data/spec/data/subscription_manager/output_list_all_available +0 -42
  23. data/spec/data/subscription_manager/output_list_installed_not_subscribed +0 -19
  24. data/spec/data/subscription_manager/output_list_installed_subscribed +0 -19
  25. data/spec/data/subscription_manager/output_orgs +0 -6
  26. data/spec/data/subscription_manager/output_repos +0 -18
  27. data/spec/data/time_date/timedatectl_output +0 -14
  28. data/spec/data/yum/first.repo +0 -19
  29. data/spec/data/yum/output_repo_list +0 -13
  30. data/spec/data/yum/output_repoquery_multiple +0 -3
  31. data/spec/data/yum/output_repoquery_single +0 -1
  32. data/spec/data/yum/second.repo +0 -9
  33. data/spec/deb_spec.rb +0 -52
  34. data/spec/disk_spec.rb +0 -246
  35. data/spec/distro_spec.rb +0 -77
  36. data/spec/dns_spec.rb +0 -105
  37. data/spec/etc_issue_spec.rb +0 -37
  38. data/spec/fstab_spec.rb +0 -66
  39. data/spec/hardware_spec.rb +0 -46
  40. data/spec/hosts_spec.rb +0 -150
  41. data/spec/ip_address_spec.rb +0 -148
  42. data/spec/logical_volume_spec.rb +0 -166
  43. data/spec/mountable_spec.rb +0 -182
  44. data/spec/network_interface/network_interface_rh_spec.rb +0 -291
  45. data/spec/network_interface_spec.rb +0 -284
  46. data/spec/partition_spec.rb +0 -24
  47. data/spec/physical_volume_spec.rb +0 -101
  48. data/spec/registration_system_spec.rb +0 -85
  49. data/spec/rhn_spec.rb +0 -144
  50. data/spec/rpm_spec.rb +0 -85
  51. data/spec/scap_spec.rb +0 -48
  52. data/spec/service/sys_v_init_service_spec.rb +0 -127
  53. data/spec/service/systemd_service_spec.rb +0 -133
  54. data/spec/service_spec.rb +0 -54
  55. data/spec/spec_helper.rb +0 -116
  56. data/spec/ssh_spec.rb +0 -53
  57. data/spec/subscription_manager_spec.rb +0 -228
  58. data/spec/system_spec.rb +0 -15
  59. data/spec/time_date_spec.rb +0 -106
  60. data/spec/volume_group_spec.rb +0 -99
  61. data/spec/yum_spec.rb +0 -155
@@ -1,284 +0,0 @@
1
- describe LinuxAdmin::NetworkInterface do
2
- let(:device_name) { "eth0" }
3
- let(:config_file_path) { LinuxAdmin::NetworkInterfaceRH.path_to_interface_config_file(device_name) }
4
- context "on redhat systems" do
5
- describe ".dist_class" do
6
- it "returns NetworkInterfaceRH" do
7
- allow(LinuxAdmin::Distros).to receive(:local).and_return(LinuxAdmin::Distros.rhel)
8
- expect(described_class.dist_class(true)).to eq(LinuxAdmin::NetworkInterfaceRH)
9
- end
10
- end
11
-
12
- describe ".new" do
13
- before do
14
- allow_any_instance_of(described_class).to receive(:ip_show).and_raise(LinuxAdmin::NetworkInterfaceError.new(nil, nil))
15
- allow(LinuxAdmin::Distros).to receive(:local).and_return(LinuxAdmin::Distros.rhel)
16
- described_class.dist_class(true)
17
- allow(Pathname).to receive(:new).and_return(config_file_path)
18
- end
19
-
20
- it "creates a NetworkInterfaceRH instance if the config file does exist" do
21
- expect(config_file_path).to receive(:file?).and_return(true)
22
- expect(File).to receive(:foreach).and_return("")
23
-
24
- expect(described_class.new(device_name)).to be_an_instance_of(LinuxAdmin::NetworkInterfaceRH)
25
- end
26
-
27
- it "creates a NetworkInterfaceRH instance if the config file does not exist" do
28
- expect(config_file_path).to receive(:file?).and_return(false)
29
-
30
- expect(described_class.new(device_name)).to be_an_instance_of(LinuxAdmin::NetworkInterfaceRH)
31
- end
32
- end
33
- end
34
-
35
- context "on other linux systems" do
36
- describe ".dist_class" do
37
- it "returns NetworkInterfaceGeneric" do
38
- allow(LinuxAdmin::Distros).to receive(:local).and_return(LinuxAdmin::Distros.generic)
39
- expect(described_class.dist_class(true)).to eq(LinuxAdmin::NetworkInterfaceGeneric)
40
- end
41
- end
42
-
43
- describe ".new" do
44
- subject do
45
- allow_any_instance_of(described_class).to receive(:ip_show).and_raise(LinuxAdmin::NetworkInterfaceError.new(nil, nil))
46
- allow(LinuxAdmin::Distros).to receive(:local).and_return(LinuxAdmin::Distros.generic)
47
- described_class.dist_class(true)
48
- described_class.new(device_name)
49
- end
50
-
51
- it "creates a NetworkInterfaceGeneric instance" do
52
- expect(subject).to be_an_instance_of(LinuxAdmin::NetworkInterfaceGeneric)
53
- end
54
- end
55
- end
56
-
57
- context "on all systems" do
58
- IP_SHOW_ARGS = [
59
- LinuxAdmin::Common.cmd("ip"),
60
- :params => %w(addr show eth0)
61
- ]
62
-
63
- IP_ROUTE_ARGS = [
64
- LinuxAdmin::Common.cmd("ip"),
65
- :params => ['-4', 'route']
66
- ]
67
-
68
- IP6_ROUTE_ARGS = [
69
- LinuxAdmin::Common.cmd("ip"),
70
- :params => ['-6', 'route']
71
- ]
72
-
73
- IFUP_ARGS = [
74
- LinuxAdmin::Common.cmd("ifup"),
75
- :params => ["eth0"]
76
- ]
77
-
78
- IFDOWN_ARGS = [
79
- LinuxAdmin::Common.cmd("ifdown"),
80
- :params => ["eth0"]
81
- ]
82
-
83
- IP_ADDR_OUT = <<-IP_OUT
84
- 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
85
- link/ether 00:0c:29:ed:0e:8b brd ff:ff:ff:ff:ff:ff
86
- inet 192.168.1.9/24 brd 192.168.1.255 scope global dynamic eth0
87
- valid_lft 1297sec preferred_lft 1297sec
88
- inet6 fe80::20c:29ff:feed:e8b/64 scope link
89
- valid_lft forever preferred_lft forever
90
- inet6 fd12:3456:789a:1::1/96 scope global
91
- valid_lft forever preferred_lft forever
92
- IP_OUT
93
-
94
- IP6_ADDR_OUT = <<-IP_OUT
95
- 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
96
- link/ether 00:0c:29:ed:0e:8b brd ff:ff:ff:ff:ff:ff
97
- inet6 fe80::20c:29ff:feed:e8b/64 scope link
98
- valid_lft forever preferred_lft forever
99
- inet6 fd12:3456:789a:1::1/96 scope global
100
- valid_lft forever preferred_lft forever
101
- IP_OUT
102
-
103
- IP_ROUTE_OUT = <<-IP_OUT
104
- default via 192.168.1.1 dev eth0 proto static metric 100
105
- 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.9 metric 100
106
- IP_OUT
107
- IP6_ROUTE_OUT = <<-IP_OUT
108
- default via d:e:a:d:b:e:e:f dev eth0 proto static metric 100
109
- fc00:dead:beef:a::/64 dev virbr1 proto kernel metric 256 linkdown pref medium
110
- fe80::/64 dev eth0 proto kernel scope link metric 100
111
- IP_OUT
112
-
113
- IP_NONE_ADDR_OUT = <<-IP_OUT.freeze
114
- 2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr1 state DOWN group default qlen 1000
115
- link/ether 52:54:00:ce:b4:f4 brd ff:ff:ff:ff:ff:ff
116
- IP_OUT
117
-
118
- subject(:subj) do
119
- allow(LinuxAdmin::Distros).to receive(:local).and_return(LinuxAdmin::Distros.generic)
120
- described_class.dist_class(true)
121
-
122
- allow(AwesomeSpawn).to receive(:run!).with(*IP_SHOW_ARGS).and_return(result(IP_ADDR_OUT, 0))
123
- allow(AwesomeSpawn).to receive(:run!).with(*IP_ROUTE_ARGS).and_return(result(IP_ROUTE_OUT, 0))
124
- allow(AwesomeSpawn).to receive(:run!).with(*IP6_ROUTE_ARGS).and_return(result(IP6_ROUTE_OUT, 0))
125
- described_class.new(device_name)
126
- end
127
-
128
- subject(:subj6) do
129
- allow(LinuxAdmin::Distros).to receive(:local).and_return(LinuxAdmin::Distros.generic)
130
- described_class.dist_class(true)
131
-
132
- allow(AwesomeSpawn).to receive(:run!).with(*IP_SHOW_ARGS).and_return(result(IP6_ADDR_OUT, 0))
133
- allow(AwesomeSpawn).to receive(:run!).with(*IP_ROUTE_ARGS).and_return(result(IP_ROUTE_OUT, 0))
134
- allow(AwesomeSpawn).to receive(:run!).with(*IP6_ROUTE_ARGS).and_return(result(IP6_ROUTE_OUT, 0))
135
- described_class.new(device_name)
136
- end
137
-
138
- subject(:subj_no_net) do
139
- allow(LinuxAdmin::Distros).to receive(:local).and_return(LinuxAdmin::Distros.generic)
140
- described_class.dist_class(true)
141
-
142
- allow(AwesomeSpawn).to receive(:run!).with(*IP_SHOW_ARGS).and_return(result(IP_NONE_ADDR_OUT, 0))
143
- allow(AwesomeSpawn).to receive(:run!).with(*IP_ROUTE_ARGS).and_return(result(IP_ROUTE_OUT, 0))
144
- allow(AwesomeSpawn).to receive(:run!).with(*IP6_ROUTE_ARGS).and_return(result(IP6_ROUTE_OUT, 0))
145
- described_class.new(device_name)
146
- end
147
-
148
- def result(output, exit_status)
149
- AwesomeSpawn::CommandResult.new("", output, "", exit_status)
150
- end
151
-
152
- describe "#reload" do
153
- it "returns false when ip addr show fails" do
154
- subj
155
- awesome_error = AwesomeSpawn::CommandResultError.new("", nil)
156
- allow(AwesomeSpawn).to receive(:run!).with(*IP_SHOW_ARGS).and_raise(awesome_error)
157
- expect(subj.reload).to eq(false)
158
- end
159
-
160
- it "raises when ip route fails" do
161
- subj
162
- awesome_error = AwesomeSpawn::CommandResultError.new("", nil)
163
- allow(AwesomeSpawn).to receive(:run!).with(*IP_SHOW_ARGS).and_return(result(IP_ADDR_OUT, 0))
164
- allow(AwesomeSpawn).to receive(:run!).with(*IP_ROUTE_ARGS).and_raise(awesome_error)
165
- allow(AwesomeSpawn).to receive(:run!).with(*IP6_ROUTE_ARGS).and_raise(awesome_error)
166
- expect { subj.reload }.to raise_error(LinuxAdmin::NetworkInterfaceError)
167
- end
168
-
169
- it "doesn't blow up when given only ipv6 addresses" do
170
- subj6
171
- allow(AwesomeSpawn).to receive(:run!).with(*IP_SHOW_ARGS).and_return(result(IP6_ADDR_OUT, 0))
172
- allow(AwesomeSpawn).to receive(:run!).with(*IP_ROUTE_ARGS).and_return(result(IP_ROUTE_OUT, 0))
173
- allow(AwesomeSpawn).to receive(:run!).with(*IP6_ROUTE_ARGS).and_return(result(IP6_ROUTE_OUT, 0))
174
- expect { subj.reload }.to_not raise_error
175
- end
176
- end
177
-
178
- describe "#address" do
179
- it "returns an address" do
180
- expect(subj.address).to eq("192.168.1.9")
181
- end
182
- end
183
-
184
- describe "#address6" do
185
- it "returns the global address by default" do
186
- expect(subj.address6).to eq("fd12:3456:789a:1::1")
187
- end
188
-
189
- it "returns the link local address" do
190
- expect(subj.address6(:link)).to eq("fe80::20c:29ff:feed:e8b")
191
- end
192
-
193
- it "raises ArgumentError when given a bad scope" do
194
- expect { subj.address6(:garbage) }.to raise_error(ArgumentError)
195
- end
196
- end
197
-
198
- describe "#mac_address" do
199
- it "returns the correct MAC address" do
200
- expect(subj.mac_address).to eq("00:0c:29:ed:0e:8b")
201
- end
202
- end
203
-
204
- describe "#netmask" do
205
- it "returns the correct netmask" do
206
- expect(subj.netmask).to eq("255.255.255.0")
207
- end
208
-
209
- it 'does not blow-up, when no ip assigned' do
210
- expect(subj_no_net.netmask).to eq(nil)
211
- end
212
- end
213
-
214
- describe "#netmask6" do
215
- it "returns the correct global netmask" do
216
- expect(subj.netmask6).to eq("ffff:ffff:ffff:ffff:ffff:ffff::")
217
- end
218
-
219
- it "returns the correct link local netmask" do
220
- expect(subj.netmask6(:link)).to eq("ffff:ffff:ffff:ffff::")
221
- end
222
-
223
- it "raises ArgumentError when given a bad scope" do
224
- expect { subj.netmask6(:garbage) }.to raise_error(ArgumentError)
225
- end
226
- end
227
-
228
- describe '#prefix' do
229
- it 'returns the correct prefix' do
230
- expect(subj.prefix).to eq(24)
231
- end
232
- end
233
-
234
- describe '#prefix6' do
235
- it 'returns the correct global prefix length' do
236
- expect(subj.prefix6).to eq(96)
237
- end
238
-
239
- it 'returns the correct link local prefix length' do
240
- expect(subj.prefix6(:link)).to eq(64)
241
- end
242
-
243
- it 'raises ArgumentError when given a bad scope' do
244
- expect { subj.prefix6(:garbage) }.to raise_error(ArgumentError)
245
- end
246
- end
247
-
248
- describe "#gateway" do
249
- it "returns the correct gateway address" do
250
- expect(subj.gateway).to eq("192.168.1.1")
251
- end
252
- end
253
-
254
- describe '#gateway6' do
255
- it 'returns the correct default gateway for IPv6 routing' do
256
- expect(subj.gateway6).to eq('d:e:a:d:b:e:e:f')
257
- end
258
- end
259
-
260
- describe "#start" do
261
- it "returns true on success" do
262
- expect(AwesomeSpawn).to receive(:run).with(*IFUP_ARGS).and_return(result("", 0))
263
- expect(subj.start).to be true
264
- end
265
-
266
- it "returns false on failure" do
267
- expect(AwesomeSpawn).to receive(:run).with(*IFUP_ARGS).and_return(result("", 1))
268
- expect(subj.start).to be false
269
- end
270
- end
271
-
272
- describe "#stop" do
273
- it "returns true on success" do
274
- expect(AwesomeSpawn).to receive(:run).with(*IFDOWN_ARGS).and_return(result("", 0))
275
- expect(subj.stop).to be true
276
- end
277
-
278
- it "returns false on failure" do
279
- expect(AwesomeSpawn).to receive(:run).with(*IFDOWN_ARGS).and_return(result("", 1))
280
- expect(subj.stop).to be false
281
- end
282
- end
283
- end
284
- end
@@ -1,24 +0,0 @@
1
- describe LinuxAdmin::Partition do
2
- before(:each) do
3
- @disk = LinuxAdmin::Disk.new :path => '/dev/sda'
4
- @partition = LinuxAdmin::Partition.new :disk => @disk, :id => 2
5
- end
6
-
7
- describe "#path" do
8
- it "returns partition path" do
9
- expect(@partition.path).to eq('/dev/sda2')
10
- end
11
- end
12
-
13
- describe "#mount" do
14
- context "mount_point not specified" do
15
- it "sets default mount_point" do
16
- expect(described_class).to receive(:mount_point_exists?).and_return(false)
17
- expect(File).to receive(:directory?).with('/mnt/sda2').and_return(true)
18
- expect(LinuxAdmin::Common).to receive(:run!)
19
- @partition.mount
20
- expect(@partition.mount_point).to eq('/mnt/sda2')
21
- end
22
- end
23
- end
24
- end
@@ -1,101 +0,0 @@
1
- describe LinuxAdmin::PhysicalVolume do
2
- before(:each) do
3
- @physical_volumes = <<eos
4
- /dev/vda2:vg_foobar:24139776:-1:8:8:-1:32768:368:0:368:pxR32D-YkC2-PfHe-zOwb-eaGD-9Ar0-mAOl9u
5
- eos
6
-
7
- @groups = <<eos
8
- vg_foobar:r/w:772:-1:0:2:2:-1:0:1:1:12058624:32768:368:368:0:tILZUF-IspH-H90I-pT5j-vVFl-b76L-zWx3CW
9
- eos
10
- end
11
-
12
- after(:each) do
13
- # reset local copies of volumes / groups
14
- LinuxAdmin::LogicalVolume.instance_variable_set(:@lvs, nil)
15
- described_class.instance_variable_set(:@pvs, nil)
16
- LinuxAdmin::VolumeGroup.instance_variable_set(:@vgs, nil)
17
- end
18
-
19
- describe "#attach_to" do
20
- it "uses vgextend" do
21
- vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
22
- pv = described_class.new :device_name => '/dev/hda'
23
- expect(LinuxAdmin::Common).to receive(:run!)
24
- .with(LinuxAdmin::Common.cmd(:vgextend),
25
- :params => ['vg', '/dev/hda'])
26
- pv.attach_to(vg)
27
- end
28
-
29
- it "assigns volume group to physical volume" do
30
- vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
31
- pv = described_class.new :device_name => '/dev/hda'
32
- allow(LinuxAdmin::Common).to receive(:run!)
33
- pv.attach_to(vg)
34
- expect(pv.volume_group).to eq(vg)
35
- end
36
-
37
- it "returns self" do
38
- vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
39
- pv = described_class.new :device_name => '/dev/hda'
40
- allow(LinuxAdmin::Common).to receive(:run!)
41
- expect(pv.attach_to(vg)).to eq(pv)
42
- end
43
- end
44
-
45
- describe "#create" do
46
- before do
47
- @disk = LinuxAdmin::Disk.new :path => '/dev/hda'
48
- allow(@disk).to receive(:size)
49
- end
50
-
51
- let(:disk) {@disk}
52
-
53
- it "uses pvcreate" do
54
- described_class.instance_variable_set(:@pvs, [])
55
- expect(LinuxAdmin::Common).to receive(:run!)
56
- .with(LinuxAdmin::Common.cmd(:pvcreate),
57
- :params => {nil => '/dev/hda'})
58
- described_class.create disk
59
- end
60
-
61
- it "returns new physical volume" do
62
- allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
63
- pv = described_class.create disk
64
- expect(pv).to be_an_instance_of(described_class)
65
- expect(pv.device_name).to eq('/dev/hda')
66
- end
67
-
68
- it "adds physical volume to local registry" do
69
- allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
70
- pv = described_class.create disk
71
- expect(described_class.scan).to include(pv)
72
- end
73
- end
74
-
75
- describe "#scan" do
76
- it "uses pvdisplay" do
77
- expect(LinuxAdmin::Common).to receive(:run!)
78
- .with(LinuxAdmin::Common.cmd(:pvdisplay),
79
- :params => {'-c' => nil})
80
- .and_return(double(:output => @physical_volumes))
81
- expect(LinuxAdmin::Common).to receive(:run!).and_return(double(:output => @groups)) # stub out call to vgdisplay
82
- described_class.scan
83
- end
84
-
85
- it "returns local physical volumes" do
86
- expect(LinuxAdmin::Common).to receive(:run!).and_return(double(:output => @physical_volumes), double(:output => @groups))
87
- pvs = described_class.scan
88
-
89
- expect(pvs[0]).to be_an_instance_of(described_class)
90
- expect(pvs[0].device_name).to eq('/dev/vda2')
91
- expect(pvs[0].size).to eq(24139776)
92
- end
93
-
94
- it "resolves volume group references" do
95
- expect(LinuxAdmin::Common).to receive(:run!).and_return(double(:output => @physical_volumes), double(:output => @groups))
96
- pvs = described_class.scan
97
- expect(pvs[0].volume_group).to be_an_instance_of(LinuxAdmin::VolumeGroup)
98
- expect(pvs[0].volume_group.name).to eq('vg_foobar')
99
- end
100
- end
101
- end
@@ -1,85 +0,0 @@
1
- describe LinuxAdmin::RegistrationSystem do
2
- context ".registration_type" do
3
- it "when registered Subscription Manager" do
4
- stub_registered_to_system(:sm)
5
- expect(described_class.registration_type).to eq(LinuxAdmin::SubscriptionManager)
6
- end
7
-
8
- it "when registered RHN" do
9
- stub_registered_to_system(:sm, :rhn)
10
- expect(described_class.registration_type).to eq(LinuxAdmin::Rhn)
11
- end
12
-
13
- it "when unregistered" do
14
- stub_registered_to_system(nil)
15
- expect(described_class.registration_type).to eq(described_class)
16
- end
17
-
18
- it "should memoize results" do
19
- expect(described_class).to receive(:registration_type_uncached).once.and_return("anything_non_nil")
20
- described_class.registration_type
21
- described_class.registration_type
22
- end
23
-
24
- it "with reload should refresh results" do
25
- expect(described_class).to receive(:registration_type_uncached).twice.and_return("anything_non_nil")
26
- described_class.registration_type
27
- described_class.registration_type(true)
28
- end
29
- end
30
-
31
- context "#registered?" do
32
- it "when unregistered" do
33
- stub_registered_to_system(nil)
34
- expect(described_class.registered?).to be_falsey
35
- end
36
-
37
- context "SubscriptionManager" do
38
- it "with no args" do
39
- expect(LinuxAdmin::Common).to receive(:run).with("subscription-manager identity").and_return(double(:exit_status => 0))
40
-
41
- LinuxAdmin::SubscriptionManager.new.registered?
42
- end
43
-
44
- it "with a proxy" do
45
- expect(LinuxAdmin::Common).to receive(:run).with(
46
- "subscription-manager identity",
47
- :params => {
48
- "--proxy=" => "https://example.com",
49
- "--proxyuser=" => "user",
50
- "--proxypassword=" => "pass"
51
- }
52
- ).and_return(double(:exit_status => 0))
53
-
54
- LinuxAdmin::SubscriptionManager.new.registered?(
55
- :proxy_address => "https://example.com",
56
- :proxy_username => "user",
57
- :proxy_password => "pass"
58
- )
59
- end
60
- end
61
- end
62
-
63
- context ".method_missing" do
64
- before do
65
- stub_registered_to_system(:rhn)
66
- end
67
-
68
- it "exists on the subclass" do
69
- expect(LinuxAdmin::RegistrationSystem.registered?).to be_truthy
70
- end
71
-
72
- it "does not exist on the subclass" do
73
- expect { LinuxAdmin::RegistrationSystem.organizations }.to raise_error(NotImplementedError)
74
- end
75
-
76
- it "is an unknown method" do
77
- expect { LinuxAdmin::RegistrationSystem.method_does_not_exist }.to raise_error(NoMethodError)
78
- end
79
- end
80
-
81
- def stub_registered_to_system(*system)
82
- allow_any_instance_of(LinuxAdmin::SubscriptionManager).to receive_messages(:registered? => (system.include?(:sm)))
83
- allow_any_instance_of(LinuxAdmin::Rhn).to receive_messages(:registered? => (system.include?(:rhn)))
84
- end
85
- end