librarian-puppet-lmco 0.9.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.md +187 -0
- data/bin/librarian-puppet +9 -0
- data/lib/librarian/puppet.rb +22 -0
- data/lib/librarian/puppet/cli.rb +85 -0
- data/lib/librarian/puppet/dsl.rb +16 -0
- data/lib/librarian/puppet/environment.rb +54 -0
- data/lib/librarian/puppet/extension.rb +47 -0
- data/lib/librarian/puppet/lockfile/parser.rb +53 -0
- data/lib/librarian/puppet/source.rb +4 -0
- data/lib/librarian/puppet/source/forge.rb +348 -0
- data/lib/librarian/puppet/source/git.rb +121 -0
- data/lib/librarian/puppet/source/githubtarball.rb +249 -0
- data/lib/librarian/puppet/source/local.rb +57 -0
- data/lib/librarian/puppet/source/path.rb +12 -0
- data/lib/librarian/puppet/templates/Puppetfile +10 -0
- data/lib/librarian/puppet/version.rb +5 -0
- data/vendor/librarian/CHANGELOG.md +224 -0
- data/vendor/librarian/Gemfile +6 -0
- data/vendor/librarian/MIT-LICENSE +20 -0
- data/vendor/librarian/README.md +401 -0
- data/vendor/librarian/Rakefile +34 -0
- data/vendor/librarian/bin/librarian-chef +7 -0
- data/vendor/librarian/bin/librarian-mock +7 -0
- data/vendor/librarian/config/cucumber.yaml +1 -0
- data/vendor/librarian/features/chef/cli/init.feature +11 -0
- data/vendor/librarian/features/chef/cli/install.feature +64 -0
- data/vendor/librarian/features/chef/cli/show.feature +77 -0
- data/vendor/librarian/features/chef/cli/version.feature +11 -0
- data/vendor/librarian/features/support/env.rb +9 -0
- data/vendor/librarian/lib/librarian.rb +11 -0
- data/vendor/librarian/lib/librarian/action.rb +5 -0
- data/vendor/librarian/lib/librarian/action/base.rb +24 -0
- data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
- data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
- data/vendor/librarian/lib/librarian/action/install.rb +95 -0
- data/vendor/librarian/lib/librarian/action/persist_resolution_mixin.rb +51 -0
- data/vendor/librarian/lib/librarian/action/resolve.rb +46 -0
- data/vendor/librarian/lib/librarian/action/update.rb +44 -0
- data/vendor/librarian/lib/librarian/chef.rb +1 -0
- data/vendor/librarian/lib/librarian/chef/cli.rb +47 -0
- data/vendor/librarian/lib/librarian/chef/dsl.rb +16 -0
- data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/chef/integration/knife.rb +46 -0
- data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
- data/vendor/librarian/lib/librarian/chef/source.rb +4 -0
- data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
- data/vendor/librarian/lib/librarian/chef/source/github.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
- data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/site.rb +442 -0
- data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
- data/vendor/librarian/lib/librarian/cli.rb +223 -0
- data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +93 -0
- data/vendor/librarian/lib/librarian/config.rb +7 -0
- data/vendor/librarian/lib/librarian/config/database.rb +205 -0
- data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
- data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
- data/vendor/librarian/lib/librarian/config/source.rb +149 -0
- data/vendor/librarian/lib/librarian/dependency.rb +147 -0
- data/vendor/librarian/lib/librarian/dsl.rb +108 -0
- data/vendor/librarian/lib/librarian/dsl/receiver.rb +46 -0
- data/vendor/librarian/lib/librarian/dsl/target.rb +171 -0
- data/vendor/librarian/lib/librarian/environment.rb +182 -0
- data/vendor/librarian/lib/librarian/error.rb +4 -0
- data/vendor/librarian/lib/librarian/helpers.rb +13 -0
- data/vendor/librarian/lib/librarian/linter/source_linter.rb +55 -0
- data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
- data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
- data/vendor/librarian/lib/librarian/lockfile/parser.rb +123 -0
- data/vendor/librarian/lib/librarian/logger.rb +46 -0
- data/vendor/librarian/lib/librarian/manifest.rb +140 -0
- data/vendor/librarian/lib/librarian/manifest_set.rb +151 -0
- data/vendor/librarian/lib/librarian/mock.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
- data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
- data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/source/mock.rb +80 -0
- data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
- data/vendor/librarian/lib/librarian/resolution.rb +46 -0
- data/vendor/librarian/lib/librarian/resolver.rb +81 -0
- data/vendor/librarian/lib/librarian/resolver/implementation.rb +223 -0
- data/vendor/librarian/lib/librarian/source.rb +2 -0
- data/vendor/librarian/lib/librarian/source/basic_api.rb +45 -0
- data/vendor/librarian/lib/librarian/source/git.rb +134 -0
- data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
- data/vendor/librarian/lib/librarian/source/local.rb +54 -0
- data/vendor/librarian/lib/librarian/source/path.rb +56 -0
- data/vendor/librarian/lib/librarian/spec.rb +13 -0
- data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
- data/vendor/librarian/lib/librarian/specfile.rb +17 -0
- data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
- data/vendor/librarian/lib/librarian/ui.rb +64 -0
- data/vendor/librarian/lib/librarian/version.rb +3 -0
- data/vendor/librarian/librarian.gemspec +35 -0
- data/vendor/librarian/spec/functional/chef/cli_spec.rb +194 -0
- data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
- data/vendor/librarian/spec/functional/chef/source/site_spec.rb +266 -0
- data/vendor/librarian/spec/functional/source/git/repository_spec.rb +150 -0
- data/vendor/librarian/spec/integration/chef/source/git_spec.rb +441 -0
- data/vendor/librarian/spec/integration/chef/source/site_spec.rb +217 -0
- data/vendor/librarian/spec/support/cli_macro.rb +114 -0
- data/vendor/librarian/spec/support/method_patch_macro.rb +30 -0
- data/vendor/librarian/spec/support/with_env_macro.rb +20 -0
- data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
- data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
- data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
- data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
- data/vendor/librarian/spec/unit/config/database_spec.rb +327 -0
- data/vendor/librarian/spec/unit/dependency_spec.rb +212 -0
- data/vendor/librarian/spec/unit/dsl_spec.rb +173 -0
- data/vendor/librarian/spec/unit/environment_spec.rb +173 -0
- data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
- data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
- data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
- data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
- data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
- data/vendor/librarian/spec/unit/resolver_spec.rb +233 -0
- data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
- data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
- metadata +220 -0
@@ -0,0 +1,212 @@
|
|
1
|
+
require "librarian/dependency"
|
2
|
+
|
3
|
+
describe Librarian::Dependency do
|
4
|
+
|
5
|
+
describe "validations" do
|
6
|
+
|
7
|
+
context "when the name is blank" do
|
8
|
+
it "raises" do
|
9
|
+
expect { described_class.new("", [], nil) }.
|
10
|
+
to raise_error(ArgumentError, %{name ("") must be sensible})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when the name has leading whitespace" do
|
15
|
+
it "raises" do
|
16
|
+
expect { described_class.new(" the-name", [], nil) }.
|
17
|
+
to raise_error(ArgumentError, %{name (" the-name") must be sensible})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when the name has trailing whitespace" do
|
22
|
+
it "raises" do
|
23
|
+
expect { described_class.new("the-name ", [], nil) }.
|
24
|
+
to raise_error(ArgumentError, %{name ("the-name ") must be sensible})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when the name is a single character" do
|
29
|
+
it "passes" do
|
30
|
+
described_class.new("R", [], nil)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#consistent_with?" do
|
37
|
+
def req(s) described_class::Requirement.new(s) end
|
38
|
+
def self.assert_consistent(a, b)
|
39
|
+
/^(.+):(\d+):in `(.+)'$/ =~ caller.first
|
40
|
+
line = $2.to_i
|
41
|
+
|
42
|
+
title = "is consistent with #{a.inspect} and #{b.inspect}"
|
43
|
+
module_eval <<-CODE, __FILE__, line
|
44
|
+
it #{title.inspect} do
|
45
|
+
a, b = req(#{a.inspect}), req(#{b.inspect})
|
46
|
+
expect(a).to be_consistent_with(b)
|
47
|
+
expect(a).to_not be_inconsistent_with(b)
|
48
|
+
expect(b).to be_consistent_with(a)
|
49
|
+
expect(b).to_not be_inconsistent_with(a)
|
50
|
+
end
|
51
|
+
CODE
|
52
|
+
end
|
53
|
+
def self.refute_consistent(a, b)
|
54
|
+
/^(.+):(\d+):in `(.+)'$/ =~ caller.first
|
55
|
+
line = $2.to_i
|
56
|
+
|
57
|
+
title = "is inconsistent with #{a.inspect} and #{b.inspect}"
|
58
|
+
module_eval <<-CODE, __FILE__, line
|
59
|
+
it #{title.inspect} do
|
60
|
+
a, b = req(#{a.inspect}), req(#{b.inspect})
|
61
|
+
expect(a).to_not be_consistent_with(b)
|
62
|
+
expect(a).to be_inconsistent_with(b)
|
63
|
+
expect(b).to_not be_consistent_with(a)
|
64
|
+
expect(b).to be_inconsistent_with(a)
|
65
|
+
end
|
66
|
+
CODE
|
67
|
+
end
|
68
|
+
|
69
|
+
# = =
|
70
|
+
assert_consistent "3", "3"
|
71
|
+
refute_consistent "3", "4"
|
72
|
+
refute_consistent "3", "0"
|
73
|
+
refute_consistent "0", "3"
|
74
|
+
|
75
|
+
# = !=
|
76
|
+
assert_consistent "3", "!= 4"
|
77
|
+
assert_consistent "3", "!= 0"
|
78
|
+
refute_consistent "3", "!= 3"
|
79
|
+
|
80
|
+
# = >
|
81
|
+
assert_consistent "3", "> 2"
|
82
|
+
refute_consistent "3", "> 3"
|
83
|
+
refute_consistent "3", "> 4"
|
84
|
+
|
85
|
+
# = <
|
86
|
+
assert_consistent "3", "< 4"
|
87
|
+
refute_consistent "3", "< 3"
|
88
|
+
refute_consistent "3", "< 2"
|
89
|
+
|
90
|
+
# = >=
|
91
|
+
assert_consistent "3", ">= 2"
|
92
|
+
assert_consistent "3", ">= 3"
|
93
|
+
refute_consistent "3", ">= 4"
|
94
|
+
|
95
|
+
# = <=
|
96
|
+
assert_consistent "3", "<= 4"
|
97
|
+
assert_consistent "3", "<= 3"
|
98
|
+
refute_consistent "3", "<= 2"
|
99
|
+
|
100
|
+
# = ~>
|
101
|
+
assert_consistent "3.4.1", "~> 3.4.1"
|
102
|
+
assert_consistent "3.4.2", "~> 3.4.1"
|
103
|
+
refute_consistent "3.4", "~> 3.4.1"
|
104
|
+
refute_consistent "3.5", "~> 3.4.1"
|
105
|
+
|
106
|
+
# != !=
|
107
|
+
assert_consistent "!= 3", "!= 3"
|
108
|
+
assert_consistent "!= 3", "!= 4"
|
109
|
+
|
110
|
+
# != >
|
111
|
+
assert_consistent "!= 3", "> 2"
|
112
|
+
assert_consistent "!= 3", "> 3"
|
113
|
+
assert_consistent "!= 3", "> 4"
|
114
|
+
|
115
|
+
# != <
|
116
|
+
assert_consistent "!= 3", "< 2"
|
117
|
+
assert_consistent "!= 3", "< 3"
|
118
|
+
assert_consistent "!= 3", "< 4"
|
119
|
+
|
120
|
+
# != >=
|
121
|
+
assert_consistent "!= 3", ">= 2"
|
122
|
+
assert_consistent "!= 3", ">= 3"
|
123
|
+
assert_consistent "!= 3", ">= 4"
|
124
|
+
|
125
|
+
# != <=
|
126
|
+
assert_consistent "!= 3", "<= 2"
|
127
|
+
assert_consistent "!= 3", "<= 3"
|
128
|
+
assert_consistent "!= 3", "<= 4"
|
129
|
+
|
130
|
+
# != ~>
|
131
|
+
assert_consistent "!= 3.4.1", "~> 3.4.1"
|
132
|
+
assert_consistent "!= 3.4.2", "~> 3.4.1"
|
133
|
+
assert_consistent "!= 3.5", "~> 3.4.1"
|
134
|
+
|
135
|
+
# > >
|
136
|
+
assert_consistent "> 3", "> 2"
|
137
|
+
assert_consistent "> 3", "> 3"
|
138
|
+
assert_consistent "> 3", "> 4"
|
139
|
+
|
140
|
+
# > <
|
141
|
+
assert_consistent "> 3", "< 4"
|
142
|
+
refute_consistent "> 3", "< 3"
|
143
|
+
refute_consistent "> 3", "< 2"
|
144
|
+
|
145
|
+
# > >=
|
146
|
+
assert_consistent "> 3", ">= 2"
|
147
|
+
assert_consistent "> 3", ">= 3"
|
148
|
+
assert_consistent "> 3", ">= 4"
|
149
|
+
|
150
|
+
# > <=
|
151
|
+
assert_consistent "> 3", "<= 4"
|
152
|
+
refute_consistent "> 3", "<= 3"
|
153
|
+
refute_consistent "> 3", "<= 2"
|
154
|
+
|
155
|
+
# > ~>
|
156
|
+
assert_consistent "> 3.3", "~> 3.4.1"
|
157
|
+
assert_consistent "> 3.4.1", "~> 3.4.1"
|
158
|
+
assert_consistent "> 3.4.2", "~> 3.4.1"
|
159
|
+
refute_consistent "> 3.5", "~> 3.4.1"
|
160
|
+
|
161
|
+
# < <
|
162
|
+
assert_consistent "< 3", "< 2"
|
163
|
+
assert_consistent "< 3", "< 3"
|
164
|
+
assert_consistent "< 3", "< 4"
|
165
|
+
|
166
|
+
# < >=
|
167
|
+
assert_consistent "< 3", ">= 2"
|
168
|
+
refute_consistent "< 3", ">= 3"
|
169
|
+
refute_consistent "< 3", ">= 4"
|
170
|
+
|
171
|
+
# < <=
|
172
|
+
assert_consistent "< 3", "<= 2"
|
173
|
+
assert_consistent "< 3", "<= 3"
|
174
|
+
assert_consistent "< 3", "<= 4"
|
175
|
+
|
176
|
+
# >= >=
|
177
|
+
assert_consistent ">= 3", ">= 2"
|
178
|
+
assert_consistent ">= 3", ">= 3"
|
179
|
+
assert_consistent ">= 3", ">= 4"
|
180
|
+
|
181
|
+
# >= <=
|
182
|
+
assert_consistent ">= 3", "<= 4"
|
183
|
+
assert_consistent ">= 3", "<= 3"
|
184
|
+
refute_consistent ">= 3", "<= 2"
|
185
|
+
|
186
|
+
# >= ~>
|
187
|
+
assert_consistent ">= 3.3", "~> 3.4.1"
|
188
|
+
assert_consistent ">= 3.4.1", "~> 3.4.1"
|
189
|
+
assert_consistent ">= 3.4.2", "~> 3.4.1"
|
190
|
+
refute_consistent ">= 3.5", "~> 3.4.1"
|
191
|
+
|
192
|
+
# <= <=
|
193
|
+
assert_consistent "<= 3", "<= 2"
|
194
|
+
assert_consistent "<= 3", "<= 3"
|
195
|
+
assert_consistent "<= 3", "<= 4"
|
196
|
+
|
197
|
+
# <= ~>
|
198
|
+
assert_consistent "<= 3.5", "~> 3.4.1"
|
199
|
+
assert_consistent "<= 3.4.1", "~> 3.4.1"
|
200
|
+
assert_consistent "<= 3.4.2", "~> 3.4.1"
|
201
|
+
refute_consistent "<= 3.3", "~> 3.4.1"
|
202
|
+
|
203
|
+
# ~> ~>
|
204
|
+
assert_consistent "~> 3.4.1", "~> 3.4.1"
|
205
|
+
assert_consistent "~> 3.4.2", "~> 3.4.1"
|
206
|
+
assert_consistent "~> 3.3", "~> 3.4.1"
|
207
|
+
refute_consistent "~> 3.3.3", "~> 3.4.1"
|
208
|
+
refute_consistent "~> 3.5", "~> 3.4.1"
|
209
|
+
refute_consistent "~> 3.5.4", "~> 3.4.1"
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'librarian'
|
2
|
+
require 'librarian/mock'
|
3
|
+
|
4
|
+
module Librarian
|
5
|
+
module Mock
|
6
|
+
|
7
|
+
describe Dsl do
|
8
|
+
|
9
|
+
let(:env) { Environment.new }
|
10
|
+
|
11
|
+
context "a single source and a single dependency with a blank name" do
|
12
|
+
it "should not not run with a blank name" do
|
13
|
+
expect do
|
14
|
+
env.dsl do
|
15
|
+
src 'source-1'
|
16
|
+
dep ''
|
17
|
+
end
|
18
|
+
end.to raise_error(ArgumentError, %{name ("") must be sensible})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "a simple specfile - a single source, a single dependency, no transitive dependencies" do
|
23
|
+
|
24
|
+
it "should run with a hash source" do
|
25
|
+
spec = env.dsl do
|
26
|
+
dep 'dependency-1',
|
27
|
+
:src => 'source-1'
|
28
|
+
end
|
29
|
+
spec.dependencies.should_not be_empty
|
30
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
31
|
+
spec.dependencies.first.source.name.should == 'source-1'
|
32
|
+
spec.sources.should be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should run with a shortcut source" do
|
36
|
+
spec = env.dsl do
|
37
|
+
dep 'dependency-1',
|
38
|
+
:source => :a
|
39
|
+
end
|
40
|
+
spec.dependencies.should_not be_empty
|
41
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
42
|
+
spec.dependencies.first.source.name.should == 'source-a'
|
43
|
+
spec.sources.should be_empty
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should run with a block hash source" do
|
47
|
+
spec = env.dsl do
|
48
|
+
source :src => 'source-1' do
|
49
|
+
dep 'dependency-1'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
spec.dependencies.should_not be_empty
|
53
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
54
|
+
spec.dependencies.first.source.name.should == 'source-1'
|
55
|
+
spec.sources.should be_empty
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should run with a block named source" do
|
59
|
+
spec = env.dsl do
|
60
|
+
src 'source-1' do
|
61
|
+
dep 'dependency-1'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
spec.dependencies.should_not be_empty
|
65
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
66
|
+
spec.dependencies.first.source.name.should == 'source-1'
|
67
|
+
spec.sources.should be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should run with a default hash source" do
|
71
|
+
spec = env.dsl do
|
72
|
+
source :src => 'source-1'
|
73
|
+
dep 'dependency-1'
|
74
|
+
end
|
75
|
+
spec.dependencies.should_not be_empty
|
76
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
77
|
+
spec.dependencies.first.source.name.should == 'source-1'
|
78
|
+
spec.sources.should_not be_empty
|
79
|
+
spec.dependencies.first.source.should == spec.sources.first
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should run with a default named source" do
|
83
|
+
spec = env.dsl do
|
84
|
+
src 'source-1'
|
85
|
+
dep 'dependency-1'
|
86
|
+
end
|
87
|
+
spec.dependencies.should_not be_empty
|
88
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
89
|
+
spec.dependencies.first.source.name.should == 'source-1'
|
90
|
+
spec.sources.should_not be_empty
|
91
|
+
spec.dependencies.first.source.should == spec.sources.first
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should run with a default shortcut source" do
|
95
|
+
spec = env.dsl do
|
96
|
+
source :a
|
97
|
+
dep 'dependency-1'
|
98
|
+
end
|
99
|
+
spec.dependencies.should_not be_empty
|
100
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
101
|
+
spec.dependencies.first.source.name.should == 'source-a'
|
102
|
+
spec.sources.should_not be_empty
|
103
|
+
spec.dependencies.first.source.should == spec.sources.first
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should run with a shortcut source hash definition" do
|
107
|
+
spec = env.dsl do
|
108
|
+
source :b, :src => 'source-b'
|
109
|
+
dep 'dependency-1', :source => :b
|
110
|
+
end
|
111
|
+
spec.dependencies.should_not be_empty
|
112
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
113
|
+
spec.dependencies.first.source.name.should == 'source-b'
|
114
|
+
spec.sources.should be_empty
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should run with a shortcut source block definition" do
|
118
|
+
spec = env.dsl do
|
119
|
+
source :b, proc { src 'source-b' }
|
120
|
+
dep 'dependency-1', :source => :b
|
121
|
+
end
|
122
|
+
spec.dependencies.should_not be_empty
|
123
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
124
|
+
spec.dependencies.first.source.name.should == 'source-b'
|
125
|
+
spec.sources.should be_empty
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should run with a default shortcut source hash definition" do
|
129
|
+
spec = env.dsl do
|
130
|
+
source :b, :src => 'source-b'
|
131
|
+
source :b
|
132
|
+
dep 'dependency-1'
|
133
|
+
end
|
134
|
+
spec.dependencies.should_not be_empty
|
135
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
136
|
+
spec.dependencies.first.source.name.should == 'source-b'
|
137
|
+
spec.sources.should_not be_empty
|
138
|
+
spec.sources.first.name.should == 'source-b'
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should run with a default shortcut source block definition" do
|
142
|
+
spec = env.dsl do
|
143
|
+
source :b, proc { src 'source-b' }
|
144
|
+
source :b
|
145
|
+
dep 'dependency-1'
|
146
|
+
end
|
147
|
+
spec.dependencies.should_not be_empty
|
148
|
+
spec.dependencies.first.name.should == 'dependency-1'
|
149
|
+
spec.dependencies.first.source.name.should == 'source-b'
|
150
|
+
spec.sources.should_not be_empty
|
151
|
+
spec.sources.first.name.should == 'source-b'
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
context "validating source options" do
|
157
|
+
|
158
|
+
it "should raise when given unrecognized optiosn options" do
|
159
|
+
expect do
|
160
|
+
env.dsl do
|
161
|
+
dep 'dependency-1',
|
162
|
+
:src => 'source-1',
|
163
|
+
:huh => 'yikes'
|
164
|
+
end
|
165
|
+
end.to raise_error(Error, %{unrecognized options: huh})
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require "librarian/environment"
|
2
|
+
|
3
|
+
require "support/with_env_macro"
|
4
|
+
|
5
|
+
module Librarian
|
6
|
+
describe Environment do
|
7
|
+
include WithEnvMacro
|
8
|
+
|
9
|
+
let(:env) { described_class.new }
|
10
|
+
|
11
|
+
describe "#http_proxy_uri" do
|
12
|
+
|
13
|
+
context "sanity" do
|
14
|
+
with_env "http_proxy" => nil
|
15
|
+
|
16
|
+
it "should have a nil http proxy uri" do
|
17
|
+
env.http_proxy_uri.should be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with a complex proxy" do
|
22
|
+
with_env "http_proxy" => "admin:secret@example.com"
|
23
|
+
|
24
|
+
it "should have the expcted http proxy uri" do
|
25
|
+
env.http_proxy_uri.should == URI("http://admin:secret@example.com")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have the expected host" do
|
29
|
+
env.http_proxy_uri.host.should == "example.com"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have the expected user" do
|
33
|
+
env.http_proxy_uri.user.should == "admin"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have the expected password" do
|
37
|
+
env.http_proxy_uri.password.should == "secret"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with a split proxy" do
|
42
|
+
with_env "http_proxy" => "example.com",
|
43
|
+
"http_proxy_user" => "admin",
|
44
|
+
"http_proxy_pass" => "secret"
|
45
|
+
|
46
|
+
it "should have the expcted http proxy uri" do
|
47
|
+
env.http_proxy_uri.should == URI("http://admin:secret@example.com")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#net_http_class" do
|
54
|
+
let(:proxied_host) { "www.example.com" }
|
55
|
+
context "sanity" do
|
56
|
+
with_env "http_proxy" => nil
|
57
|
+
|
58
|
+
it "should have the normal class" do
|
59
|
+
env.net_http_class(proxied_host).should be Net::HTTP
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not be marked as a proxy class" do
|
63
|
+
env.net_http_class(proxied_host).should_not be_proxy_class
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "with a complex proxy" do
|
68
|
+
with_env "http_proxy" => "admin:secret@example.com"
|
69
|
+
|
70
|
+
it "should not by marked as a proxy class for localhost" do
|
71
|
+
env.net_http_class('localhost').should_not be_proxy_class
|
72
|
+
end
|
73
|
+
it "should not have the normal class" do
|
74
|
+
env.net_http_class(proxied_host).should_not be Net::HTTP
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should have a subclass the normal class" do
|
78
|
+
env.net_http_class(proxied_host).should < Net::HTTP
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should be marked as a proxy class" do
|
82
|
+
env.net_http_class(proxied_host).should be_proxy_class
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should have the expected proxy attributes" do
|
86
|
+
http = env.net_http_class(proxied_host).new("www.kernel.org")
|
87
|
+
expected_attributes = {
|
88
|
+
"host" => env.http_proxy_uri.host,
|
89
|
+
"port" => env.http_proxy_uri.port,
|
90
|
+
"user" => env.http_proxy_uri.user,
|
91
|
+
"pass" => env.http_proxy_uri.password
|
92
|
+
}
|
93
|
+
actual_attributes = {
|
94
|
+
"host" => http.proxy_address,
|
95
|
+
"port" => http.proxy_port,
|
96
|
+
"user" => http.proxy_user,
|
97
|
+
"pass" => http.proxy_pass,
|
98
|
+
}
|
99
|
+
|
100
|
+
actual_attributes.should == expected_attributes
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
context "with an excluded host" do
|
106
|
+
with_env "http_proxy" => "admin:secret@example.com",
|
107
|
+
"no_proxy" => "no.proxy.com, noproxy.com"
|
108
|
+
|
109
|
+
context "with an exact match" do
|
110
|
+
let(:proxied_host) { "noproxy.com" }
|
111
|
+
|
112
|
+
it "should have the normal class" do
|
113
|
+
env.net_http_class(proxied_host).should be Net::HTTP
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should not be marked as a proxy class" do
|
117
|
+
env.net_http_class(proxied_host).should_not be_proxy_class
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "with a subdomain match" do
|
122
|
+
let(:proxied_host) { "www.noproxy.com" }
|
123
|
+
|
124
|
+
it "should have the normal class" do
|
125
|
+
env.net_http_class(proxied_host).should be Net::HTTP
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should not be marked as a proxy class" do
|
129
|
+
env.net_http_class(proxied_host).should_not be_proxy_class
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "with localhost" do
|
134
|
+
let(:proxied_host) { "localhost" }
|
135
|
+
|
136
|
+
it "should have the normal class" do
|
137
|
+
env.net_http_class(proxied_host).should be Net::HTTP
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should not be marked as a proxy class" do
|
141
|
+
env.net_http_class(proxied_host).should_not be_proxy_class
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "with 127.0.0.1" do
|
146
|
+
let(:proxied_host) { "127.0.0.1" }
|
147
|
+
|
148
|
+
it "should have the normal class" do
|
149
|
+
env.net_http_class(proxied_host).should be Net::HTTP
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should not be marked as a proxy class" do
|
153
|
+
env.net_http_class(proxied_host).should_not be_proxy_class
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context "with a mismatch" do
|
158
|
+
let(:proxied_host) { "www.example.com" }
|
159
|
+
|
160
|
+
it "should have a subclass the normal class" do
|
161
|
+
env.net_http_class(proxied_host).should < Net::HTTP
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should be marked as a proxy class" do
|
165
|
+
env.net_http_class(proxied_host).should be_proxy_class
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|