vagrant-proxyconf 1.5.1 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d859efb30525863489514b79c22bb78026039cc
4
- data.tar.gz: de787f2cb8e3a1fb9500667e45df19f6b9e6a208
3
+ metadata.gz: 57a68635cfc9a1ce7ad88b14d65ff04950f43b7b
4
+ data.tar.gz: 182af0796244d4b82b6eb6cc9338b2cc3212361b
5
5
  SHA512:
6
- metadata.gz: 3d2923af76570dc3a474e437b177a12e0e3ec6ca2f523820879e1acdd1d22d694526ac3adcadd008db3dbd331c3245c8ac24346a3b7936c52675578c3d12d513
7
- data.tar.gz: a64851d585e6cd4a83a116d66d29b8b008770e39ca1cedb22874a15db46441bc421ac901a5d6eec7a6fcb558c71c7621896fee912433221891cca7872b00c54d
6
+ metadata.gz: 31c746c218e6f4f65e9b3cbe88c09b7ca4d0e2efe472193d4571c60b531ad0241d76d55579a00673b08d9d543bf5eacfe6a9800e0baa6326408a344eda6b0e0b
7
+ data.tar.gz: 12fc3b6db9dc5511dcba1f21b0e77d1f796c734613420cd3c4b5672a0b10a6cec7131138c203d839c05a21235b092077ca842465f4bdca1142f8a22b28445209
@@ -1,10 +1,16 @@
1
+ # 1.5.2 / 2015-10-01
2
+
3
+ Improvements:
4
+
5
+ - Support URI-encorded UserInfo for Chef, SVN, Yum ([GH-130][])
6
+ - Support docker on Debian/Ubuntu with systemd ([GH-133][])
7
+
1
8
  # 1.5.1 / 2015-07-25
2
9
 
3
10
  Bug fixes:
4
11
 
5
12
  - Fix docker configuration ([GH-106][])
6
13
 
7
-
8
14
  # 1.5.0 / 2015-01-15
9
15
 
10
16
  Features:
@@ -214,3 +220,5 @@ Bug fixes:
214
220
  [GH-103]: https://github.com/tmatilai/vagrant-proxyconf/issues/103 "Issue 103"
215
221
  [GH-105]: https://github.com/tmatilai/vagrant-proxyconf/issues/105 "Issue 105"
216
222
  [GH-106]: https://github.com/tmatilai/vagrant-proxyconf/issues/106 "Issue 106"
223
+ [GH-130]: https://github.com/tmatilai/vagrant-proxyconf/issues/106 "Issue 130"
224
+ [GH-133]: https://github.com/tmatilai/vagrant-proxyconf/issues/106 "Issue 133"
@@ -0,0 +1,50 @@
1
+ require_relative '../util'
2
+
3
+ module VagrantPlugins
4
+ module ProxyConf
5
+ module Cap
6
+ module Debian
7
+ # Capability for docker proxy configuration
8
+ module DockerProxyConf
9
+ CONFIG_DIR = '/etc/default/'
10
+
11
+ # @return [String, false] the path to docker or `false` if not found
12
+ def self.docker_proxy_conf(machine)
13
+ docker_command = find_docker_command(machine)
14
+ return false if docker_command.nil?
15
+
16
+ config_path = CONFIG_DIR + docker_command
17
+ return config_path unless Util.which(machine, 'systemctl')
18
+
19
+ machine.communicate.tap do |comm|
20
+ src_file = "/lib/systemd/system/#{docker_command}.service"
21
+ dst_file = "/etc/systemd/system/#{docker_command}.service"
22
+ tmp_file = "/tmp/#{docker_command}.service"
23
+ env_file = "EnvironmentFile=-\\/etc\\/default\\/#{docker_command}"
24
+ if comm.test("grep -q -e '#{env_file}' #{src_file}")
25
+ comm.sudo("cp -p #{src_file} #{tmp_file}")
26
+ else
27
+ comm.sudo("sed -e 's/\\[Service\\]/[Service]\\n#{env_file}/g' #{src_file} > #{tmp_file}")
28
+ end
29
+ unless comm.test("diff #{tmp_file} #{dst_file}")
30
+ # update config and restart docker when config changed
31
+ comm.sudo("mv -f #{tmp_file} #{dst_file}")
32
+ comm.sudo('systemctl daemon-reload')
33
+ end
34
+ comm.sudo("rm -f #{tmp_file}")
35
+ end
36
+ config_path
37
+ end
38
+
39
+ private
40
+
41
+ def self.find_docker_command(machine)
42
+ return 'docker' if Util.which(machine, 'docker')
43
+ return 'docker.io' if Util.which(machine, 'docker.io')
44
+ nil
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -18,6 +18,11 @@ module VagrantPlugins
18
18
  Cap::CoreOS::DockerProxyConf
19
19
  end
20
20
 
21
+ guest_capability 'debian', 'docker_proxy_conf' do
22
+ require_relative 'cap/debian/docker_proxy_conf'
23
+ Cap::Debian::DockerProxyConf
24
+ end
25
+
21
26
  guest_capability 'linux', 'env_proxy_conf' do
22
27
  require_relative 'cap/linux/env_proxy_conf'
23
28
  Cap::Linux::EnvProxyConf
@@ -11,13 +11,7 @@ module VagrantPlugins
11
11
  # @return [String] the host
12
12
  # @!attribute [r] port
13
13
  # @return [String] the port
14
- # @!attribute [r] user
15
- # @return [String] the username
16
- def_delegators :@uri, :host, :port, :user
17
-
18
- # @!attribute [r] pass
19
- # @return [String] the password
20
- def_delegator :@uri, :password, :pass
14
+ def_delegators :@uri, :host, :port
21
15
 
22
16
  # @param uri [String] the URI including optional userinfo
23
17
  def initialize(uri)
@@ -36,6 +30,18 @@ module VagrantPlugins
36
30
  end
37
31
  end
38
32
 
33
+ # @return [String] the username
34
+ def user
35
+ return URI.decode(@uri.user) if @uri.user
36
+ @uri.user
37
+ end
38
+
39
+ # @return [String] the password
40
+ def pass
41
+ return URI.decode(@uri.password) if @uri.password
42
+ @uri.password
43
+ end
44
+
39
45
  alias_method :to_s, :uri
40
46
  end
41
47
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProxyConf
3
- VERSION = '1.5.1'
3
+ VERSION = '1.5.2'
4
4
  end
5
5
  end
@@ -45,6 +45,24 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureChefProxy do
45
45
  end
46
46
  end
47
47
 
48
+ context "with specified default configurations in URI encoded" do
49
+ before :each do
50
+ config.http = 'http://bar%23:baz%25@foo:1234'
51
+ config.https = false
52
+
53
+ configure_chef
54
+ end
55
+
56
+ it "configures chef" do
57
+ expect(chef.http_proxy).to eq 'http://foo:1234'
58
+ expect(chef.http_proxy_user).to eq 'bar#'
59
+ expect(chef.http_proxy_pass).to eq 'baz%'
60
+ expect(chef.https_proxy).to be_nil
61
+ expect(chef.https_proxy_user).to be_nil
62
+ expect(chef.https_proxy_pass).to be_nil
63
+ end
64
+ end
65
+
48
66
  context "with specified chef configurations" do
49
67
  before :each do
50
68
  chef.http_proxy = 'http://proxy:8080/'
@@ -8,4 +8,83 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureSvnProxy do
8
8
  it { is_expected.to eq 'svn_proxy' }
9
9
  end
10
10
 
11
+ describe '#svn_config' do
12
+ subject do
13
+ action = described_class.new(nil, nil)
14
+ allow(action).to receive(:config) { config }
15
+ action.send(:svn_config)
16
+ end
17
+ let(:config) { OpenStruct.new(http: http) }
18
+ let(:uri_encoded) { false }
19
+
20
+ context "with `false`" do
21
+ let(:http) { false }
22
+ it do
23
+ is_expected.to eq <<-CONFIG
24
+ [global]
25
+ http-proxy-host=
26
+ http-proxy-port=
27
+ http-proxy-username=
28
+ http-proxy-password=
29
+ http-proxy-exceptions=
30
+ CONFIG
31
+ end
32
+ end
33
+
34
+ context "without userinfo" do
35
+ let(:http) { 'http://proxy:1234/' }
36
+ it do
37
+ is_expected.to eq <<-CONFIG
38
+ [global]
39
+ http-proxy-host=proxy
40
+ http-proxy-port=1234
41
+ http-proxy-username=
42
+ http-proxy-password=
43
+ http-proxy-exceptions=
44
+ CONFIG
45
+ end
46
+ end
47
+
48
+ context "with userinfo" do
49
+ let(:http) { 'http://foo:bar@myproxy:9876' }
50
+ it do
51
+ is_expected.to eq <<-CONFIG
52
+ [global]
53
+ http-proxy-host=myproxy
54
+ http-proxy-port=9876
55
+ http-proxy-username=foo
56
+ http-proxy-password=bar
57
+ http-proxy-exceptions=
58
+ CONFIG
59
+ end
60
+ end
61
+
62
+ context "with special characters" do
63
+ let(:http) { %q{http://x*y:a(b@proxy.com:8080} }
64
+ it do
65
+ is_expected.to eq <<-CONFIG
66
+ [global]
67
+ http-proxy-host=proxy.com
68
+ http-proxy-port=8080
69
+ http-proxy-username=x*y
70
+ http-proxy-password=a(b
71
+ http-proxy-exceptions=
72
+ CONFIG
73
+ end
74
+ end
75
+
76
+ context "with URI encoded special characters" do
77
+ let(:http) { %q{http://foo%25:abc%23123@proxy.com:8080} }
78
+ it do
79
+ is_expected.to eq <<-CONFIG
80
+ [global]
81
+ http-proxy-host=proxy.com
82
+ http-proxy-port=8080
83
+ http-proxy-username=foo%
84
+ http-proxy-password=abc#123
85
+ http-proxy-exceptions=
86
+ CONFIG
87
+ end
88
+ end
89
+ end
11
90
  end
@@ -35,5 +35,10 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureYumProxy do
35
35
  let(:http) { %q{http://x*y:a(b@proxy.com:8080} }
36
36
  it { is_expected.to eq %q{-v proxy=http://proxy.com:8080 -v user=x\\*y -v pass=a\\(b} }
37
37
  end
38
+
39
+ context "with URI encoded special characters" do
40
+ let(:http) { %q{http://foo%25:abc%23123@proxy.com:8080} }
41
+ it { is_expected.to eq %q{-v proxy=http://proxy.com:8080 -v user=foo\% -v pass=abc\#123} }
42
+ end
38
43
  end
39
44
  end
@@ -95,4 +95,13 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
95
95
  its(:pass) { should be_nil }
96
96
  end
97
97
 
98
+ context "with uri_encoded" do
99
+ let(:uri) { 'http://foo%25:bar%23123@proxy.example.com:8123/' }
100
+ its(:to_s) { should eq 'http://proxy.example.com:8123' }
101
+ its(:uri) { should eq 'http://proxy.example.com:8123' }
102
+ its(:host) { should eq 'proxy.example.com' }
103
+ its(:port) { should eq 8123 }
104
+ its(:user) { should eq 'foo%' }
105
+ its(:pass) { should eq 'bar#123' }
106
+ end
98
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-proxyconf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Teemu Matilainen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-25 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Vagrant plugin that configures the virtual machine to use proxy servers
14
14
  email:
@@ -45,6 +45,7 @@ files:
45
45
  - lib/vagrant-proxyconf/action/only_once.rb
46
46
  - lib/vagrant-proxyconf/cap/coreos/docker_proxy_conf.rb
47
47
  - lib/vagrant-proxyconf/cap/debian/apt_proxy_conf.rb
48
+ - lib/vagrant-proxyconf/cap/debian/docker_proxy_conf.rb
48
49
  - lib/vagrant-proxyconf/cap/linux/docker_proxy_conf.rb
49
50
  - lib/vagrant-proxyconf/cap/linux/env_proxy_conf.rb
50
51
  - lib/vagrant-proxyconf/cap/linux/git_proxy_conf.rb
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  version: '0'
144
145
  requirements: []
145
146
  rubyforge_project:
146
- rubygems_version: 2.4.5
147
+ rubygems_version: 2.4.5.1
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: A Vagrant plugin that configures the virtual machine to use proxy servers