vagrant-proxyconf 1.0.1 → 1.1.0
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 +7 -0
- data/.gitignore +1 -1
- data/.travis.yml +15 -1
- data/CHANGELOG.md +25 -0
- data/Gemfile +6 -3
- data/LICENSE.txt +1 -1
- data/README.md +34 -8
- data/Rakefile +2 -0
- data/lib/vagrant-proxyconf/action.rb +28 -5
- data/lib/vagrant-proxyconf/action/base.rb +26 -19
- data/lib/vagrant-proxyconf/action/configure_chef_proxy.rb +15 -15
- data/lib/vagrant-proxyconf/action/configure_env_proxy.rb +2 -2
- data/lib/vagrant-proxyconf/action/configure_pear_proxy.rb +29 -0
- data/lib/vagrant-proxyconf/action/configure_yum_proxy.rb +5 -10
- data/lib/vagrant-proxyconf/action/is_enabled.rb +24 -0
- data/lib/vagrant-proxyconf/cap/linux/pear_proxy_conf.rb +15 -0
- data/lib/vagrant-proxyconf/capability.rb +31 -0
- data/lib/vagrant-proxyconf/config.rb +27 -0
- data/lib/vagrant-proxyconf/config/apt_proxy.rb +24 -24
- data/lib/vagrant-proxyconf/config/env_proxy.rb +8 -1
- data/lib/vagrant-proxyconf/config/key_mixin.rb +3 -2
- data/lib/vagrant-proxyconf/config/proxy.rb +3 -0
- data/lib/vagrant-proxyconf/hook.rb +41 -0
- data/lib/vagrant-proxyconf/plugin.rb +42 -70
- data/lib/vagrant-proxyconf/version.rb +1 -1
- data/locales/en.yml +9 -1
- data/spec/spec_helper.rb +11 -9
- data/spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb +3 -1
- data/spec/unit/vagrant-proxyconf/action/configure_pear_proxy_spec.rb +10 -0
- data/spec/unit/vagrant-proxyconf/action/configure_yum_proxy_spec.rb +5 -1
- data/spec/unit/vagrant-proxyconf/action/is_enabled_spec.rb +39 -0
- data/spec/unit/vagrant-proxyconf/cap/linux/pear_proxy_conf_spec.rb +25 -0
- data/spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb +15 -8
- data/spec/unit/vagrant-proxyconf/plugin_spec.rb +54 -15
- metadata +19 -15
data/locales/en.yml
CHANGED
@@ -24,6 +24,14 @@ en:
|
|
24
24
|
configuring: |-
|
25
25
|
Configuring proxy environment variables...
|
26
26
|
|
27
|
+
pear_proxy:
|
28
|
+
not_enabled: |-
|
29
|
+
pear_proxy not enabled or configured
|
30
|
+
not_supported: |-
|
31
|
+
Skipping PEAR proxy config as `pear` is not found
|
32
|
+
configuring: |-
|
33
|
+
Configuring proxy for PEAR...
|
34
|
+
|
27
35
|
yum_proxy:
|
28
36
|
not_enabled: |-
|
29
37
|
yum_proxy not enabled or configured
|
@@ -34,4 +42,4 @@ en:
|
|
34
42
|
|
35
43
|
errors:
|
36
44
|
vagrant_version: |-
|
37
|
-
vagrant-proxyconf plugin requires Vagrant %{
|
45
|
+
vagrant-proxyconf plugin requires Vagrant version %{requirement}
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start do
|
8
|
+
coverage_dir('tmp/coverage')
|
9
|
+
add_filter '/spec/'
|
10
|
+
end
|
11
|
+
|
1
12
|
RSpec.configure do |config|
|
2
13
|
config.expect_with :rspec do |c|
|
3
14
|
c.syntax = :expect
|
@@ -5,12 +16,3 @@ RSpec.configure do |config|
|
|
5
16
|
config.color = true
|
6
17
|
config.tty = true
|
7
18
|
end
|
8
|
-
|
9
|
-
require 'simplecov'
|
10
|
-
SimpleCov.start do
|
11
|
-
coverage_dir('tmp/coverage')
|
12
|
-
add_filter '/spec/'
|
13
|
-
end
|
14
|
-
|
15
|
-
require 'tempfile'
|
16
|
-
require 'vagrant-proxyconf'
|
@@ -9,7 +9,9 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureChefProxy do
|
|
9
9
|
let(:config) { OpenStruct.new }
|
10
10
|
|
11
11
|
def configure_chef
|
12
|
-
described_class.new(nil, nil)
|
12
|
+
action = described_class.new(nil, nil)
|
13
|
+
action.stub(:config => config)
|
14
|
+
action.send(:configure_chef, chef)
|
13
15
|
end
|
14
16
|
|
15
17
|
context "with no configurations" do
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant-proxyconf/action/configure_pear_proxy'
|
3
|
+
|
4
|
+
describe VagrantPlugins::ProxyConf::Action::ConfigurePearProxy do
|
5
|
+
|
6
|
+
describe '#config_name' do
|
7
|
+
subject { described_class.new(double, double).config_name }
|
8
|
+
it { should eq 'pear_proxy' }
|
9
|
+
end
|
10
|
+
end
|
@@ -9,7 +9,11 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureYumProxy do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '#proxy_params' do
|
12
|
-
subject
|
12
|
+
subject do
|
13
|
+
action = described_class.new(nil, nil)
|
14
|
+
action.stub(:config => config)
|
15
|
+
action.send(:proxy_params)
|
16
|
+
end
|
13
17
|
let(:config) { OpenStruct.new(http: http) }
|
14
18
|
|
15
19
|
context "with `false`" do
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant-proxyconf/action/is_enabled'
|
3
|
+
|
4
|
+
describe VagrantPlugins::ProxyConf::Action::IsEnabled do
|
5
|
+
let(:app) { lambda { |env| } }
|
6
|
+
let(:env) { { :machine => machine } }
|
7
|
+
let(:machine) do
|
8
|
+
double('machine').tap { |machine| machine.stub(:config).and_return(config) }
|
9
|
+
end
|
10
|
+
let(:config) do
|
11
|
+
double('config').tap { |config| config.stub(:proxy => proxy_config) }
|
12
|
+
end
|
13
|
+
let(:proxy_config) do
|
14
|
+
double('proxy_config').tap { |config| config.stub(:enabled => enabled) }
|
15
|
+
end
|
16
|
+
|
17
|
+
[false, ''].each do |value|
|
18
|
+
context "with `config.proxy.enabled=#{value.inspect}`" do
|
19
|
+
let(:enabled) { value }
|
20
|
+
|
21
|
+
it "results to falsy" do
|
22
|
+
described_class.new(app, {}).call(env)
|
23
|
+
expect(env[:result]).to be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
[nil, true, :auto, 'yes please'].each do |value|
|
29
|
+
context "with `config.proxy.enabled=#{value.inspect}`" do
|
30
|
+
let(:enabled) { value }
|
31
|
+
|
32
|
+
it "results to truthy" do
|
33
|
+
described_class.new(app, {}).call(env)
|
34
|
+
expect(env[:result]).to be_true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant-proxyconf/cap/linux/pear_proxy_conf'
|
3
|
+
|
4
|
+
describe VagrantPlugins::ProxyConf::Cap::Linux::PearProxyConf do
|
5
|
+
|
6
|
+
describe '.pear_proxy_conf' do
|
7
|
+
let(:machine) { double }
|
8
|
+
let(:communicator) { double }
|
9
|
+
|
10
|
+
before do
|
11
|
+
machine.stub(:communicate => communicator)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns true when pear is installed" do
|
15
|
+
expect(communicator).to receive(:test).with("which pear").and_return(true)
|
16
|
+
expect(described_class.pear_proxy_conf(machine)).to be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns false when pear is not installed" do
|
20
|
+
expect(communicator).to receive(:test).with("which pear").and_return(false)
|
21
|
+
expect(described_class.pear_proxy_conf(machine)).to be_false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -8,10 +8,6 @@ def config_with(options)
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def conf_lines(env_var, val)
|
12
|
-
[env_var.upcase, env_var.downcase].map { |var| "export #{var}=#{val}\n" }
|
13
|
-
end
|
14
|
-
|
15
11
|
RSpec::Matchers.define :match_lines do |expected|
|
16
12
|
match do |actual|
|
17
13
|
expect(actual.lines.to_a).to match_array(expected)
|
@@ -38,15 +34,23 @@ describe VagrantPlugins::ProxyConf::Config::EnvProxy do
|
|
38
34
|
let(:proxy) { 'http://proxy.example.com:8888' }
|
39
35
|
subject { config_with({ http: proxy }) }
|
40
36
|
its(:enabled?) { should be_true }
|
41
|
-
its(:to_s) { should match_lines
|
37
|
+
its(:to_s) { should match_lines [
|
38
|
+
%Q{export HTTP_PROXY=#{proxy}\n},
|
39
|
+
%Q{export http_proxy=#{proxy}\n},
|
40
|
+
] }
|
42
41
|
end
|
43
42
|
|
44
43
|
context "with http and no_proxy config" do
|
45
44
|
let(:proxy) { 'http://proxy.example.com:8888' }
|
46
|
-
let(:no_proxy) { 'localhost,127.0.0.1' }
|
45
|
+
let(:no_proxy) { 'localhost, 127.0.0.1' }
|
47
46
|
subject { config_with({ http: proxy, no_proxy: no_proxy }) }
|
48
47
|
its(:enabled?) { should be_true }
|
49
|
-
its(:to_s) { should match_lines
|
48
|
+
its(:to_s) { should match_lines [
|
49
|
+
%Q{export HTTP_PROXY=#{proxy}\n},
|
50
|
+
%Q{export http_proxy=#{proxy}\n},
|
51
|
+
%Q{export NO_PROXY="#{no_proxy}"\n},
|
52
|
+
%Q{export no_proxy="#{no_proxy}"\n},
|
53
|
+
] }
|
50
54
|
end
|
51
55
|
|
52
56
|
context "with VAGRANT_ENV_HTTP_PROXY env var" do
|
@@ -54,6 +58,9 @@ describe VagrantPlugins::ProxyConf::Config::EnvProxy do
|
|
54
58
|
before(:each) { ENV['VAGRANT_ENV_HTTP_PROXY'] = proxy }
|
55
59
|
subject { config_with({ http: 'http://default:3128' }) }
|
56
60
|
its(:enabled?) { should be_true }
|
57
|
-
its(:to_s) { should match_lines
|
61
|
+
its(:to_s) { should match_lines [
|
62
|
+
%Q{export HTTP_PROXY=#{proxy}\n},
|
63
|
+
%Q{export http_proxy=#{proxy}\n},
|
64
|
+
] }
|
58
65
|
end
|
59
66
|
end
|
@@ -3,13 +3,36 @@ require 'vagrant-proxyconf/plugin'
|
|
3
3
|
|
4
4
|
describe VagrantPlugins::ProxyConf::Plugin do
|
5
5
|
|
6
|
+
describe '.check_vagrant_version' do
|
7
|
+
before :each do
|
8
|
+
stub_const('Vagrant::VERSION', '1.2.3')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "accepts single String argument" do
|
12
|
+
expect(described_class.check_vagrant_version('~> 1.1')).to be_true
|
13
|
+
expect(described_class.check_vagrant_version('1.2')).to be_false
|
14
|
+
end
|
15
|
+
|
16
|
+
it "accepts an Array argument" do
|
17
|
+
expect(described_class.check_vagrant_version(['>= 1.1', '< 1.3.0.beta'])).to be_true
|
18
|
+
expect(described_class.check_vagrant_version(['>= 1.3'])).to be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "accepts multiple arguments" do
|
22
|
+
expect(described_class.check_vagrant_version('>= 1.0', '<= 1.3')).to be_true
|
23
|
+
expect(described_class.check_vagrant_version('~> 1.2', '>= 1.2.5')).to be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
6
27
|
describe '.check_vagrant_version!' do
|
7
28
|
subject { described_class.check_vagrant_version! }
|
8
|
-
let(:
|
9
|
-
let(:err_msg) { /requires Vagrant #{
|
29
|
+
let(:requirement) { '>= 1.2.3' }
|
30
|
+
let(:err_msg) { /requires Vagrant version #{Regexp.escape(requirement.inspect)}/ }
|
10
31
|
|
11
32
|
before :each do
|
12
|
-
stub_const(
|
33
|
+
stub_const(
|
34
|
+
'VagrantPlugins::ProxyConf::Plugin::VAGRANT_VERSION_REQUIREMENT',
|
35
|
+
requirement)
|
13
36
|
stub_const('Vagrant::VERSION', vagrant_version)
|
14
37
|
$stderr.stub(:puts)
|
15
38
|
end
|
@@ -26,7 +49,7 @@ describe VagrantPlugins::ProxyConf::Plugin do
|
|
26
49
|
end
|
27
50
|
|
28
51
|
context "on exact required Vagrant version" do
|
29
|
-
let(:vagrant_version) {
|
52
|
+
let(:vagrant_version) { '1.2.3' }
|
30
53
|
it "does not raise" do
|
31
54
|
expect { subject }.not_to raise_error
|
32
55
|
end
|
@@ -44,19 +67,35 @@ describe VagrantPlugins::ProxyConf::Plugin do
|
|
44
67
|
subject { described_class.load_optional_dependency(plugin_name) }
|
45
68
|
let(:plugin_name) { 'vagrant-foo' }
|
46
69
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
70
|
+
# Vagrant plugin loading API changed in v1.5.0
|
71
|
+
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new('1.5.0.dev')
|
72
|
+
it "loads the specified plugin" do
|
73
|
+
expect(Vagrant).to receive(:require_plugin).with(plugin_name)
|
74
|
+
subject
|
75
|
+
end
|
51
76
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
77
|
+
it "ignores PluginLoadError" do
|
78
|
+
expect(Vagrant).to receive(:require_plugin).
|
79
|
+
and_raise(Vagrant::Errors::PluginLoadError, plugin: plugin_name)
|
80
|
+
expect { subject }.not_to raise_error
|
81
|
+
end
|
56
82
|
|
57
|
-
|
58
|
-
|
59
|
-
|
83
|
+
it "won't ignore other error" do
|
84
|
+
expect(Vagrant).to receive(:require_plugin).
|
85
|
+
and_raise(Vagrant::Errors::PluginLoadFailed, plugin: plugin_name)
|
86
|
+
expect { subject }.to raise_error(Vagrant::Errors::PluginLoadFailed)
|
87
|
+
end
|
88
|
+
else
|
89
|
+
it "loads the specified plugin" do
|
90
|
+
expect(described_class).to receive(:require).with(plugin_name)
|
91
|
+
subject
|
92
|
+
end
|
93
|
+
|
94
|
+
it "ignores errors" do
|
95
|
+
expect(described_class).to receive(:require).
|
96
|
+
and_raise(LoadError, path: plugin_name)
|
97
|
+
expect { subject }.not_to raise_error
|
98
|
+
end
|
60
99
|
end
|
61
100
|
end
|
62
101
|
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-proxyconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Teemu Matilainen
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: A Vagrant plugin that configures the virtual machine to use proxy servers
|
15
14
|
email:
|
@@ -36,17 +35,23 @@ files:
|
|
36
35
|
- lib/vagrant-proxyconf/action/configure_apt_proxy.rb
|
37
36
|
- lib/vagrant-proxyconf/action/configure_chef_proxy.rb
|
38
37
|
- lib/vagrant-proxyconf/action/configure_env_proxy.rb
|
38
|
+
- lib/vagrant-proxyconf/action/configure_pear_proxy.rb
|
39
39
|
- lib/vagrant-proxyconf/action/configure_yum_proxy.rb
|
40
|
+
- lib/vagrant-proxyconf/action/is_enabled.rb
|
40
41
|
- lib/vagrant-proxyconf/action/only_once.rb
|
41
42
|
- lib/vagrant-proxyconf/cap/debian/apt_proxy_conf.rb
|
42
43
|
- lib/vagrant-proxyconf/cap/linux/env_proxy_conf.rb
|
44
|
+
- lib/vagrant-proxyconf/cap/linux/pear_proxy_conf.rb
|
43
45
|
- lib/vagrant-proxyconf/cap/redhat/yum_proxy_conf.rb
|
46
|
+
- lib/vagrant-proxyconf/capability.rb
|
47
|
+
- lib/vagrant-proxyconf/config.rb
|
44
48
|
- lib/vagrant-proxyconf/config/apt_proxy.rb
|
45
49
|
- lib/vagrant-proxyconf/config/env_proxy.rb
|
46
50
|
- lib/vagrant-proxyconf/config/key.rb
|
47
51
|
- lib/vagrant-proxyconf/config/key_mixin.rb
|
48
52
|
- lib/vagrant-proxyconf/config/proxy.rb
|
49
53
|
- lib/vagrant-proxyconf/config/yum_proxy.rb
|
54
|
+
- lib/vagrant-proxyconf/hook.rb
|
50
55
|
- lib/vagrant-proxyconf/logger.rb
|
51
56
|
- lib/vagrant-proxyconf/plugin.rb
|
52
57
|
- lib/vagrant-proxyconf/resource.rb
|
@@ -72,11 +77,14 @@ files:
|
|
72
77
|
- spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
|
73
78
|
- spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb
|
74
79
|
- spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb
|
80
|
+
- spec/unit/vagrant-proxyconf/action/configure_pear_proxy_spec.rb
|
75
81
|
- spec/unit/vagrant-proxyconf/action/configure_yum_proxy_spec.rb
|
82
|
+
- spec/unit/vagrant-proxyconf/action/is_enabled_spec.rb
|
76
83
|
- spec/unit/vagrant-proxyconf/action/only_once_spec.rb
|
77
84
|
- spec/unit/vagrant-proxyconf/action_spec.rb
|
78
85
|
- spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
|
79
86
|
- spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb
|
87
|
+
- spec/unit/vagrant-proxyconf/cap/linux/pear_proxy_conf_spec.rb
|
80
88
|
- spec/unit/vagrant-proxyconf/cap/redhat/yum_proxy_conf_spec.rb
|
81
89
|
- spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
|
82
90
|
- spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb
|
@@ -93,33 +101,26 @@ files:
|
|
93
101
|
homepage: http://tmatilai.github.io/vagrant-proxyconf/
|
94
102
|
licenses:
|
95
103
|
- MIT
|
104
|
+
metadata: {}
|
96
105
|
post_install_message:
|
97
106
|
rdoc_options: []
|
98
107
|
require_paths:
|
99
108
|
- lib
|
100
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
110
|
requirements:
|
103
|
-
- -
|
111
|
+
- - '>='
|
104
112
|
- !ruby/object:Gem::Version
|
105
113
|
version: '0'
|
106
|
-
segments:
|
107
|
-
- 0
|
108
|
-
hash: -1237288161997812265
|
109
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
115
|
requirements:
|
112
|
-
- -
|
116
|
+
- - '>='
|
113
117
|
- !ruby/object:Gem::Version
|
114
118
|
version: '0'
|
115
|
-
segments:
|
116
|
-
- 0
|
117
|
-
hash: -1237288161997812265
|
118
119
|
requirements: []
|
119
120
|
rubyforge_project:
|
120
|
-
rubygems_version:
|
121
|
+
rubygems_version: 2.0.14
|
121
122
|
signing_key:
|
122
|
-
specification_version:
|
123
|
+
specification_version: 4
|
123
124
|
summary: A Vagrant plugin that configures the virtual machine to use proxy servers
|
124
125
|
test_files:
|
125
126
|
- spec/spec_helper.rb
|
@@ -140,11 +141,14 @@ test_files:
|
|
140
141
|
- spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
|
141
142
|
- spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb
|
142
143
|
- spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb
|
144
|
+
- spec/unit/vagrant-proxyconf/action/configure_pear_proxy_spec.rb
|
143
145
|
- spec/unit/vagrant-proxyconf/action/configure_yum_proxy_spec.rb
|
146
|
+
- spec/unit/vagrant-proxyconf/action/is_enabled_spec.rb
|
144
147
|
- spec/unit/vagrant-proxyconf/action/only_once_spec.rb
|
145
148
|
- spec/unit/vagrant-proxyconf/action_spec.rb
|
146
149
|
- spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
|
147
150
|
- spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb
|
151
|
+
- spec/unit/vagrant-proxyconf/cap/linux/pear_proxy_conf_spec.rb
|
148
152
|
- spec/unit/vagrant-proxyconf/cap/redhat/yum_proxy_conf_spec.rb
|
149
153
|
- spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
|
150
154
|
- spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb
|