puppet-blacksmith 6.1.1 → 7.0.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.
@@ -1,341 +0,0 @@
1
- {
2
- "slug": "maestrodev/test/1.0.5165510",
3
- "_links": {
4
- "self": {
5
- "href": null
6
- }
7
- },
8
- "id": 11099,
9
- "module": {
10
- "id": 933,
11
- "name": "test",
12
- "homepage_url": "http://github.com/maestrodev/puppet-test",
13
- "source_url": "http://github.com/maestrodev/puppetforge",
14
- "issues_url": "",
15
- "commit_feed_url": "",
16
- "owner": {
17
- "id": 1185,
18
- "username": "maestrodev",
19
- "email": "info@maestrodev.com",
20
- "display_name": "MaestroDev",
21
- "release_count": 377,
22
- "module_count": 32,
23
- "created_at": "2012-05-24T05:37:32-07:00",
24
- "updated_at": "2012-11-09T22:11:21-08:00"
25
- },
26
- "tags": [],
27
- "downloads": 30409,
28
- "created_at": "2013-01-25T12:53:13-08:00",
29
- "updated_at": "2014-09-18T10:47:45-07:00",
30
- "current_release": {
31
- "id": 11096,
32
- "version": "1.0.8466228",
33
- "metadata": {
34
- "name": "maestrodev-test",
35
- "version": "1.0.8466228",
36
- "source": "http://github.com/maestrodev/puppet-test",
37
- "author": "maestrodev",
38
- "license": "Apache License, Version 2.0",
39
- "summary": "Testing Puppet module operations",
40
- "description": "Testing Puppet module operations",
41
- "project_page": "http://github.com/maestrodev/puppet-test",
42
- "dependencies": [],
43
- "types": [],
44
- "checksums": {}
45
- },
46
- "downloads": 0,
47
- "file_size": 375,
48
- "file_md5": "c8e550ca457983c92296eb99180b7052",
49
- "created_at": "2014-09-18T09:48:56-07:00",
50
- "updated_at": "2014-09-18T09:48:56-07:00",
51
- "readme": null,
52
- "changelog": null,
53
- "license": null
54
- },
55
- "releases": [
56
- {
57
- "slug": "maestrodev-test-1.0.8466228",
58
- "key": "1.0.8466228",
59
- "_links": {
60
- "self": {
61
- "href": null
62
- }
63
- }
64
- },
65
- {
66
- "slug": "maestrodev-test-1.0.7876831",
67
- "key": "1.0.7876831",
68
- "_links": {
69
- "self": {
70
- "href": null
71
- }
72
- }
73
- },
74
- {
75
- "slug": "maestrodev-test-1.0.5165510",
76
- "key": "1.0.5165510",
77
- "_links": {
78
- "self": {
79
- "href": null
80
- }
81
- }
82
- },
83
- {
84
- "slug": "maestrodev-test-1.0.3620912",
85
- "key": "1.0.3620912",
86
- "_links": {
87
- "self": {
88
- "href": null
89
- }
90
- }
91
- },
92
- {
93
- "slug": "maestrodev-test-1.0.26",
94
- "key": "1.0.26",
95
- "_links": {
96
- "self": {
97
- "href": null
98
- }
99
- }
100
- },
101
- {
102
- "slug": "maestrodev-test-1.0.25",
103
- "key": "1.0.25",
104
- "_links": {
105
- "self": {
106
- "href": null
107
- }
108
- }
109
- },
110
- {
111
- "slug": "maestrodev-test-1.0.24",
112
- "key": "1.0.24",
113
- "_links": {
114
- "self": {
115
- "href": null
116
- }
117
- }
118
- },
119
- {
120
- "slug": "maestrodev-test-1.0.23",
121
- "key": "1.0.23",
122
- "_links": {
123
- "self": {
124
- "href": null
125
- }
126
- }
127
- },
128
- {
129
- "slug": "maestrodev-test-1.0.22",
130
- "key": "1.0.22",
131
- "_links": {
132
- "self": {
133
- "href": null
134
- }
135
- }
136
- },
137
- {
138
- "slug": "maestrodev-test-1.0.21",
139
- "key": "1.0.21",
140
- "_links": {
141
- "self": {
142
- "href": null
143
- }
144
- }
145
- },
146
- {
147
- "slug": "maestrodev-test-1.0.19",
148
- "key": "1.0.19",
149
- "_links": {
150
- "self": {
151
- "href": null
152
- }
153
- }
154
- },
155
- {
156
- "slug": "maestrodev-test-1.0.18",
157
- "key": "1.0.18",
158
- "_links": {
159
- "self": {
160
- "href": null
161
- }
162
- }
163
- },
164
- {
165
- "slug": "maestrodev-test-1.0.16",
166
- "key": "1.0.16",
167
- "_links": {
168
- "self": {
169
- "href": null
170
- }
171
- }
172
- },
173
- {
174
- "slug": "maestrodev-test-1.0.15",
175
- "key": "1.0.15",
176
- "_links": {
177
- "self": {
178
- "href": null
179
- }
180
- }
181
- },
182
- {
183
- "slug": "maestrodev-test-1.0.14",
184
- "key": "1.0.14",
185
- "_links": {
186
- "self": {
187
- "href": null
188
- }
189
- }
190
- },
191
- {
192
- "slug": "maestrodev-test-1.0.13",
193
- "key": "1.0.13",
194
- "_links": {
195
- "self": {
196
- "href": null
197
- }
198
- }
199
- },
200
- {
201
- "slug": "maestrodev-test-1.0.12",
202
- "key": "1.0.12",
203
- "_links": {
204
- "self": {
205
- "href": null
206
- }
207
- }
208
- },
209
- {
210
- "slug": "maestrodev-test-1.0.11",
211
- "key": "1.0.11",
212
- "_links": {
213
- "self": {
214
- "href": null
215
- }
216
- }
217
- },
218
- {
219
- "slug": "maestrodev-test-1.0.10",
220
- "key": "1.0.10",
221
- "_links": {
222
- "self": {
223
- "href": null
224
- }
225
- }
226
- },
227
- {
228
- "slug": "maestrodev-test-1.0.9",
229
- "key": "1.0.9",
230
- "_links": {
231
- "self": {
232
- "href": null
233
- }
234
- }
235
- },
236
- {
237
- "slug": "maestrodev-test-1.0.8",
238
- "key": "1.0.8",
239
- "_links": {
240
- "self": {
241
- "href": null
242
- }
243
- }
244
- },
245
- {
246
- "slug": "maestrodev-test-1.0.7",
247
- "key": "1.0.7",
248
- "_links": {
249
- "self": {
250
- "href": null
251
- }
252
- }
253
- },
254
- {
255
- "slug": "maestrodev-test-1.0.6",
256
- "key": "1.0.6",
257
- "_links": {
258
- "self": {
259
- "href": null
260
- }
261
- }
262
- },
263
- {
264
- "slug": "maestrodev-test-1.0.5",
265
- "key": "1.0.5",
266
- "_links": {
267
- "self": {
268
- "href": null
269
- }
270
- }
271
- },
272
- {
273
- "slug": "maestrodev-test-1.0.4",
274
- "key": "1.0.4",
275
- "_links": {
276
- "self": {
277
- "href": null
278
- }
279
- }
280
- },
281
- {
282
- "slug": "maestrodev-test-1.0.3",
283
- "key": "1.0.3",
284
- "_links": {
285
- "self": {
286
- "href": null
287
- }
288
- }
289
- },
290
- {
291
- "slug": "maestrodev-test-1.0.2",
292
- "key": "1.0.2",
293
- "_links": {
294
- "self": {
295
- "href": null
296
- }
297
- }
298
- },
299
- {
300
- "slug": "maestrodev-test-1.0.1",
301
- "key": "1.0.1",
302
- "_links": {
303
- "self": {
304
- "href": null
305
- }
306
- }
307
- },
308
- {
309
- "slug": "maestrodev-test-1.0.0",
310
- "key": "1.0.0",
311
- "_links": {
312
- "self": {
313
- "href": null
314
- }
315
- }
316
- }
317
- ]
318
- },
319
- "version": "1.0.5165510",
320
- "metadata": {
321
- "name": "maestrodev-test",
322
- "version": "1.0.5165510",
323
- "source": "http://github.com/maestrodev/puppet-test",
324
- "author": "maestrodev",
325
- "license": "Apache License, Version 2.0",
326
- "summary": "Testing Puppet module operations",
327
- "description": "Testing Puppet module operations",
328
- "project_page": "http://github.com/maestrodev/puppet-test",
329
- "dependencies": [],
330
- "types": [],
331
- "checksums": {}
332
- },
333
- "downloads": 0,
334
- "file_size": 374,
335
- "file_md5": "181a8a83140de2bac9475f5c0142079a",
336
- "created_at": "2014-09-18T10:47:45-07:00",
337
- "updated_at": "2014-09-18T10:47:45-07:00",
338
- "readme": null,
339
- "changelog": null,
340
- "license": null
341
- }
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- require_relative 'forge_shared'
3
- require 'fileutils'
4
-
5
- # Run tests against the real Forge staging API
6
- describe 'Blacksmith::Forge', :live => true do
7
- include_context 'forge'
8
- let(:username) { nil }
9
-
10
- describe 'push' do
11
- before { create_tarball }
12
- include_examples 'forge_push'
13
- end
14
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
- require 'fileutils'
3
-
4
- RSpec.shared_examples 'forge_push' do |collection_class|
5
- it "should push the module" do
6
- subject.push!(module_name, package)
7
- end
8
- end
9
-
10
- RSpec.shared_context "forge" do
11
- subject { Blacksmith::Forge.new(username, password, forge) }
12
- let(:username) { 'johndoe' }
13
- let(:password) { 'secret' }
14
- let(:forge) { "https://forgestagingapi.puppetlabs.com" }
15
- let(:module_name) { "test" }
16
- let(:version) { "1.0.0" }
17
- let(:module_name) { "maestrodev-test" }
18
- let(:spec_data) { File.join(__dir__, '..', 'data') }
19
- let(:spec_module) { File.join(spec_data, module_name) }
20
- let(:target) { File.expand_path(File.join(__dir__, "..", "..", "pkg", module_name)) }
21
- let(:package) { "#{target}.tar.gz" }
22
-
23
- let(:headers) { { 'User-Agent' => %r{^Blacksmith/#{Blacksmith::VERSION} Ruby/.* \(.*\)$} } }
24
-
25
- def create_tarball
26
- FileUtils.mkdir_p(target)
27
-
28
- # update version
29
- f = File.join(spec_module, "metadata.json")
30
- metadata = JSON.parse File.read(f)
31
- metadata['version'] = "1.0.#{Random.rand(9999999)}"
32
- File.open(File.join(target, "metadata.json"),"w") do |file|
33
- file.write(JSON.pretty_generate(metadata))
34
- end
35
- `cd '#{target}/..'; tar -czf #{module_name}.tar.gz #{module_name}`
36
- end
37
- end
@@ -1,122 +0,0 @@
1
- require 'spec_helper'
2
- require_relative 'forge_shared'
3
- require 'fileutils'
4
- require 'webmock/rspec'
5
-
6
- describe 'Blacksmith::Forge' do
7
- include_context 'forge'
8
-
9
- describe 'resolving credentials' do
10
- before do
11
- allow(Dir).to receive(:pwd) { '/home/mr_puppet/puppet-some-module' }
12
- allow(File).to receive(:expand_path).with('~/.puppetforge.yml') { '/home/mr_puppet/.puppetforge.yml' }
13
- allow(File).to receive(:expand_path).with(/credentials.yml/) { '/home/mr_puppet/puppet-blacksmith/credentials.yml' }
14
- allow(YAML).to receive(:load_file).with('/home/mr_puppet/puppet-blacksmith/credentials.yml') { {
15
- "client_id" => "b93eb708fd942cfc7b4ed71db6ce219b814954619dbe537ddfd208584e8cff8d",
16
- "client_secret" => "216648059ad4afec3e4d77bd9e67817c095b2dcf94cdec18ac3d00584f863180",
17
- } }
18
- end
19
-
20
- it 'prefers env vars to file values' do
21
- stubbed_forge_password = 'asdf1234'
22
-
23
- allow(File).to receive(:exists?).
24
- with('/home/mr_puppet/puppet-some-module/.puppetforge.yml').
25
- and_return(false)
26
- allow(File).to receive(:exists?).
27
- with('/home/mr_puppet/.puppetforge.yml').
28
- and_return(true)
29
- allow(YAML).to receive(:load_file).
30
- with('/home/mr_puppet/.puppetforge.yml').
31
- and_return({'username' => username,
32
- 'password' => password})
33
- allow(ENV).to receive(:[]).
34
- with(any_args)
35
- allow(ENV).to receive(:[]).
36
- with('BLACKSMITH_FORGE_PASSWORD').
37
- and_return(stubbed_forge_password)
38
-
39
- forge = Blacksmith::Forge.new()
40
-
41
- expect(forge.url).to eq(Blacksmith::Forge::PUPPETLABS_FORGE)
42
- expect(forge.password).to eq(stubbed_forge_password)
43
- expect(forge.username).to eq(username)
44
- end
45
-
46
- context 'when the credentials values are unset' do
47
- it "should raise an error" do
48
- expect { foo = Blacksmith::Forge.new(nil, password, forge) }.to raise_error(/Could not find Puppet Forge credentials/)
49
- end
50
- end
51
-
52
- it 'loads credentials from home dir' do
53
- allow(File).to receive(:exists?).with('/home/mr_puppet/puppet-some-module/.puppetforge.yml') { false }
54
- allow(File).to receive(:exists?).with('/home/mr_puppet/.puppetforge.yml') { true }
55
- allow(YAML).to receive(:load_file).with('/home/mr_puppet/.puppetforge.yml') { {'username'=> 'puppet-user'} }
56
-
57
- subject = Blacksmith::Forge.new(nil, password, forge)
58
- expect(subject.username).to eq('puppet-user')
59
- end
60
-
61
- it 'loads credentials from project dir' do
62
- allow(File).to receive(:exists?).with('/home/mr_puppet/puppet-some-module/.puppetforge.yml') { true }
63
- allow(File).to receive(:exists?).with('/home/mr_puppet/.puppetforge.yml') { true }
64
- allow(YAML).to receive(:load_file).with('/home/mr_puppet/puppet-some-module/.puppetforge.yml') { {'username'=> 'puppet-other-user'} }
65
-
66
- subject = Blacksmith::Forge.new(nil, password, forge)
67
- expect(subject.username).to eq('puppet-other-user')
68
- end
69
-
70
- end
71
-
72
- describe 'push' do
73
- let(:login_body) {{
74
- "client_id"=>"b93eb708fd942cfc7b4ed71db6ce219b814954619dbe537ddfd208584e8cff8d",
75
- "client_secret"=>"216648059ad4afec3e4d77bd9e67817c095b2dcf94cdec18ac3d00584f863180",
76
- "grant_type"=>"password",
77
- "password"=>"secret",
78
- "username"=>"johndoe"
79
- }}
80
-
81
- before { create_tarball }
82
-
83
- context "when using username and password" do
84
- before do
85
- stub_request(:post, "#{forge}/oauth/token").with(
86
- :body => login_body,
87
- :headers => headers
88
- ).to_return(
89
- :status => 200,
90
- :body => {"access_token" => "e52f78b62e97cb8d8db6659a73aa522cca0f5c74d4714e0ed0bdd10000000000", "scope" =>""}.to_json,
91
- :headers => {})
92
-
93
- stub_request(:post, "#{forge}/v2/releases").with(
94
- :headers => headers.merge({'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer e52f78b62e97cb8d8db6659a73aa522cca0f5c74d4714e0ed0bdd10000000000', 'Content-Type'=>%r{\Amultipart/form-data;}})
95
- ) { |request |
96
- request.body =~ %r{Content-Disposition: form-data; name=\"file\"; filename=\"maestrodev-test.tar.gz\"\r\nContent-Type: application/gzip}
97
- }.to_return(:status => 200, :body => File.read(File.join(spec_data, "response.json")), :headers => {})
98
-
99
- end
100
-
101
- include_examples 'forge_push'
102
- end
103
-
104
- context "when using bad credentials" do
105
- before do
106
- stub_request(:post, "#{forge}/oauth/token").with(
107
- :body => login_body,
108
- :headers => headers
109
- ).to_return(
110
- :status => 400,
111
- :body => {"error"=>"invalid_grant","error_description"=>"Username/password do not match"}.to_json,
112
- :headers => {})
113
- end
114
-
115
- it "should push the module" do
116
- expect { subject.push!(module_name, package) }.to raise_error(Blacksmith::Error, "Error login to the forge #{forge} as #{username} [400 Bad Request]: {\"error\":\"invalid_grant\",\"error_description\":\"Username/password do not match\"}")
117
- end
118
-
119
- end
120
- end
121
- end
122
-
@@ -1,132 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Blacksmith::Git' do
4
-
5
- subject { Blacksmith::Git.new(path) }
6
- let(:path) { File.expand_path(File.join(__dir__, '../../tmp/git_test')) }
7
- let(:version) { '1.0.0' }
8
- let(:metadata_file) { "metadata.json" }
9
-
10
- before do
11
- FileUtils.rm_rf path
12
- FileUtils.mkdir_p(path)
13
- `git init '#{path}'`
14
- FileUtils.touch(File.join(path, metadata_file))
15
- `cd '#{path}' && git add #{metadata_file} && git commit -am "Init"`
16
- end
17
-
18
- shared_examples_for :git do
19
- describe 'has_tag?' do
20
- context 'with a tag' do
21
- before { subject.tag!(version) }
22
- it { expect(subject.has_tag?("v#{version}")).to be true }
23
- end
24
-
25
- context 'with a partial match' do
26
- before { subject.tag!(version) }
27
- it { expect(subject.has_tag?(version)).to be false }
28
- end
29
-
30
- context 'without a tag' do
31
- it { expect(subject.has_tag?('something')).to be false }
32
- end
33
- end
34
-
35
- describe 'has_tag?' do
36
- context 'with a tag' do
37
- before { subject.tag!(version) }
38
- it { expect(subject.has_version_tag?(version)).to be true }
39
- end
40
-
41
- context 'without a tag' do
42
- it { expect(subject.has_version_tag?('something')).to be false }
43
- end
44
- end
45
-
46
- describe 'tag!' do
47
- context 'basic tag' do
48
- before { subject.tag!(version) }
49
- it "should have the tag" do
50
- out = `cd '#{path}' && git tag`
51
- expect(out.chomp).to match(/^v1.0.0$/)
52
- end
53
- end
54
-
55
- context 'signed tag without pattern' do
56
- before do
57
- subject.tag_message_pattern = nil
58
- subject.tag_sign = true
59
- end
60
-
61
- it { expect { subject.tag!(version) }.to raise_error(Blacksmith::Error, /Signed tags require messages/)}
62
- end
63
-
64
- context 'signed tag with pattern' do
65
- before do
66
- subject.tag_message_pattern = 'Version %s'
67
- subject.tag_sign = true
68
- allow(subject).to receive(:exec_git).with(['tag', 'v1.0.0', '-m', 'Version 1.0.0', '-s']).and_return(true)
69
- end
70
-
71
- it { expect(subject.tag!(version)).to be true }
72
- end
73
- end
74
-
75
- describe 'commit_modulefile' do
76
- before do
77
- open(File.join(subject.path, metadata_file), 'a') { |f|
78
- f.puts "more text"
79
- }
80
- end
81
-
82
- it "should commit the metadata file" do
83
- expect(subject.commit_modulefile!(version)).to match(/\[blacksmith\] Bump version to #{version}/)
84
- end
85
- end
86
-
87
- describe 'exec_git' do
88
- let(:cmd) { ['log'] }
89
- let(:stdin) { nil }
90
- let(:stdout) { '' }
91
- let(:stderr) { '' }
92
- let(:exit_code) { double('exit_code', :success? => true) }
93
- let(:wait_thr) { double('wait_thr', :value => exit_code) }
94
-
95
- context 'when git succeeds' do
96
- before do
97
- allow(Open3).to receive(:popen3). \
98
- with('git', '--git-dir', File.join(path, '.git'), '--work-tree', path, *cmd). \
99
- and_yield(nil, double(:read => stdout), double(:read => stderr), wait_thr)
100
- expect { subject.send(:exec_git, cmd) }.to_not raise_error
101
- end
102
-
103
- context 'when stderr is empty' do
104
- it {}
105
- end
106
-
107
- context 'when stderr is not empty' do
108
- let(:stderr) { 'some error' }
109
- it {}
110
- end
111
-
112
- end
113
-
114
- context 'when git fails' do
115
- # this spec fails on jruby, can't detect exit code of script
116
- context 'when stderr is empty' do
117
- let(:cmd) { [] } # exits with 1
118
- it { expect { subject.send(:exec_git, cmd) }.to raise_error(Blacksmith::Error, /^Command .* failed with exit status.*1.*$/) }
119
- end
120
-
121
- context 'when stderr is not empty' do
122
- let(:cmd) { ["help", "xxxx"] } # exits with 1 and prints to stdout
123
- it { expect { subject.send(:exec_git, cmd) }.to raise_error(Blacksmith::Error, /No manual entry for gitxxx/) }
124
- end
125
- end
126
- end
127
- end
128
-
129
- context "Using metadata.json" do
130
- it_behaves_like :git
131
- end
132
- end