vagrant-proxyconf 2.0.4 → 2.0.10

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.
Files changed (52) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +12 -7
  3. data/CHANGELOG.md +155 -0
  4. data/Gemfile +1 -18
  5. data/Jenkinsfile +60 -0
  6. data/Makefile +33 -0
  7. data/README.md +22 -0
  8. data/deps/patches/lib/vagrant/bundler.rb.patch +14 -0
  9. data/jenkins/helper_functions +206 -0
  10. data/lib/vagrant-proxyconf/action/base.rb +20 -9
  11. data/lib/vagrant-proxyconf/action/configure_docker_proxy.rb +21 -23
  12. data/lib/vagrant-proxyconf/config/apt_proxy.rb +21 -2
  13. data/lib/vagrant-proxyconf/version.rb +1 -1
  14. data/spec/unit/support/shared/apt_proxy_config.rb +12 -0
  15. data/spec/unit/vagrant-proxyconf/action/configure_docker_proxy_spec.rb +44 -37
  16. data/spec/unit/vagrant-proxyconf/action/configure_svn_proxy_spec.rb +1 -0
  17. data/test/issues/172/README.md +2 -2
  18. data/test/issues/172/spec/docker_host/redhat_spec.rb +2 -2
  19. data/test/issues/180/spec/docker_host/redhat_spec.rb +2 -2
  20. data/test/issues/192/.rspec +2 -0
  21. data/test/issues/192/Dockerfile +47 -0
  22. data/test/issues/192/Dockerfile.bionic +40 -0
  23. data/test/issues/192/README.md +29 -0
  24. data/test/issues/192/Rakefile +27 -0
  25. data/test/issues/192/Vagrantfile +64 -0
  26. data/test/issues/192/entrypoint.sh +50 -0
  27. data/test/issues/192/spec/default/redhat_spec.rb +15 -0
  28. data/test/issues/192/spec/docker_host/ubuntu_spec.rb +3 -0
  29. data/test/issues/192/spec/spec_helper.rb +52 -0
  30. data/test/issues/192/tinyproxy.conf +333 -0
  31. data/test/issues/199/.rspec +2 -0
  32. data/test/issues/199/Dockerfile +47 -0
  33. data/test/issues/199/README.md +31 -0
  34. data/test/issues/199/Rakefile +27 -0
  35. data/test/issues/199/Vagrantfile +74 -0
  36. data/test/issues/199/entrypoint.sh +50 -0
  37. data/test/issues/199/spec/apt_host/ubuntu_spec.rb +135 -0
  38. data/test/issues/199/spec/default/redhat_spec.rb +15 -0
  39. data/test/issues/199/spec/spec_helper.rb +52 -0
  40. data/test/issues/199/tinyproxy.conf +333 -0
  41. data/test/issues/218/.rspec +2 -0
  42. data/test/issues/218/Dockerfile +47 -0
  43. data/test/issues/218/README.md +35 -0
  44. data/test/issues/218/Rakefile +27 -0
  45. data/test/issues/218/Vagrantfile +62 -0
  46. data/test/issues/218/entrypoint.sh +50 -0
  47. data/test/issues/218/force-all-outbound-traffic-through-proxy.iptables +18 -0
  48. data/test/issues/218/spec/default/redhat_spec.rb +16 -0
  49. data/test/issues/218/spec/docker_host/redhat_spec.rb +171 -0
  50. data/test/issues/218/spec/spec_helper.rb +43 -0
  51. data/test/issues/218/tinyproxy.conf +333 -0
  52. metadata +71 -4
@@ -87,13 +87,17 @@ module VagrantPlugins
87
87
  local_tmp = tempfile(config)
88
88
 
89
89
  logger.debug "Configuration (#{path}):\n#{config}"
90
+
90
91
  @machine.communicate.tap do |comm|
91
- comm.sudo("rm -f #{tmp}", error_check: false)
92
92
  comm.upload(local_tmp.path, tmp)
93
- comm.sudo("chmod #{opts[:mode] || '0644'} #{tmp}")
94
- comm.sudo("chown #{opts[:owner] || 'root:root'} #{tmp}")
95
- comm.sudo("mkdir -p #{File.dirname(path)}")
96
- comm.sudo("mv -f #{tmp} #{path}")
93
+ if comm.test("command -v sudo")
94
+ comm.sudo("chmod #{opts[:mode] || '0644'} #{tmp}")
95
+ comm.sudo("chown #{opts[:owner] || 'root:root'} #{tmp}")
96
+ comm.sudo("mkdir -p #{File.dirname(path)}")
97
+ comm.sudo("mv -f #{tmp} #{path}")
98
+ else
99
+ raise Vagrant::Errors::CommandUnavailable.new(file: "sudo")
100
+ end
97
101
  end
98
102
  end
99
103
 
@@ -104,11 +108,18 @@ module VagrantPlugins
104
108
 
105
109
  # @return [Tempfile] a temporary file with the specified content
106
110
  def tempfile(content)
107
- Tempfile.new("vagrant").tap do |temp|
108
- temp.binmode
109
- temp.write(content)
110
- temp.close
111
+ tempfile = Tempfile.new("vagrant-proxyconf")
112
+
113
+ begin
114
+ tempfile.tap do |tmp|
115
+ tmp.binmode
116
+ tmp.write(content)
117
+ end
118
+ ensure
119
+ tempfile.close
111
120
  end
121
+
122
+ tempfile
112
123
  end
113
124
 
114
125
  def cap_name
@@ -39,28 +39,28 @@ module VagrantPlugins
39
39
  true
40
40
  end
41
41
 
42
- def docker_client_config_path
43
- return @docker_client_config_path if @docker_client_config_path
42
+ def docker_client_config
43
+ return @docker_client_config if @docker_client_config
44
44
  return if !supports_config_json?
45
45
 
46
- @docker_client_config_path = tempfile(Hash.new)
46
+ @docker_client_config = tempfile(Hash.new)
47
47
 
48
48
  @machine.communicate.tap do |comm|
49
- if comm.test("[ -f /etc/docker/config.json ]")
50
- logger.info('Downloading file /etc/docker/config.json')
51
- comm.sudo("chmod 0644 /etc/docker/config.json")
52
- comm.download("/etc/docker/config.json", @docker_client_config_path.path)
53
- logger.info("Downloaded /etc/docker/config.json to #{@docker_client_config_path.path}")
49
+ if comm.test("[ -f /home/vagrant/.docker/config.json ]")
50
+ logger.info('Downloading file /home/vagrant/.docker/config.json')
51
+ comm.sudo("chmod 0644 /home/vagrant/.docker/config.json")
52
+ comm.download("/home/vagrant/.docker/config.json", @docker_client_config.path)
53
+ logger.info("Downloaded /home/vagrant/.docker/config.json to #{@docker_client_config.path}")
54
54
  end
55
55
  end
56
56
 
57
- @docker_client_config_path = @docker_client_config_path.path
57
+ @docker_client_config
58
58
  end
59
59
 
60
60
  def update_docker_client_config
61
- return if !supports_config_json? || !docker_client_config_path
61
+ return if !supports_config_json? || !docker_client_config
62
62
 
63
- content = File.read(@docker_client_config_path)
63
+ content = File.read(@docker_client_config)
64
64
  data = JSON.load(content)
65
65
 
66
66
  if disabled?
@@ -92,20 +92,17 @@ module VagrantPlugins
92
92
 
93
93
  config_json = JSON.pretty_generate(data)
94
94
 
95
- @docker_client_config_path = tempfile(config_json)
95
+ @docker_client_config = tempfile(config_json)
96
96
 
97
97
  @machine.communicate.tap do |comm|
98
- comm.upload(@docker_client_config_path.path, "/tmp/vagrant-proxyconf-docker-config.json")
99
- comm.sudo("mkdir -p /etc/docker")
100
- comm.sudo("chown root:root /etc/docker")
101
- comm.sudo("mv /tmp/vagrant-proxyconf-docker-config.json /etc/docker/config.json")
102
- comm.sudo("chown root:root /etc/docker/config.json")
98
+ comm.upload(@docker_client_config.path, "/tmp/vagrant-proxyconf-docker-config.json")
99
+ comm.sudo("mkdir -p /home/vagrant/.docker")
100
+ comm.sudo("mv /tmp/vagrant-proxyconf-docker-config.json /home/vagrant/.docker/config.json")
101
+ comm.sudo("chown -R vagrant:docker /home/vagrant/.docker")
102
+ comm.sudo("chmod 0644 /home/vagrant/.docker/config.json")
103
103
  comm.sudo("rm -f /tmp/vagrant-proxyconf-docker-config.json")
104
104
 
105
105
  comm.sudo("sed -i.bak -e '/^DOCKER_CONFIG/d' /etc/environment")
106
- if !disabled?
107
- comm.sudo("echo DOCKER_CONFIG=/etc/docker >> /etc/environment")
108
- end
109
106
  end
110
107
 
111
108
  config_json
@@ -135,12 +132,12 @@ module VagrantPlugins
135
132
  end
136
133
 
137
134
  systemd_config = docker_systemd_config
138
- @docker_systemd_config = tempfile(systemd_config).path
135
+ @docker_systemd_config = tempfile(systemd_config)
139
136
 
140
137
  @machine.communicate.tap do |comm|
141
138
 
142
139
  comm.sudo("mkdir -p /etc/systemd/system/docker.service.d")
143
- comm.upload(@docker_systemd_config, "/tmp/vagrant-proxyconf-docker-systemd-config")
140
+ comm.upload(@docker_systemd_config.path, "/tmp/vagrant-proxyconf-docker-systemd-config")
144
141
 
145
142
  if comm.test("diff -Naur /etc/systemd/system/docker.service.d/http-proxy.conf /tmp/vagrant-proxyconf-docker-systemd-config")
146
143
  # system config file is the same as the current config
@@ -154,6 +151,7 @@ module VagrantPlugins
154
151
  end
155
152
 
156
153
  comm.sudo('chown -R 0:0 /etc/systemd/system/docker.service.d/')
154
+ comm.sudo('touch /etc/systemd/system/docker.service.d/http-proxy.conf')
157
155
  comm.sudo('chmod 0644 /etc/systemd/system/docker.service.d/http-proxy.conf')
158
156
 
159
157
  if changed
@@ -235,7 +233,7 @@ module VagrantPlugins
235
233
 
236
234
  # update config and restart docker when config changed
237
235
  comm.sudo("chmod 0644 #{path}.new")
238
- comm.sudo("chown root:root #{path}.new")
236
+ comm.sudo("chown root:docker #{path}.new")
239
237
  comm.sudo("mv -f #{path}.new #{path}")
240
238
  comm.sudo(service_restart_command)
241
239
  end
@@ -20,6 +20,12 @@ module VagrantPlugins
20
20
  # @return [String] the FTP proxy
21
21
  key :ftp, env_var: 'VAGRANT_APT_FTP_PROXY'
22
22
 
23
+ # @return [String] whether APT should verify peer certificate
24
+ key :verify_peer, env_var: 'VAGRANT_APT_VERIFY_PEER'
25
+
26
+ # @return [String] whether APT should verify that certificate name matches server name
27
+ key :verify_host, env_var: 'VAGRANT_APT_VERIFY_HOST'
28
+
23
29
  def finalize!
24
30
  super
25
31
 
@@ -33,7 +39,15 @@ module VagrantPlugins
33
39
 
34
40
  # (see KeyMixin#config_for)
35
41
  def config_for(key, value)
36
- %Q{Acquire::#{key.name}::Proxy #{value.inspect};\n} if value
42
+ if value
43
+ if key.name == :verify_host
44
+ %Q{Acquire::https::Verify-Host #{value.inspect};\n}
45
+ elsif key.name == :verify_peer
46
+ %Q{Acquire::https::Verify-Peer #{value.inspect};\n}
47
+ else
48
+ %Q{Acquire::#{key.name}::Proxy #{value.inspect};\n}
49
+ end
50
+ end
37
51
  end
38
52
 
39
53
  def finalize_uri(key, value)
@@ -55,7 +69,8 @@ module VagrantPlugins
55
69
  end
56
70
 
57
71
  def to_s
58
- direct || "#{prefix}#{value}#{suffix}"
72
+ # direct || "#{prefix}#{value}#{suffix}"
73
+ direct || verify || "#{prefix}#{value}#{suffix}"
59
74
  end
60
75
 
61
76
  private
@@ -64,6 +79,10 @@ module VagrantPlugins
64
79
  'DIRECT' if value.upcase == 'DIRECT'
65
80
  end
66
81
 
82
+ def verify
83
+ value if ["true", "false"].to_set.include? value
84
+ end
85
+
67
86
  # Hash of deprecation warning sentinels
68
87
  @@warned = {}
69
88
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProxyConf
3
- VERSION = '2.0.4'
3
+ VERSION = '2.0.10'
4
4
  end
5
5
  end
@@ -8,6 +8,10 @@ end
8
8
  def conf_line(proto, name, port = 3142)
9
9
  if name == :direct
10
10
  %Q{Acquire::#{proto}::Proxy "DIRECT";\n}
11
+ elsif proto == :verify_peer
12
+ %Q{Acquire::https::Verify-Peer "#{name}";\n}
13
+ elsif proto == :verify_host
14
+ %Q{Acquire::https::Verify-Host "#{name}";\n}
11
15
  else
12
16
  port = ":#{port}" if port
13
17
  %Q{Acquire::#{proto}::Proxy "#{proto}://#{name}#{port}";\n}
@@ -65,6 +69,14 @@ shared_examples "apt proxy config" do |proto|
65
69
  end
66
70
  end
67
71
 
72
+ [:verify_peer, :verify_host].each do |verify|
73
+ context "with #{verify.inspect}" do
74
+ subject { config_with(verify => "false") }
75
+ its(:enabled?) { should be_truthy }
76
+ its(:to_s) { should eq conf_line(verify, "false") }
77
+ end
78
+ end
79
+
68
80
  [false, ""].each do |unset|
69
81
  context "with #{unset.inspect}" do
70
82
  subject { config_with(proto => unset) }
@@ -10,7 +10,7 @@ def mock_write_docker_config(machine)
10
10
  allow(machine).to receive_message_chain(:communicate, :sudo).with("cat /tmp/vagrant-proxyconf >> /etc/default/docker.new")
11
11
  allow(machine).to receive_message_chain(:communicate, :test).with("diff /etc/default/docker.new /etc/default/docker")
12
12
  allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /etc/default/docker.new")
13
- allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:root /etc/default/docker.new")
13
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:docker /etc/default/docker.new")
14
14
  allow(machine).to receive_message_chain(:communicate, :sudo).with("mv -f /etc/default/docker.new /etc/default/docker")
15
15
  allow(machine).to receive_message_chain(:communicate, :sudo).with("kill -HUP `pgrep -f 'docker'` || systemctl restart docker || service docker restart || /etc/init.d/docker restart")
16
16
  allow(machine).to receive_message_chain(:communicate, :sudo).with("rm -f /tmp/vagrant-proxyconf /etc/default/docker.new")
@@ -18,13 +18,13 @@ end
18
18
 
19
19
  def mock_update_docker_client_config(machine)
20
20
  allow(machine).to receive_message_chain(:communicate, :upload)
21
- allow(machine).to receive_message_chain(:communicate, :sudo).with("mv /tmp/vagrant-proxyconf-docker-config.json /etc/docker/config.json")
22
- allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:root /etc/docker/config.json")
21
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("mkdir -p /home/vagrant/.docker")
22
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("mv /tmp/vagrant-proxyconf-docker-config.json /home/vagrant/.docker/config.json")
23
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("chown -R vagrant:docker /home/vagrant/.docker")
24
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /home/vagrant/.docker/config.json")
23
25
  allow(machine).to receive_message_chain(:communicate, :sudo).with("rm -f /tmp/vagrant-proxyconf-docker-config.json")
24
26
  allow(machine).to receive_message_chain(:communicate, :sudo).with("sed -i.bak -e '/^DOCKER_CONFIG/d' /etc/environment")
25
27
  allow(machine).to receive_message_chain(:communicate, :sudo).with("echo DOCKER_CONFIG=/etc/docker >> /etc/environment")
26
- allow(machine).to receive_message_chain(:communicate, :sudo).with("mkdir -p /etc/docker")
27
- allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:root /etc/docker")
28
28
  end
29
29
 
30
30
  def mock_update_docker_systemd_config(machine)
@@ -71,9 +71,9 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
71
71
  docker_proxy = described_class.new(app, env)
72
72
  docker_proxy.instance_variable_set(:@machine, machine)
73
73
 
74
- # #docker_client_config_path mock
75
- fixture = docker_proxy.send(:tempfile, load_fixture(fixture)).path
76
- docker_proxy.instance_variable_set(:@docker_client_config_path, fixture)
74
+ # #docker_client_config mock
75
+ fixture = fixture = docker_proxy.send(:tempfile, load_fixture(fixture))
76
+ docker_proxy.instance_variable_set(:@docker_client_config, fixture.path)
77
77
 
78
78
  # #supported? mock
79
79
  allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_proxy_conf).and_return(true)
@@ -100,7 +100,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
100
100
  @docker_proxy = docker_proxy
101
101
  end
102
102
 
103
- context 'and when /etc/docker/config.json has proxy configuration' do
103
+ context 'and when /home/vagrant/.docker/config.json has proxy configuration' do
104
104
  before :each do
105
105
  fixture = fixture_file("docker_client_config_json_enabled_proxy")
106
106
  configure_docker_proxy(fixture)
@@ -109,7 +109,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
109
109
  )
110
110
  end
111
111
 
112
- it 'update /etc/docker/config.json' do
112
+ it 'update /home/vagrant/.docker/config.json' do
113
113
  expect(@docker_proxy.send(:configure_machine)).to eq true
114
114
  end
115
115
  end
@@ -123,9 +123,9 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
123
123
  docker_proxy = described_class.new(app, env)
124
124
  docker_proxy.instance_variable_set(:@machine, machine)
125
125
 
126
- # #docker_client_config_path mock
127
- fixture = docker_proxy.send(:tempfile, load_fixture(fixture)).path
128
- docker_proxy.instance_variable_set(:@docker_client_config_path, fixture)
126
+ # #docker_client_config mock
127
+ fixture = docker_proxy.send(:tempfile, load_fixture(fixture))
128
+ docker_proxy.instance_variable_set(:@docker_client_config, fixture.path)
129
129
 
130
130
  # #supported? mock
131
131
  allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_proxy_conf).and_return(true)
@@ -163,6 +163,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
163
163
  allow(machine).to receive_message_chain(:communicate, :sudo).with("mkdir -p /etc/systemd/system/docker.service.d")
164
164
  allow(machine).to receive_message_chain(:communicate, :upload).with(@docker_proxy.instance_variable_get(:@docker_systemd_config), "/tmp")
165
165
  allow(machine).to receive_message_chain(:communicate, :sudo).with('chown -R 0:0 /etc/systemd/system/docker.service.d/')
166
+ allow(machine).to receive_message_chain(:communicate, :sudo).with('touch /etc/systemd/system/docker.service.d/http-proxy.conf')
166
167
  allow(machine).to receive_message_chain(:communicate, :sudo).with('chmod 0644 /etc/systemd/system/docker.service.d/http-proxy.conf')
167
168
  allow(machine).to receive_message_chain(:communicate, :test).with('command -v systemctl').and_return(false)
168
169
  allow(machine).to receive_message_chain(:communicate, :test).with('diff -Naur /etc/systemd/system/docker.service.d/http-proxy.conf /tmp/vagrant-proxyconf-docker-systemd-config').and_return(false)
@@ -181,7 +182,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
181
182
  end
182
183
  end
183
184
 
184
- describe "#docker_client_config_path" do
185
+ describe "#docker_client_config" do
185
186
  let(:machine) { double('machine') }
186
187
 
187
188
  context "when not supported" do
@@ -195,46 +196,46 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
195
196
  allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_proxy_conf).and_return(true)
196
197
  allow(machine).to receive_message_chain(:guest, :capability).with(:docker_proxy_conf).and_return('/etc/default/docker')
197
198
 
198
- docker_proxy.send(:docker_client_config_path)
199
+ docker_proxy.send(:docker_client_config)
199
200
  end
200
201
 
201
202
  it { is_expected.to eq nil }
202
203
  end
203
204
 
204
205
  context "when supported" do
205
- context "when /etc/docker/config.json exists" do
206
+ context "when /home/vagrant/.docker/config.json exists" do
206
207
  subject do
207
208
  docker_proxy = described_class.new(nil, nil)
208
209
  docker_proxy.instance_variable_set(:@machine, machine)
209
- docker_proxy.instance_variable_set(:@docker_client_config_path, nil)
210
+ docker_proxy.instance_variable_set(:@docker_client_config, nil)
210
211
 
211
212
  allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
212
213
 
213
- allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /etc/docker/config.json ]").and_return(true)
214
- allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /etc/docker/config.json")
214
+ allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /home/vagrant/.docker/config.json ]").and_return(true)
215
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /home/vagrant/.docker/config.json")
215
216
  allow(machine).to receive_message_chain(:communicate, :download)
216
217
 
217
- docker_proxy.send(:docker_client_config_path)
218
+ docker_proxy.send(:docker_client_config)
218
219
  end
219
220
 
220
- it { expect(File.exists?(subject)).to eq true }
221
+ it { expect(File.exists?(subject.path)).to eq true }
221
222
  end
222
223
 
223
- context "when /etc/docker/config.json does not exist" do
224
+ context "when /home/vagrant/.docker/config.json does not exist" do
224
225
  subject do
225
226
  docker_proxy = described_class.new(nil, nil)
226
227
  docker_proxy.instance_variable_set(:@machine, machine)
227
- docker_proxy.instance_variable_set(:@docker_client_config_path, nil)
228
+ docker_proxy.instance_variable_set(:@docker_client_config, nil)
228
229
 
229
230
  allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
230
231
 
231
- allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /etc/docker/config.json ]").and_return(false)
232
+ allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /home/vagrant/.docker/config.json ]").and_return(false)
232
233
 
233
- docker_proxy.send(:docker_client_config_path)
234
+ docker_proxy.send(:docker_client_config)
234
235
  end
235
236
 
236
237
  it do
237
- expect(File.exists?(subject)).to eq true
238
+ expect(File.exists?(subject.path)).to eq true
238
239
  expect(File.read(subject)).to eq "{}"
239
240
  end
240
241
  end
@@ -263,14 +264,14 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
263
264
 
264
265
  end
265
266
 
266
- context "when #docker_client_config_path returns nil" do
267
+ context "when #docker_client_config returns nil" do
267
268
  it 'return nil' do
268
269
  docker_proxy = described_class.new(app, env)
269
270
  docker_proxy.instance_variable_set(:@machine, machine)
270
271
 
271
272
  # mock a result that looks like no proxy is configured for the config.json
272
273
  allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
273
- allow(docker_proxy).to receive(:docker_client_config_path).and_return(nil)
274
+ allow(docker_proxy).to receive(:docker_client_config).and_return(nil)
274
275
 
275
276
  # #supported? mock
276
277
  allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_proxy_conf).and_return(true)
@@ -280,7 +281,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
280
281
  end
281
282
  end
282
283
 
283
- context "when /etc/docker/config.json is supported" do
284
+ context "when /home/vagrant/.docker/config.json is supported" do
284
285
 
285
286
  context "when configuration is disabled" do
286
287
  it do
@@ -290,9 +291,11 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
290
291
  # mock a result that looks like proxy is configured for the config.json
291
292
  fixture = fixture_file("docker_client_config_json_enabled_proxy")
292
293
  fixture_content = load_fixture(fixture)
293
- config_path = docker_proxy.send(:tempfile, fixture_content).path
294
294
 
295
- docker_proxy.instance_variable_set(:@docker_client_config_path, config_path)
295
+ temp_filename = config_path = docker_proxy.send(:tempfile, fixture_content)
296
+ config_path = temp_filename.path
297
+
298
+ docker_proxy.instance_variable_set(:@docker_client_config, config_path)
296
299
 
297
300
  allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
298
301
  allow(docker_proxy).to receive(:disabled?).and_return(true)
@@ -329,9 +332,10 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
329
332
  # mock a result that looks like no proxy is configured for the config.json
330
333
  fixture = fixture_file("docker_client_config_json_no_proxy")
331
334
  fixture_content = load_fixture(fixture)
332
- config_path = docker_proxy.send(:tempfile, fixture_content).path
335
+ temp_filename = config_path = docker_proxy.send(:tempfile, fixture_content)
336
+ config_path = temp_filename.path
333
337
 
334
- docker_proxy.instance_variable_set(:@docker_client_config_path, config_path)
338
+ docker_proxy.instance_variable_set(:@docker_client_config, config_path)
335
339
 
336
340
  allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
337
341
  allow(docker_proxy).to receive(:disabled?).and_return(false)
@@ -389,8 +393,10 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
389
393
  docker_proxy.instance_variable_set(:@version, [18, 9, 0])
390
394
 
391
395
  fixture = fixture_file("docker_client_config_json_enabled_proxy")
392
- config_path = docker_proxy.send(:tempfile, load_fixture(fixture)).path
393
- docker_proxy.instance_variable_set(:@docker_client_config_path, config_path)
396
+ temp_filename = config_path = docker_proxy.send(:tempfile, load_fixture(fixture))
397
+ config_path = temp_filename.path
398
+
399
+ docker_proxy.instance_variable_set(:@docker_client_config, config_path)
394
400
 
395
401
  # to isolate this test, we turn of support for systemd
396
402
  allow(docker_proxy).to receive(:supports_systemd?).and_return(false)
@@ -438,8 +444,9 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
438
444
  allow(docker_proxy).to receive(:supports_systemd?).and_return(false)
439
445
 
440
446
  fixture = fixture_file("docker_client_config_json_enabled_proxy")
441
- config_path = docker_proxy.send(:tempfile, load_fixture(fixture)).path
442
- docker_proxy.instance_variable_set(:@docker_client_config_path, config_path)
447
+ temp_filename = docker_proxy.send(:tempfile, load_fixture(fixture))
448
+ config_path = temp_filename.path
449
+ docker_proxy.instance_variable_set(:@docker_client_config, config_path)
443
450
 
444
451
  allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_proxy_conf).and_return(true)
445
452
  allow(machine).to receive_message_chain(:guest, :capability).with(:docker_proxy_conf).and_return('/etc/default/docker')
@@ -4,6 +4,7 @@ require 'vagrant-proxyconf/action/configure_svn_proxy'
4
4
  def mock_write_config(machine)
5
5
  allow(machine).to receive_message_chain(:communicate, :sudo).with("rm -f /tmp/vagrant-proxyconf", error_check: false)
6
6
  allow(machine).to receive_message_chain(:communicate, :upload)
7
+ allow(machine).to receive_message_chain(:communicate, :test).with('command -v sudo').and_return(true)
7
8
  allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /tmp/vagrant-proxyconf")
8
9
  allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:root /tmp/vagrant-proxyconf")
9
10
  allow(machine).to receive_message_chain(:communicate, :sudo).with("mkdir -p /etc/subversion")