vagrant-hypconfigmgmt 0.0.2 → 0.0.3
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/vagrant-hypconfigmgmt/command.rb +72 -0
- data/lib/vagrant-hypconfigmgmt/version.rb +1 -1
- data/pkg/vagrant-hypconfigmgmt-0.0.3.gem +0 -0
- data/spec/unit/command/configure_firewall_spec.rb +37 -0
- data/spec/unit/command/configure_synced_folders_spec.rb +7 -3
- data/spec/unit/command/ensure_firewall_disabled_for_incompatible_fs_types_spec.rb +81 -0
- data/spec/unit/command/ensure_fs_type_configured_spec.rb +47 -0
- data/spec/unit/command/ensure_settings_are_configured_spec.rb +4 -0
- data/spec/unit/command/get_firewall_state_spec.rb +56 -0
- data/spec/unit/command/get_fs_type_spec.rb +97 -0
- metadata +8 -3
- data/pkg/vagrant-hypconfigmgmt-0.0.2.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b27e5b0ad9ed5e0a31db8176cb3c439a2206741e
|
4
|
+
data.tar.gz: 9642e941dae96c39f741a523fa9abf9a566861ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ca8d0dc091ebdf6ca7aeb256052a9ff78adc2f9768b493f7cdf1c465c44d8ba7e5bd3fe43c141516bdbfb051a9d1938a01f80c58f23e24af67f48cd762db428
|
7
|
+
data.tar.gz: 3210f4d40bdb425cb71adc56fdb897e2620b87d40972a58a43698981927dde64847e3426ad480b244e09a06bcbe646c405d75a9f43e23e1c1a71acac1d42b0e6
|
data/README.md
CHANGED
@@ -10,12 +10,24 @@ AVAILABLE_PHP_VERSIONS = [5.5, 7.0]
|
|
10
10
|
DEFAULT_VARNISH_STATE = false
|
11
11
|
AVAILABLE_VARNISH_STATES = [true, false]
|
12
12
|
|
13
|
+
DEFAULT_FIREWALL_STATE = false
|
14
|
+
AVAILABLE_FIREWALL_STATES = [true, false]
|
15
|
+
|
13
16
|
# paths to local settings file
|
14
17
|
H_V_SETTINGS_FILE = "local.yml"
|
15
18
|
H_V_BASE_SETTINGS_FILE = ".local.base.yml"
|
16
19
|
|
17
20
|
RECOMMENDED_PLUGINS = ["vagrant-hostmanager", "vagrant-vbguest"]
|
18
21
|
|
22
|
+
# filesystem types that need to have the firewall disabled in the guest
|
23
|
+
# because they otherwise can cause problems
|
24
|
+
FIREWALL_INCOMPATIBLE_FS_TYPES = ['nfs_guest']
|
25
|
+
|
26
|
+
AVAILABLE_FS_TYPES = ['nfs', 'nfs_guest', 'virtualbox', 'rsync']
|
27
|
+
# This is the only one that works on all platforms.
|
28
|
+
# Perhaps we should consider using a different default on different platforms.
|
29
|
+
DEFAULT_FS_TYPE = 'virtualbox'
|
30
|
+
|
19
31
|
|
20
32
|
module VagrantHypconfigmgmt
|
21
33
|
class Command
|
@@ -112,8 +124,38 @@ module VagrantHypconfigmgmt
|
|
112
124
|
env[:ui].info(message)
|
113
125
|
return varnish_state
|
114
126
|
end
|
127
|
+
|
128
|
+
|
129
|
+
def get_firewall_state(env)
|
130
|
+
ask_message = "Do you want to enable the production-like firewall? Enter true or false [default false]: "
|
131
|
+
firewall_enabled = get_setting(env, AVAILABLE_FIREWALL_STATES, DEFAULT_FIREWALL_STATE, ask_message)
|
132
|
+
firewall_state = firewall_enabled == 'true' ? true : false
|
133
|
+
message = "The firewall will be #{firewall_state ? 'enabled' : 'disabled'}"
|
134
|
+
env[:ui].info(message)
|
135
|
+
return firewall_state
|
136
|
+
end
|
115
137
|
|
116
138
|
|
139
|
+
def get_fs_type(env)
|
140
|
+
ask_message = "What filesystem type do you want to use? Options: nfs_guest, nfs, rsync, virtualbox [default #{DEFAULT_FS_TYPE}]: "
|
141
|
+
fs_type = get_setting(env, AVAILABLE_FS_TYPES, DEFAULT_FS_TYPE, ask_message)
|
142
|
+
case fs_type
|
143
|
+
when "nfs"
|
144
|
+
message = ("The guest will mount NFS folders served by the host.")
|
145
|
+
when "nfs_guest"
|
146
|
+
message = ("The host will mount NFS folders served by the guest")
|
147
|
+
when "virtualbox"
|
148
|
+
message = ("Virtualbox is the default fs type. If you later want to try a faster fs type like nfs_guest, edit local.yml")
|
149
|
+
when "rsync"
|
150
|
+
message = ("Will use rsync to sync the folders. Don't forget to start the filesync with 'vagrant rsync-auto' or 'vagrant gatling-rsync-auto'!")
|
151
|
+
else
|
152
|
+
message = ("Unknown filesystem type. If it's valid for Vagrant then there is no problem. Otherwise you can edit local.yml to change it.")
|
153
|
+
end
|
154
|
+
env[:ui].info(message)
|
155
|
+
return fs_type
|
156
|
+
end
|
157
|
+
|
158
|
+
|
117
159
|
# Make sure we don't link /data/web/public on Magento 2 Vagrants
|
118
160
|
# because that dir will be a symlink to /data/web/magento2/pub and
|
119
161
|
# we mount that. On Magento 1 Vagrants we need to make sure we don't
|
@@ -210,8 +252,25 @@ HEREDOC
|
|
210
252
|
end
|
211
253
|
update_settings(settings)
|
212
254
|
end
|
255
|
+
|
213
256
|
|
257
|
+
def ensure_firewall_disabled_for_incompatible_fs_types(env)
|
258
|
+
settings = retrieve_settings()
|
259
|
+
if FIREWALL_INCOMPATIBLE_FS_TYPES.include?(settings['fs']['type'])
|
260
|
+
env[:ui].info("Disabling the firewall in the guest because fs type #{settings['fs']['type']} might run into some problems otherwise.")
|
261
|
+
settings['firewall']['state'] = false
|
262
|
+
end
|
263
|
+
update_settings(settings)
|
264
|
+
end
|
265
|
+
|
214
266
|
|
267
|
+
def ensure_fs_type_configured(env)
|
268
|
+
settings = retrieve_settings()
|
269
|
+
settings['fs']['type'] ||= get_fs_type(env)
|
270
|
+
update_settings(settings)
|
271
|
+
end
|
272
|
+
|
273
|
+
|
215
274
|
def configure_magento(env)
|
216
275
|
ensure_setting_exists('magento')
|
217
276
|
ensure_attribute_configured(
|
@@ -237,9 +296,21 @@ HEREDOC
|
|
237
296
|
AVAILABLE_VARNISH_STATES
|
238
297
|
) { get_varnish_state(env) }
|
239
298
|
end
|
299
|
+
|
300
|
+
|
301
|
+
def configure_firewall(env)
|
302
|
+
ensure_setting_exists('firewall')
|
303
|
+
ensure_firewall_disabled_for_incompatible_fs_types(env)
|
304
|
+
ensure_attribute_configured(
|
305
|
+
env, 'firewall', 'state',
|
306
|
+
AVAILABLE_FIREWALL_STATES
|
307
|
+
) { get_firewall_state(env) }
|
308
|
+
end
|
240
309
|
|
241
310
|
|
242
311
|
def configure_synced_folders(env)
|
312
|
+
ensure_setting_exists('fs')
|
313
|
+
ensure_fs_type_configured(env)
|
243
314
|
ensure_magento_mounts_configured(env)
|
244
315
|
validate_magento2_root(env)
|
245
316
|
inform_if_gatling_not_installed(env)
|
@@ -258,6 +329,7 @@ HEREDOC
|
|
258
329
|
configure_php(env)
|
259
330
|
configure_varnish(env)
|
260
331
|
configure_synced_folders(env)
|
332
|
+
configure_firewall(env)
|
261
333
|
configure_vagrant(env)
|
262
334
|
new_settings = retrieve_settings()
|
263
335
|
return new_settings.to_yaml != old_settings.to_yaml
|
Binary file
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
13
|
+
after do
|
14
|
+
subject.configure_firewall(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
# instantiate class of which a method is to be tested
|
18
|
+
subject { described_class.new(app, env) }
|
19
|
+
|
20
|
+
# the method that we are going to test
|
21
|
+
describe "#configure_firewall" do
|
22
|
+
|
23
|
+
context "when env is passed" do
|
24
|
+
it "configures the settings for firewall" do
|
25
|
+
# check the firewall settings is ensured to exist in the configuration file
|
26
|
+
expect(subject).to receive(:ensure_setting_exists).with('firewall')
|
27
|
+
# check the firewall is disabled for incompatible fs types
|
28
|
+
expect(subject).to receive(:ensure_firewall_disabled_for_incompatible_fs_types).with(env)
|
29
|
+
# check the firewall state is ensured to be configured
|
30
|
+
expect(subject).to receive(:ensure_attribute_configured).with(
|
31
|
+
env, 'firewall', 'state', AVAILABLE_FIREWALL_STATES
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -22,12 +22,16 @@ describe VagrantHypconfigmgmt::Command do
|
|
22
22
|
|
23
23
|
context "when env is passed" do
|
24
24
|
it "configures all the settings for the synced folders" do
|
25
|
+
# check if the fs settings is ensured to exist
|
26
|
+
expect(subject).to receive(:ensure_setting_exists).once.with('fs')
|
27
|
+
# check if fs type is configured
|
28
|
+
expect(subject).to receive(:ensure_fs_type_configured).once.with(env)
|
25
29
|
# check the magento mounts are configured
|
26
|
-
expect(subject).to receive(:ensure_magento_mounts_configured).with(env)
|
30
|
+
expect(subject).to receive(:ensure_magento_mounts_configured).once.with(env)
|
27
31
|
# check the directory to be mounted is validated against the magento version (pub symlink vs public)
|
28
|
-
expect(subject).to receive(:validate_magento2_root).with(env)
|
32
|
+
expect(subject).to receive(:validate_magento2_root).once.with(env)
|
29
33
|
# check a message will be printed if gatling is not installed while the rsync fs type is specified
|
30
|
-
expect(subject).to receive(:inform_if_gatling_not_installed).with(env)
|
34
|
+
expect(subject).to receive(:inform_if_gatling_not_installed).once.with(env)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
|
8
|
+
describe VagrantHypconfigmgmt::Command do
|
9
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
10
|
+
let(:app) { }
|
11
|
+
let(:env) { { :ui => ui } }
|
12
|
+
let(:setting_name) { get_random_string() }
|
13
|
+
|
14
|
+
# pretend env contains the Vagrant ui element
|
15
|
+
let(:ui) do
|
16
|
+
double('ui').tap do |ui|
|
17
|
+
allow(ui).to receive(:info) { nil }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
22
|
+
after do
|
23
|
+
subject.ensure_firewall_disabled_for_incompatible_fs_types(env)
|
24
|
+
end
|
25
|
+
|
26
|
+
# instantiate class of which a method is to be tested
|
27
|
+
subject { described_class.new(app, env) }
|
28
|
+
|
29
|
+
# the method that we are going to test
|
30
|
+
describe "#ensure_firewall_disabled_for_incompatible_fs_types" do
|
31
|
+
context "when current fs type is compatible with the firewall and the firewall state was already defined" do
|
32
|
+
let(:retrieved_settings) { { "fs" => { "type" => "virtualbox" }, "firewall" => { "state" => true } } }
|
33
|
+
it "leaves the firewall enabled" do
|
34
|
+
# pretend the settings are retrieved from disk and return a fs type that does not clash with the firewall
|
35
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
36
|
+
# check if we do not notify the user that the firewall will be disabled
|
37
|
+
expect(ui).to receive(:info).never.with(/Disabling the firewall.*/)
|
38
|
+
# check if the firewall is still enabled
|
39
|
+
expect(subject).to receive(:update_settings).once.with(retrieved_settings)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "when current fs type is compatible with the firewall and the firewall state was not yet defined" do
|
44
|
+
let(:retrieved_settings) { { "fs" => { "type" => "virtualbox" }, "firewall" => { } } }
|
45
|
+
it "does not changes the settings" do
|
46
|
+
# pretend the settings are retrieved from disk and return a fs type that does not clash with the firewall
|
47
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
48
|
+
# check if we do not notify the user that the firewall will be disabled
|
49
|
+
expect(ui).to receive(:info).never.with(/Disabling the firewall.*/)
|
50
|
+
# check if the settings are not changed
|
51
|
+
expect(subject).to receive(:update_settings).once.with(retrieved_settings)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when current fs type is not compatible with the firewall and the firewall state was already defined" do
|
56
|
+
let(:retrieved_settings) { { "fs" => { "type" => "nfs_guest" }, "firewall" => { "state" => true } } }
|
57
|
+
let(:expected_settings) { { "fs" => { "type" => "nfs_guest" }, "firewall" => { "state" => false } } }
|
58
|
+
it "changes the existing firewall state to disabled" do
|
59
|
+
# pretend the settings are retrieved from disk and return an incompatible fs type
|
60
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
61
|
+
# check if we notify the user that the firewall will be disabled
|
62
|
+
expect(ui).to receive(:info).once.with(/Disabling the firewall.*/)
|
63
|
+
# check if the firewall is disabled
|
64
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when current fs type is not compatible with the firewall and the firewall state was not defined" do
|
69
|
+
let(:retrieved_settings) { { "fs" => { "type" => "nfs_guest" }, "firewall" => { } } }
|
70
|
+
let(:expected_settings) { { "fs" => { "type" => "nfs_guest" }, "firewall" => { "state" => false } } }
|
71
|
+
it "creates a new firewall state disabled" do
|
72
|
+
# pretend the settings are retrieved from disk and return an incompatible fs type
|
73
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
74
|
+
# check if we notify the user that the firewall will be disabled
|
75
|
+
expect(ui).to receive(:info).once.with(/Disabling the firewall.*/)
|
76
|
+
# check if the firewall is disabled
|
77
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
13
|
+
after do
|
14
|
+
subject.ensure_fs_type_configured(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
# instantiate class of which a method is to be tested
|
18
|
+
subject { described_class.new(app, env) }
|
19
|
+
|
20
|
+
# the method that we are going to test
|
21
|
+
describe "#ensure_fs_type_configured" do
|
22
|
+
context "fs type is configured" do
|
23
|
+
let(:retrieved_settings) { { "fs" => { "type" => "virtualbox"} } }
|
24
|
+
it "configures the fs type" do
|
25
|
+
# pretend we retrieve the settings and they specify no fs type
|
26
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
27
|
+
# check if the fs type is not gotten because we already have it specified in the settings
|
28
|
+
expect(subject).to receive(:get_fs_type).never
|
29
|
+
# check if the settings are unchanged
|
30
|
+
expect(subject).to receive(:update_settings).once.with(retrieved_settings)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "fs type is not configured" do
|
35
|
+
let(:retrieved_settings) { { "fs" => { } } }
|
36
|
+
let(:expected_settings) { { "fs" => { "type" => "rsync" }} }
|
37
|
+
it "configures the fs type" do
|
38
|
+
# pretend we retrieve the settings and they specify no fs type
|
39
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
40
|
+
# check if the fs type is gotten and pretend it returns rsync
|
41
|
+
expect(subject).to receive(:get_fs_type).once.with(env).and_return('rsync')
|
42
|
+
# check if the settings that are written back to disk contain the new fs type
|
43
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -41,6 +41,8 @@ describe VagrantHypconfigmgmt::Command do
|
|
41
41
|
expect(subject).to receive(:configure_varnish).with(env)
|
42
42
|
# check the synced folder settings are configured
|
43
43
|
expect(subject).to receive(:configure_synced_folders).with(env)
|
44
|
+
# check the firewall settings are configured
|
45
|
+
expect(subject).to receive(:configure_firewall).with(env)
|
44
46
|
# check the vagrant settings are configured
|
45
47
|
expect(subject).to receive(:configure_vagrant).with(env)
|
46
48
|
# check true is returned when settings are updated
|
@@ -60,6 +62,8 @@ describe VagrantHypconfigmgmt::Command do
|
|
60
62
|
expect(subject).to receive(:configure_varnish).with(env)
|
61
63
|
# check the synced folder settings are configured
|
62
64
|
expect(subject).to receive(:configure_synced_folders).with(env)
|
65
|
+
# check the firewall settings are configured
|
66
|
+
expect(subject).to receive(:configure_firewall).with(env)
|
63
67
|
# check the vagrant settings are configured
|
64
68
|
expect(subject).to receive(:configure_vagrant).with(env)
|
65
69
|
# check false is returned when settings are not updated
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { { :ui => ui } }
|
11
|
+
|
12
|
+
# pretend env contains the Vagrant ui element
|
13
|
+
let(:ui) do
|
14
|
+
double('ui').tap do |ui|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# instantiate class of which a method is to be tested
|
21
|
+
subject { described_class.new(app, env) }
|
22
|
+
|
23
|
+
# the method that we are going to test
|
24
|
+
describe "#get_firewall_state" do
|
25
|
+
|
26
|
+
context "when the state is enabled" do
|
27
|
+
it "it notifies the user that it will be enabled and returns the value" do
|
28
|
+
# check if the setting is prompted for and pretend it returns a "firewall enabled" answer
|
29
|
+
expect(subject).to receive(:get_setting).with(
|
30
|
+
env, AVAILABLE_FIREWALL_STATES, DEFAULT_FIREWALL_STATE,
|
31
|
+
"Do you want to enable the production-like firewall? Enter true or false [default false]: "
|
32
|
+
).and_return("true")
|
33
|
+
# check if the user is notified that the firewall will be enabled
|
34
|
+
expect(ui).to receive(:info).once.with(/.*enabled.*/)
|
35
|
+
# check if the function returns true if the firewall should be enabled
|
36
|
+
expect( subject.get_firewall_state(env) ).to eq(true)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
context "when the state is disabled" do
|
42
|
+
it "it notifies the user that it will be disabled and returns the value" do
|
43
|
+
# check if the setting is prompted for and pretend it returns a "firewall disabled" answer
|
44
|
+
expect(subject).to receive(:get_setting).with(
|
45
|
+
env, AVAILABLE_FIREWALL_STATES, DEFAULT_FIREWALL_STATE,
|
46
|
+
"Do you want to enable the production-like firewall? Enter true or false [default false]: "
|
47
|
+
).and_return("false")
|
48
|
+
# check if the user is notified that the firewall will be disabled
|
49
|
+
expect(ui).to receive(:info).once.with(/.*disabled.*/)
|
50
|
+
# check if the function returns false if the firewall should be disabled
|
51
|
+
expect( subject.get_firewall_state(env) ).to eq(false)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { { :ui => ui } }
|
11
|
+
|
12
|
+
# pretend env contains the Vagrant ui element
|
13
|
+
let(:ui) do
|
14
|
+
double('ui').tap do |ui|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# instantiate class of which a method is to be tested
|
21
|
+
subject { described_class.new(app, env) }
|
22
|
+
|
23
|
+
# the method that we are going to test
|
24
|
+
describe "#fs_type" do
|
25
|
+
|
26
|
+
context "when the user inputs an unknown fs type" do
|
27
|
+
it "returns fs type unknown" do
|
28
|
+
# check if the setting is prompted for and pretend it returns an "rsync" answer
|
29
|
+
expect(subject).to receive(:get_setting).with(
|
30
|
+
env, AVAILABLE_FS_TYPES, DEFAULT_FS_TYPE,
|
31
|
+
"What filesystem type do you want to use? Options: nfs_guest, nfs, rsync, virtualbox [default #{DEFAULT_FS_TYPE}]: "
|
32
|
+
).and_return("unknown_fs_type")
|
33
|
+
# check a message is printed about the fs type
|
34
|
+
expect(ui).to receive(:info).once.with(/.*Unknown.*/)
|
35
|
+
# check if the function returns the unknown fs type
|
36
|
+
expect( subject.get_fs_type(env) ).to eq("unknown_fs_type")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when the user inputs fs type rsync" do
|
41
|
+
it "returns fs type rsync" do
|
42
|
+
# check if the setting is prompted for and pretend it returns an "rsync" answer
|
43
|
+
expect(subject).to receive(:get_setting).with(
|
44
|
+
env, AVAILABLE_FS_TYPES, DEFAULT_FS_TYPE,
|
45
|
+
"What filesystem type do you want to use? Options: nfs_guest, nfs, rsync, virtualbox [default #{DEFAULT_FS_TYPE}]: "
|
46
|
+
).and_return("rsync")
|
47
|
+
# check a message is printed about the fs type
|
48
|
+
expect(ui).to receive(:info).once.with(/.*rsync.*filesync.*/)
|
49
|
+
# check if the function returns "rsync"
|
50
|
+
expect( subject.get_fs_type(env) ).to eq("rsync")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when the user inputs fs type virtualbox" do
|
55
|
+
it "returns fs type virtualbox" do
|
56
|
+
# check if the setting is prompted for and pretend it returns a "virtualbox" answer
|
57
|
+
expect(subject).to receive(:get_setting).with(
|
58
|
+
env, AVAILABLE_FS_TYPES, DEFAULT_FS_TYPE,
|
59
|
+
"What filesystem type do you want to use? Options: nfs_guest, nfs, rsync, virtualbox [default #{DEFAULT_FS_TYPE}]: "
|
60
|
+
).and_return("virtualbox")
|
61
|
+
# check a message is printed about the fs type
|
62
|
+
expect(ui).to receive(:info).once.with(/.*is the default.*/)
|
63
|
+
# check if the function returns "virtualbox"
|
64
|
+
expect( subject.get_fs_type(env) ).to eq("virtualbox")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when the user inputs fs type nfs_guest" do
|
69
|
+
it "returns fs type nfs_guest" do
|
70
|
+
# check if the setting is prompted for and pretend it returns an "nfs_guest" answer
|
71
|
+
expect(subject).to receive(:get_setting).with(
|
72
|
+
env, AVAILABLE_FS_TYPES, DEFAULT_FS_TYPE,
|
73
|
+
"What filesystem type do you want to use? Options: nfs_guest, nfs, rsync, virtualbox [default #{DEFAULT_FS_TYPE}]: "
|
74
|
+
).and_return("nfs_guest")
|
75
|
+
# check a message is printed about the fs type
|
76
|
+
expect(ui).to receive(:info).once.with(/.*host will mount NFS.*/)
|
77
|
+
# check if the function returns "nfs_guest"
|
78
|
+
expect( subject.get_fs_type(env) ).to eq("nfs_guest")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "when the user inputs fs type nfs" do
|
83
|
+
it "returns fs type nfs" do
|
84
|
+
# check if the setting is prompted for and pretend it returns an "nfs" answer
|
85
|
+
expect(subject).to receive(:get_setting).with(
|
86
|
+
env, AVAILABLE_FS_TYPES, DEFAULT_FS_TYPE,
|
87
|
+
"What filesystem type do you want to use? Options: nfs_guest, nfs, rsync, virtualbox [default #{DEFAULT_FS_TYPE}]: "
|
88
|
+
).and_return("nfs")
|
89
|
+
# check a message is printed about the fs type
|
90
|
+
expect(ui).to receive(:info).once.with(/.*guest will mount NFS.*/)
|
91
|
+
# check if the function returns "nfs"
|
92
|
+
expect( subject.get_fs_type(env) ).to eq("nfs")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-hypconfigmgmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick van de Loo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,20 +99,25 @@ files:
|
|
99
99
|
- lib/vagrant-hypconfigmgmt/command.rb
|
100
100
|
- lib/vagrant-hypconfigmgmt/config.rb
|
101
101
|
- lib/vagrant-hypconfigmgmt/version.rb
|
102
|
-
- pkg/vagrant-hypconfigmgmt-0.0.
|
102
|
+
- pkg/vagrant-hypconfigmgmt-0.0.3.gem
|
103
103
|
- spec/spec_helper.rb
|
104
104
|
- spec/unit/command/call_spec.rb
|
105
|
+
- spec/unit/command/configure_firewall_spec.rb
|
105
106
|
- spec/unit/command/configure_magento_spec.rb
|
106
107
|
- spec/unit/command/configure_php_spec.rb
|
107
108
|
- spec/unit/command/configure_synced_folders_spec.rb
|
108
109
|
- spec/unit/command/configure_vagrant_spec.rb
|
109
110
|
- spec/unit/command/configure_varnish_spec.rb
|
110
111
|
- spec/unit/command/ensure_attribute_configured_spec.rb
|
112
|
+
- spec/unit/command/ensure_firewall_disabled_for_incompatible_fs_types_spec.rb
|
113
|
+
- spec/unit/command/ensure_fs_type_configured_spec.rb
|
111
114
|
- spec/unit/command/ensure_magento_mounts_configured_spec.rb
|
112
115
|
- spec/unit/command/ensure_required_plugins_are_installed_spec.rb
|
113
116
|
- spec/unit/command/ensure_setting_exists_spec.rb
|
114
117
|
- spec/unit/command/ensure_settings_are_configured_spec.rb
|
115
118
|
- spec/unit/command/ensure_vagrant_box_type_configured_spec.rb
|
119
|
+
- spec/unit/command/get_firewall_state_spec.rb
|
120
|
+
- spec/unit/command/get_fs_type_spec.rb
|
116
121
|
- spec/unit/command/get_magento_version_spec.rb
|
117
122
|
- spec/unit/command/get_options_string_spec.rb
|
118
123
|
- spec/unit/command/get_php_version_spec.rb
|
Binary file
|