puppet-blacksmith 2.3.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/puppet_blacksmith/credentials.yml +3 -0
- data/lib/puppet_blacksmith/forge.rb +29 -32
- data/lib/puppet_blacksmith/git.rb +4 -2
- data/lib/puppet_blacksmith/version.rb +1 -1
- data/spec/data/maestrodev-test/metadata.json +18 -0
- data/spec/data/response.json +341 -0
- data/spec/puppet_blacksmith/forge_spec.rb +38 -23
- data/spec/spec_helper.rb +0 -1
- metadata +8 -21
- data/spec/data/forge_error.html +0 -230
- data/spec/data/maestrodev-ant-1.0.4.tar.gz +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTUzZmNlYWZkNWI0MmUzNjRiMTYwMjJkOTJhMzU0NzVmM2JkMDYxZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTExMDFmY2VlOTNkZGJiZjNiYmE3NjdhNzA2YjVlNmZlZjJiNDZjZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGUzNjg0MGFhYzRjZGExMzU3YzQ0MzViN2RkMDAwNjQ0OTAzYzFhM2NjYjgx
|
10
|
+
ZDMyYWJhMmE1OTAzNDYxMWI2NjQ3M2QwNjliMTFjODBkYWVmNDFmNjFhNDlm
|
11
|
+
OWY1MzQ1Y2JkMzUwZDhhZmFiMmU0ZjMxNDJmYTFjOGJjMjRiODY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDg2ZmUwMDM1NzdiMjNlYWMzYzdmMTgxNGYxZTFkOTg0ZWY1MzA2YzkyZjk1
|
14
|
+
MGVhNzhkNjNjMzA0MzQxMzU2ZTRmNjg3MzFiODgzODMxMWU5OGU3MGVhOGZm
|
15
|
+
YzZhNDhiMzEwMzI0YmNmMTU3NzIwYjkzMmEwZmU2MjlmNGRkYmY=
|
@@ -1,20 +1,25 @@
|
|
1
1
|
require 'rest-client'
|
2
|
-
require 'nokogiri'
|
3
2
|
|
4
3
|
module Blacksmith
|
5
4
|
class Forge
|
6
5
|
|
7
|
-
PUPPETLABS_FORGE = "https://
|
6
|
+
PUPPETLABS_FORGE = "https://forgeapi.puppetlabs.com"
|
7
|
+
HEADERS = { 'User-Agent' => "Blacksmith/#{Blacksmith::VERSION} Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE}; #{RUBY_PLATFORM})" }
|
8
8
|
|
9
|
-
attr_accessor :username, :password
|
9
|
+
attr_accessor :username, :password, :client_id, :client_secret
|
10
10
|
attr_writer :url
|
11
11
|
|
12
12
|
def initialize(username = nil, password = nil, url = nil)
|
13
13
|
self.username = username
|
14
14
|
self.password = password
|
15
|
-
self.url = url
|
16
15
|
RestClient.proxy = ENV['http_proxy']
|
17
16
|
load_credentials_from_file if username.nil?
|
17
|
+
load_client_credentials_from_file
|
18
|
+
self.url = url unless url.nil?
|
19
|
+
if self.url =~ %r{http(s)?://forge.puppetlabs.com}
|
20
|
+
puts "Ignoring url entry in .puppetforge.yml: must point to the api server at #{PUPPETLABS_FORGE}, not the Forge webpage"
|
21
|
+
self.url = PUPPETLABS_FORGE
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
def url
|
@@ -32,36 +37,20 @@ module Blacksmith
|
|
32
37
|
raise Errno::ENOENT, "File does not exist: #{package}" unless File.exists?(package)
|
33
38
|
|
34
39
|
# login to the puppet forge
|
35
|
-
response = RestClient.post(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
}
|
45
|
-
raise Blacksmith::Error, "Failed to login to Puppet Forge: cookies not set correctly" unless response.cookies['auth']
|
46
|
-
|
47
|
-
page = Nokogiri::HTML(response.body)
|
48
|
-
errors = page.css('.failure')
|
49
|
-
raise Blacksmith::Error, "Error uploading module #{package} to Puppet Forge #{username}/#{name}:#{errors.text}" unless errors.empty?
|
40
|
+
response = RestClient.post("#{url}/oauth/token", {
|
41
|
+
'client_id' => client_id,
|
42
|
+
'client_secret' => client_secret,
|
43
|
+
'username' => username,
|
44
|
+
'password' => password,
|
45
|
+
'grant_type' => 'password'
|
46
|
+
}, HEADERS)
|
47
|
+
login_data = JSON.parse(response)
|
48
|
+
access_token = login_data['access_token']
|
50
49
|
|
51
50
|
# upload the file
|
52
|
-
response = RestClient.post("#{url}
|
53
|
-
{:
|
54
|
-
{
|
55
|
-
|response, request, result, &block|
|
56
|
-
if [301, 302, 307].include? response.code
|
57
|
-
response # no need to follow redirects
|
58
|
-
else
|
59
|
-
response.return!(request, result, &block)
|
60
|
-
end
|
61
|
-
}
|
62
|
-
page = Nokogiri::HTML(response.body)
|
63
|
-
errors = page.css('.errors')
|
64
|
-
raise Blacksmith::Error, "Error uploading module #{package} to Puppet Forge #{username}/#{name}:#{errors.text}" unless errors.empty?
|
51
|
+
response = RestClient.post("#{url}/v2/releases",
|
52
|
+
{:file => File.new(package, 'rb')},
|
53
|
+
HEADERS.merge({'Authorization' => "Bearer #{access_token}"}))
|
65
54
|
end
|
66
55
|
|
67
56
|
private
|
@@ -88,5 +77,13 @@ password: mypassword
|
|
88
77
|
end
|
89
78
|
self.url = credentials['url'] if credentials['url']
|
90
79
|
end
|
80
|
+
|
81
|
+
def load_client_credentials_from_file
|
82
|
+
credentials_file = File.expand_path(File.join(__FILE__, "..", "credentials.yml"))
|
83
|
+
credentials = YAML.load_file(credentials_file)
|
84
|
+
self.client_id = credentials['client_id']
|
85
|
+
self.client_secret = credentials['client_secret']
|
86
|
+
end
|
91
87
|
end
|
88
|
+
|
92
89
|
end
|
@@ -42,9 +42,11 @@ module Blacksmith
|
|
42
42
|
exit_status = wait_thr.nil? ? nil : wait_thr.value
|
43
43
|
end
|
44
44
|
if exit_status.nil?
|
45
|
-
raise Blacksmith::Error, err unless err.empty?
|
45
|
+
raise Blacksmith::Error, "Command #{new_cmd} failed with stderr:\n#{err}#{"\nstdout:\n" + out unless out.empty?}" unless err.empty?
|
46
46
|
elsif !exit_status.success?
|
47
|
-
|
47
|
+
msg = err.empty? ? out : err
|
48
|
+
msg = "\n#{msg}" unless msg.empty?
|
49
|
+
raise Blacksmith::Error, "Command #{new_cmd} failed with exit status #{exit_status}#{msg}"
|
48
50
|
end
|
49
51
|
return out
|
50
52
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"name": "maestrodev-test",
|
3
|
+
"version": "",
|
4
|
+
"source": "http://github.com/maestrodev/puppet-test",
|
5
|
+
"author": "maestrodev",
|
6
|
+
"license": "Apache License, Version 2.0",
|
7
|
+
"summary": "Testing Puppet module operations",
|
8
|
+
"description": "Testing Puppet module operations",
|
9
|
+
"project_page": "http://github.com/maestrodev/puppet-test",
|
10
|
+
"dependencies": [
|
11
|
+
|
12
|
+
],
|
13
|
+
"types": [
|
14
|
+
|
15
|
+
],
|
16
|
+
"checksums": {
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,341 @@
|
|
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,15 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'webmock/rspec'
|
3
4
|
|
4
5
|
describe 'Blacksmith::Forge' do
|
5
6
|
|
6
7
|
subject { Blacksmith::Forge.new(username, password, forge) }
|
7
8
|
let(:username) { 'johndoe' }
|
8
9
|
let(:password) { 'secret' }
|
9
|
-
let(:forge) { "https://
|
10
|
+
let(:forge) { "https://forgestagingapi.puppetlabs.com" }
|
10
11
|
let(:module_name) { "test" }
|
11
12
|
let(:version) { "1.0.0" }
|
12
|
-
let(:
|
13
|
+
let(:module_name) { "maestrodev-test" }
|
14
|
+
let(:spec_data) { File.join(File.dirname(__FILE__), '/../data') }
|
15
|
+
let(:spec_module) { File.join(spec_data, module_name) }
|
16
|
+
let(:target) { File.expand_path(File.join(__FILE__, "../../..", "pkg", module_name)) }
|
17
|
+
let(:package) { "#{target}.tar.gz" }
|
13
18
|
|
14
19
|
describe 'missing credentials file' do
|
15
20
|
before do
|
@@ -28,20 +33,44 @@ describe 'Blacksmith::Forge' do
|
|
28
33
|
|
29
34
|
end
|
30
35
|
|
31
|
-
describe 'push' do
|
36
|
+
describe 'push', :credentials => true do
|
37
|
+
let(:headers) { { 'User-Agent' => %r{^Blacksmith/#{Blacksmith::VERSION} Ruby/.* \(.*\)$} } }
|
32
38
|
|
33
39
|
before do
|
34
|
-
FileUtils.mkdir_p(
|
35
|
-
|
40
|
+
FileUtils.mkdir_p(target)
|
41
|
+
|
42
|
+
# update version
|
43
|
+
f = File.join(spec_module, "metadata.json")
|
44
|
+
metadata = JSON.parse File.read(f)
|
45
|
+
metadata['version'] = "1.0.#{Random.rand(9999999)}"
|
46
|
+
File.open(File.join(target, "metadata.json"),"w") do |file|
|
47
|
+
file.write(JSON.pretty_generate(metadata))
|
48
|
+
end
|
49
|
+
`cd #{target}/..; tar -czf #{module_name}.tar.gz #{module_name}`
|
36
50
|
end
|
37
51
|
|
38
52
|
context "when using username and password" do
|
39
53
|
before do
|
40
|
-
stub_request(:post, "#{forge}/login").with(
|
41
|
-
:body => {'username' => username, 'password' => password}).to_return(
|
42
|
-
:status => 200, :headers => { 'Set-Cookie' => "auth=xxx; path=/; expires=Tue, 27-Aug-2013 08:34:51 GMT" })
|
43
54
|
|
44
|
-
stub_request(:post, "#{forge}
|
55
|
+
stub_request(:post, "#{forge}/oauth/token").with(
|
56
|
+
:body => {
|
57
|
+
"client_id"=>"b93eb708fd942cfc7b4ed71db6ce219b814954619dbe537ddfd208584e8cff8d",
|
58
|
+
"client_secret"=>"216648059ad4afec3e4d77bd9e67817c095b2dcf94cdec18ac3d00584f863180",
|
59
|
+
"grant_type"=>"password",
|
60
|
+
"password"=>"secret",
|
61
|
+
"username"=>"johndoe"
|
62
|
+
},
|
63
|
+
:headers => headers
|
64
|
+
).to_return(
|
65
|
+
:status => 200,
|
66
|
+
:body => {"access_token" => "e52f78b62e97cb8d8db6659a73aa522cca0f5c74d4714e0ed0bdd10000000000", "scope" =>""}.to_json,
|
67
|
+
:headers => {})
|
68
|
+
|
69
|
+
stub_request(:post, "#{forge}/v2/releases").with(
|
70
|
+
:body => %r{Content-Disposition: form-data; name=\"file\"; filename=\"maestrodev-test.tar.gz\"\r\nContent-Type: application/gzip},
|
71
|
+
:headers => headers.merge({'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer e52f78b62e97cb8d8db6659a73aa522cca0f5c74d4714e0ed0bdd10000000000', 'Content-Type'=>%r{multipart/form-data;}})
|
72
|
+
).to_return(:status => 200, :body => File.read(File.join(spec_data, "response.json")), :headers => {})
|
73
|
+
|
45
74
|
subject.push!(module_name, package)
|
46
75
|
end
|
47
76
|
|
@@ -50,20 +79,6 @@ describe 'Blacksmith::Forge' do
|
|
50
79
|
end
|
51
80
|
end
|
52
81
|
|
53
|
-
context "when forge returns an error" do
|
54
|
-
before do
|
55
|
-
stub_request(:post, "#{forge}/login").with(
|
56
|
-
:body => {'username' => username, 'password' => password}).to_return(
|
57
|
-
:status => 200, :headers => { 'Set-Cookie' => "auth=xxx; path=/; expires=Tue, 27-Aug-2013 08:34:51 GMT" })
|
58
|
-
|
59
|
-
stub_request(:post, "#{forge}/#{username}/#{module_name}/upload").to_return(
|
60
|
-
:body => File.new('spec/data/forge_error.html'), :status => 200)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should handle the error" do
|
64
|
-
expect { subject.push!(module_name, package) }.to raise_error(%r{^Error uploading module .*maestrodev-ant-1.0.4.tar.gz to Puppet Forge johndoe/test})
|
65
|
-
end
|
66
|
-
end
|
67
82
|
end
|
68
83
|
end
|
69
84
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-blacksmith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MaestroDev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.7.16
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: nokogiri
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,6 +131,7 @@ extra_rdoc_files: []
|
|
145
131
|
files:
|
146
132
|
- LICENSE
|
147
133
|
- lib/puppet_blacksmith.rb
|
134
|
+
- lib/puppet_blacksmith/credentials.yml
|
148
135
|
- lib/puppet_blacksmith/error.rb
|
149
136
|
- lib/puppet_blacksmith/forge.rb
|
150
137
|
- lib/puppet_blacksmith/git.rb
|
@@ -152,9 +139,9 @@ files:
|
|
152
139
|
- lib/puppet_blacksmith/rake_tasks.rb
|
153
140
|
- lib/puppet_blacksmith/version.rb
|
154
141
|
- spec/data/Modulefile
|
155
|
-
- spec/data/
|
156
|
-
- spec/data/maestrodev-ant-1.0.4.tar.gz
|
142
|
+
- spec/data/maestrodev-test/metadata.json
|
157
143
|
- spec/data/metadata.json
|
144
|
+
- spec/data/response.json
|
158
145
|
- spec/puppet_blacksmith/forge_spec.rb
|
159
146
|
- spec/puppet_blacksmith/git_spec.rb
|
160
147
|
- spec/puppet_blacksmith/modulefile_spec.rb
|
@@ -183,11 +170,11 @@ signing_key:
|
|
183
170
|
specification_version: 4
|
184
171
|
summary: Tasks to manage Puppet module builds
|
185
172
|
test_files:
|
186
|
-
- spec/
|
173
|
+
- spec/spec_helper.rb
|
187
174
|
- spec/data/metadata.json
|
188
|
-
- spec/data/
|
175
|
+
- spec/data/response.json
|
189
176
|
- spec/data/Modulefile
|
177
|
+
- spec/data/maestrodev-test/metadata.json
|
190
178
|
- spec/puppet_blacksmith/forge_spec.rb
|
191
179
|
- spec/puppet_blacksmith/modulefile_spec.rb
|
192
180
|
- spec/puppet_blacksmith/git_spec.rb
|
193
|
-
- spec/spec_helper.rb
|
data/spec/data/forge_error.html
DELETED
@@ -1,230 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html dir="ltr" lang="en-US">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
5
|
-
<title>Puppet Forge</title>
|
6
|
-
<link rel="stylesheet" href="/styles/application.css" />
|
7
|
-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
8
|
-
<script src="/scripts/modernizr.js"></script>
|
9
|
-
|
10
|
-
<script src="//munchkin.marketo.net/munchkin.js" type="text/javascript"></script>
|
11
|
-
|
12
|
-
<script src="/scripts/leadcapture.js"></script>
|
13
|
-
|
14
|
-
<script type="text/javascript">
|
15
|
-
mktoMunchkin("307-QLA-991");
|
16
|
-
|
17
|
-
var _gaq = _gaq || [];
|
18
|
-
_gaq.push(['_setAccount', 'UA-1537572-5']);
|
19
|
-
_gaq.push(['_trackPageview']);
|
20
|
-
(function() {
|
21
|
-
var ga = document.createElement('script');
|
22
|
-
ga.type = 'text/javascript';
|
23
|
-
ga.async = true;
|
24
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
25
|
-
var s = document.getElementsByTagName('script')[0];
|
26
|
-
s.parentNode.insertBefore(ga, s);
|
27
|
-
})();
|
28
|
-
|
29
|
-
var _gauges = _gauges || [];
|
30
|
-
(function() {
|
31
|
-
var t = document.createElement('script');
|
32
|
-
t.type = 'text/javascript';
|
33
|
-
t.async = true;
|
34
|
-
t.id = 'gauges-tracker';
|
35
|
-
t.setAttribute('data-site-id', '50a02411613f5d682f0000c1');
|
36
|
-
t.src = '//secure.gaug.es/track.js';
|
37
|
-
var s = document.getElementsByTagName('script')[0];
|
38
|
-
s.parentNode.insertBefore(t, s);
|
39
|
-
})();
|
40
|
-
</script>
|
41
|
-
</head>
|
42
|
-
<body>
|
43
|
-
<section id="masthead">
|
44
|
-
<div class="site-width">
|
45
|
-
<ul>
|
46
|
-
<li class="colon-after"><a href="http://www.puppetlabs.com">Puppet Labs</a></li>
|
47
|
-
<li><a href="http://puppetlabs.com/puppet/puppet-open-source/">Open Source Projects</a></li>
|
48
|
-
<li><a href="http://puppetlabs.com/services/customer-support/">Support</a></li>
|
49
|
-
<li><a href="http://docs.puppetlabs.com/">Docs</a></li>
|
50
|
-
<li><a href="http://projects.puppetlabs.com/">Bugs</a></li>
|
51
|
-
</ul>
|
52
|
-
</div>
|
53
|
-
</section>
|
54
|
-
<section id="header">
|
55
|
-
<div class="site-width clearfix">
|
56
|
-
<a href="/">
|
57
|
-
<img src="/images/forge-logo.png" class="logo" width="214px" height="50px" alt="Puppet Forge Home">
|
58
|
-
</a>
|
59
|
-
|
60
|
-
<div class="stats">
|
61
|
-
<span class="first">
|
62
|
-
<span class="big">1,369</span> modules
|
63
|
-
</span>
|
64
|
-
<span>
|
65
|
-
<span class="big">1,193,444</span> downloads
|
66
|
-
</span>
|
67
|
-
</div>
|
68
|
-
</div>
|
69
|
-
</section>
|
70
|
-
<section id="content">
|
71
|
-
<div class="site-width clearfix">
|
72
|
-
<section id="body">
|
73
|
-
<h2>Upload a Release of maestrodev/test</h2>
|
74
|
-
<div class="errors">
|
75
|
-
<ul>
|
76
|
-
<li>Internal server error</li>
|
77
|
-
</ul>
|
78
|
-
</div>
|
79
|
-
|
80
|
-
<form action="/maestrodev/test/upload" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
|
81
|
-
<input type="hidden" name="utf-8" value="✓" />
|
82
|
-
<ul class="form">
|
83
|
-
<li class="requiredFieldText">Required fields <span>*</span></li>
|
84
|
-
|
85
|
-
<li>
|
86
|
-
<label for="tarball" class="required">Tarball</label>
|
87
|
-
<p>
|
88
|
-
The version number for this release will be determined from the metadata.json file in the uploaded tarball.
|
89
|
-
|
90
|
-
</p>
|
91
|
-
<input name="tarball" type="file" required />
|
92
|
-
</li>
|
93
|
-
|
94
|
-
<li>
|
95
|
-
<input type="submit" value="Upload Release" />
|
96
|
-
<a href="/maestrodev/test">Cancel</a>
|
97
|
-
</li>
|
98
|
-
</ul>
|
99
|
-
</form>
|
100
|
-
|
101
|
-
</section>
|
102
|
-
<section id="sidebar">
|
103
|
-
<section class="session">
|
104
|
-
<table>
|
105
|
-
<tr>
|
106
|
-
<td>
|
107
|
-
<img class="avatar" alt="avatar" src="//gravatar.com/avatar/192d33f0c408b08b3df9d4927bfbcdc0.png?r=PG&s=45" /></td>
|
108
|
-
<td>
|
109
|
-
<a class="profile-edit" href="/users/maestrodev/edit">MaestroDev</a>
|
110
|
-
<a href="/logout">Sign Out</a>
|
111
|
-
</td>
|
112
|
-
</tr>
|
113
|
-
</table>
|
114
|
-
|
115
|
-
<ul>
|
116
|
-
<li><a href="/maestrodev">Your Modules</a></li>
|
117
|
-
<li><a href="/modules/new">Publish a Module</a></li>
|
118
|
-
</ul>
|
119
|
-
</section>
|
120
|
-
|
121
|
-
<section class="search">
|
122
|
-
<h3>Find Modules</h3>
|
123
|
-
<form action="/modules" method="get" accept-charset="UTF-8">
|
124
|
-
<input type="hidden" name="utf-8" value="✓" />
|
125
|
-
<input type="hidden" name="sort" value="rank" />
|
126
|
-
<input type="search" name="q" required placeholder="eg. apache, mysql" />
|
127
|
-
<input type="submit" value="Find" />
|
128
|
-
</form>
|
129
|
-
</section>
|
130
|
-
|
131
|
-
<section class="tags">
|
132
|
-
<h3>Popular Tags</h3>
|
133
|
-
<ul>
|
134
|
-
<li>
|
135
|
-
<a href="/tags/ubuntu">
|
136
|
-
<b>ubuntu</b> (248 modules)
|
137
|
-
</a>
|
138
|
-
</li>
|
139
|
-
<li>
|
140
|
-
<a href="/tags/debian">
|
141
|
-
<b>debian</b> (197 modules)
|
142
|
-
</a>
|
143
|
-
</li>
|
144
|
-
<li>
|
145
|
-
<a href="/tags/rhel">
|
146
|
-
<b>rhel</b> (145 modules)
|
147
|
-
</a>
|
148
|
-
</li>
|
149
|
-
<li>
|
150
|
-
<a href="/tags/CentOS">
|
151
|
-
<b>CentOS</b> (114 modules)
|
152
|
-
</a>
|
153
|
-
</li>
|
154
|
-
<li>
|
155
|
-
<a href="/tags/centos">
|
156
|
-
<b>centos</b> (95 modules)
|
157
|
-
</a>
|
158
|
-
</li>
|
159
|
-
<li>
|
160
|
-
<a href="/tags/monitoring">
|
161
|
-
<b>monitoring</b> (77 modules)
|
162
|
-
</a>
|
163
|
-
</li>
|
164
|
-
<li>
|
165
|
-
<a href="/tags/networking">
|
166
|
-
<b>networking</b> (73 modules)
|
167
|
-
</a>
|
168
|
-
</li>
|
169
|
-
<li>
|
170
|
-
<a href="/tags/redhat">
|
171
|
-
<b>redhat</b> (68 modules)
|
172
|
-
</a>
|
173
|
-
</li>
|
174
|
-
<li>
|
175
|
-
<a href="/tags/security">
|
176
|
-
<b>security</b> (62 modules)
|
177
|
-
</a>
|
178
|
-
</li>
|
179
|
-
<li>
|
180
|
-
<a href="/tags/applications">
|
181
|
-
<b>applications</b> (61 modules)
|
182
|
-
</a>
|
183
|
-
</li>
|
184
|
-
</ul>
|
185
|
-
</section>
|
186
|
-
|
187
|
-
<section class="banner">
|
188
|
-
<a href="http://puppetconf.com/register/"><img src="/images/puppetconf_v1-01.png"></a>
|
189
|
-
</section> </section>
|
190
|
-
</div>
|
191
|
-
</section>
|
192
|
-
<section id="footer">
|
193
|
-
<div class="site-width">
|
194
|
-
<div id="footer-links">
|
195
|
-
<ul>
|
196
|
-
<li><strong>Community</strong></li>
|
197
|
-
<li><a href="http://webchat.freenode.net/?channels=puppet">IRC</a></li>
|
198
|
-
<li><a href="http://groups.google.com/group/puppet-dev">Puppet Developer List</a></li>
|
199
|
-
<li><a href="http://groups.google.com/group/puppet-users?pli=1">Puppet User List</a></li>
|
200
|
-
<li><a href="http://www.linkedin.com/groups?about=&gid=696467&trk=anet_ug_grppro">Puppet Users' LinkedIn Group</a></li>
|
201
|
-
<li><a href="http://puppetlabs.com/resources/newsletter/">Subscribe to Newsletter</a></li>
|
202
|
-
</ul>
|
203
|
-
</div>
|
204
|
-
<div id="footer-bottom" class="clearfix">
|
205
|
-
<div class="vcard">
|
206
|
-
© 2009-2012
|
207
|
-
<span class="org">
|
208
|
-
<a href="http://puppetlabs.com/" title="Puppet Labs">
|
209
|
-
Puppet Labs
|
210
|
-
</a>
|
211
|
-
</span>
|
212
|
-
<a class="email" href="mailto:info@puppetlabs.com">info@puppetlabs.com</a>
|
213
|
-
<span class="adr">
|
214
|
-
<span class="street-address">926 NW 13th Ave., Suite 210</span>
|
215
|
-
/
|
216
|
-
<span class="locality">Portland</span>
|
217
|
-
,
|
218
|
-
<span class="region">OR</span>
|
219
|
-
<span class="postal-code">97209</span>
|
220
|
-
|
221
|
-
</span>
|
222
|
-
<span class="tel">+1 503-805-9065</span>
|
223
|
-
</div>
|
224
|
-
<div class="new-relic-logo">Monitored by <a href="http://newrelic.com/"><img src="/images/new-relic-oval.png"></a>
|
225
|
-
</div>
|
226
|
-
</div>
|
227
|
-
</div>
|
228
|
-
</section>
|
229
|
-
</body>
|
230
|
-
</html>
|
File without changes
|