nexus_cli 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/features/step_definitions/cli_steps.rb +31 -0
- data/lib/nexus_cli/errors.rb +18 -0
- data/lib/nexus_cli/nexus_oss_remote.rb +35 -18
- data/lib/nexus_cli/nexus_pro_remote.rb +209 -51
- data/lib/nexus_cli/tasks.rb +111 -3
- data/pro/nexus_pro.feature +91 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
@@ -49,6 +49,37 @@ When /^I update global settings uiTimeout to (\d+) and upload the json string$/
|
|
49
49
|
nexus_remote.upload_global_settings(JSON.dump(edited_json))
|
50
50
|
end
|
51
51
|
|
52
|
+
When /^I add a trusted key to nexus$/ do
|
53
|
+
Dir.chdir(temp_dir) do
|
54
|
+
File.open("cert.txt", "w+") do |opened|
|
55
|
+
opened.write("-----BEGIN CERTIFICATE-----
|
56
|
+
MIICiTCCAfICCQDIKBRH7YO5mTANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC
|
57
|
+
VVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFTATBgNVBAcTDFNhbnRhIE1vbmljYTET
|
58
|
+
MBEGA1UEChMKUmlvdCBHYW1lczETMBEGA1UEAxMKS3lsZSBBbGxhbjEjMCEGCSqG
|
59
|
+
SIb3DQEJARYUa2FsbGFuQHJpb3RnYW1lcy5jb20wHhcNMTIwNjIwMjMxOTQ1WhcN
|
60
|
+
MTMwNjIwMjMxOTQ1WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3Ju
|
61
|
+
aWExFTATBgNVBAcTDFNhbnRhIE1vbmljYTETMBEGA1UEChMKUmlvdCBHYW1lczET
|
62
|
+
MBEGA1UEAxMKS3lsZSBBbGxhbjEjMCEGCSqGSIb3DQEJARYUa2FsbGFuQHJpb3Rn
|
63
|
+
YW1lcy5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM8Yz96KDxzv7eEt
|
64
|
+
DQNLV/3ipXJ5U/lQOQ2BrjSB6qrAHP2u4f+tzJtANXHcRrhXI3oOE993fg82adZg
|
65
|
+
XpWLl9wcPHDKP8s5l4TUxMjVJ4UYLJeINwOh/s3cpFq/ni/Klb+QWKG8Vyp6ossF
|
66
|
+
VGOc0IiU4ZaC38+jlqvCkHwdCQ4hAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAG6Eh
|
67
|
+
2QO0D69W+9wFvMQAC8YvHNMW9S9A+YRDa5vOeWzUZpeAYuawFSVfjT3fof2ovCU8
|
68
|
+
/AR2PyVwJvXRp0Yon2sUfaaFVP4x0BFAwWHk4vLBtqviBhKRdF1D/rR1g4KRowsh
|
69
|
+
P5KVneepzhtEt9G/uO4MU89cdUR0IMyUwdhq2dg=
|
70
|
+
-----END CERTIFICATE-----
|
71
|
+
")
|
72
|
+
end
|
73
|
+
step "I run `nexus-cli add_trusted_key --certificate=#{File.join(temp_dir, "cert.txt")} --description=cucumber`"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
When /^I delete a trusted key in nexus$/ do
|
78
|
+
json = JSON.parse(nexus_remote.get_trusted_keys)
|
79
|
+
key_id = json["data"].first["id"]
|
80
|
+
step "I run `nexus-cli delete_trusted_key #{key_id}`"
|
81
|
+
end
|
82
|
+
|
52
83
|
Then /^a file named "(.*?)" should exist in my nexus folder$/ do |file|
|
53
84
|
path = File.join(File.expand_path("~/.nexus"), file)
|
54
85
|
step "a file named \"#{path}\" should exist"
|
data/lib/nexus_cli/errors.rb
CHANGED
@@ -191,4 +191,22 @@ The output from the server was:
|
|
191
191
|
end
|
192
192
|
status_code(120)
|
193
193
|
end
|
194
|
+
|
195
|
+
class NotProxyRepositoryException < NexusCliError
|
196
|
+
def initialize(repository_id)
|
197
|
+
@repository_id = repository_id
|
198
|
+
end
|
199
|
+
|
200
|
+
def message
|
201
|
+
"The #{@repository_id} repository is not a Proxy repository and cannot subscribe to artifact updates."
|
202
|
+
end
|
203
|
+
status_code(121)
|
204
|
+
end
|
205
|
+
|
206
|
+
class LicenseInstallFailure < NexusCliError
|
207
|
+
def message
|
208
|
+
"Either your Nexus already has a license installed or there was a problem with the file you uploaded."
|
209
|
+
end
|
210
|
+
status_code(122)
|
211
|
+
end
|
194
212
|
end
|
@@ -38,7 +38,7 @@ module NexusCli
|
|
38
38
|
params = {:g => group_id, :a => artifact_id, :v => version, :e => extension, :r => configuration["repository"]}.collect {|k,v| "#{k}=#{URI::escape(v.to_s)}"}.join("&")
|
39
39
|
version = Nokogiri::XML(get_artifact_info(artifact)).xpath("//version").first.content() if version.casecmp("latest")
|
40
40
|
destination = File.join(File.expand_path(destination || "."), "#{artifact_id}-#{version}.#{extension}")
|
41
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
41
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
|
42
42
|
request = Net::HTTP::Get.new(URI(http.request_get(uri.request_uri + "?" + params)["location"]).request_uri)
|
43
43
|
request.basic_auth(configuration["username"], configuration["password"])
|
44
44
|
http.request(request) do |response|
|
@@ -132,8 +132,14 @@ module NexusCli
|
|
132
132
|
nexus['service/local/global_settings/current'].put(default_json, :content_type => "application/json")
|
133
133
|
end
|
134
134
|
|
135
|
-
def create_repository(name)
|
136
|
-
|
135
|
+
def create_repository(name, proxy, url)
|
136
|
+
|
137
|
+
json = if proxy
|
138
|
+
create_proxy_repository_json(name, url)
|
139
|
+
else
|
140
|
+
create_hosted_repository_json(name)
|
141
|
+
end
|
142
|
+
nexus['service/local/repositories'].post(json, :content_type => "application/json") do |response|
|
137
143
|
case response.code
|
138
144
|
when 400
|
139
145
|
raise CreateRepsitoryException.new(response.body)
|
@@ -265,21 +271,32 @@ module NexusCli
|
|
265
271
|
return group_id, artifact_id, version, extension
|
266
272
|
end
|
267
273
|
|
268
|
-
def
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
274
|
+
def create_hosted_repository_json(name)
|
275
|
+
params = {:provider => "maven2"}
|
276
|
+
params[:providerRole] = "org.sonatype.nexus.proxy.repository.Repository"
|
277
|
+
params[:exposed] = true
|
278
|
+
params[:repoType] = "hosted"
|
279
|
+
params[:repoPolicy] = "RELEASE"
|
280
|
+
params[:name] = name
|
281
|
+
params[:id] = name.downcase
|
282
|
+
params[:format] = "maven2"
|
283
|
+
JSON.dump(:data => params)
|
284
|
+
end
|
285
|
+
|
286
|
+
def create_proxy_repository_json(name, url)
|
287
|
+
params = {:provider => "maven2"}
|
288
|
+
params[:providerRole] = "org.sonatype.nexus.proxy.repository.Repository"
|
289
|
+
params[:exposed] = true
|
290
|
+
params[:repoType] = "proxy"
|
291
|
+
params[:repoPolicy] = "RELEASE"
|
292
|
+
params[:checksumPolicy] = "WARN"
|
293
|
+
params[:writePolicy] = "READ_ONLY"
|
294
|
+
params[:downloadRemoteIndexes] = true
|
295
|
+
params[:autoBlockActive] = true
|
296
|
+
params[:name] = name
|
297
|
+
params[:id] = name.downcase
|
298
|
+
params[:remoteStorage] = {:remoteStorageUrl => url.nil? ? "http://change-me.com/" : url}
|
299
|
+
JSON.dump(:data => params)
|
283
300
|
end
|
284
301
|
|
285
302
|
def create_user_json(params)
|
@@ -106,64 +106,222 @@ module NexusCli
|
|
106
106
|
return result.nil? ? "" : result.to_xml(:indent => 4)
|
107
107
|
end
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
109
|
+
def get_pub_sub(repository_id)
|
110
|
+
nexus["service/local/smartproxy/pub-sub/#{repository_id}"].get
|
111
|
+
end
|
112
|
+
|
113
|
+
def enable_artifact_publish(repository_id)
|
114
|
+
params = {:repositoryId => repository_id}
|
115
|
+
params[:publish] = true
|
116
|
+
artifact_publish(repository_id, params)
|
117
|
+
end
|
118
|
+
|
119
|
+
def disable_artifact_publish(repository_id)
|
120
|
+
params = {:repositoryId => repository_id}
|
121
|
+
params[:publish] = false
|
122
|
+
artifact_publish(repository_id, params)
|
123
|
+
end
|
124
|
+
|
125
|
+
def artifact_publish(repository_id, params)
|
126
|
+
nexus["service/local/smartproxy/pub-sub/#{repository_id}"].put(create_pub_sub_json(params), :content_type => "application/json") do |response|
|
127
|
+
case response.code
|
128
|
+
when 200
|
129
|
+
return true
|
130
|
+
else
|
131
|
+
raise UnexpectedStatusCodeException.new(response.code)
|
119
132
|
end
|
120
|
-
return parsed_params
|
121
|
-
rescue
|
122
|
-
raise N3ParameterMalformedException
|
123
133
|
end
|
124
134
|
end
|
125
135
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
136
|
+
|
137
|
+
def enable_artifact_subscribe(repository_id)
|
138
|
+
raise NotProxyRepositoryException.new(repository_id) unless Nokogiri::XML(get_repository_info(repository_id)).xpath("/repository/data/repoType").first.content == "proxy"
|
139
|
+
|
140
|
+
params = {:repositoryId => repository_id}
|
141
|
+
params[:subscribe] = true
|
142
|
+
artifact_subscribe(repository_id, params)
|
143
|
+
end
|
144
|
+
|
145
|
+
def disable_artifact_subscribe(repository_id)
|
146
|
+
raise NotProxyRepositoryException.new(repository_id) unless Nokogiri::XML(get_repository_info(repository_id)).xpath("/repository/data/repoType").first.content == "proxy"
|
147
|
+
|
148
|
+
params = {:repositoryId => repository_id}
|
149
|
+
params[:subscribe] = false
|
150
|
+
artifact_subscribe(repository_id, params)
|
151
|
+
end
|
152
|
+
|
153
|
+
def artifact_subscribe(repository_id, params)
|
154
|
+
nexus["service/local/smartproxy/pub-sub/#{repository_id}"].put(create_pub_sub_json(params), :content_type => "application/json") do |response|
|
155
|
+
case response.code
|
156
|
+
when 200
|
157
|
+
return true
|
158
|
+
else
|
159
|
+
raise UnexpectedStatusCodeException.new(response.code)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def enable_smart_proxy(host=nil, port=nil)
|
165
|
+
params = {:enabled => true}
|
166
|
+
params[:host] = host unless host.nil?
|
167
|
+
params[:port] = port unless port.nil?
|
168
|
+
smart_proxy(params)
|
169
|
+
end
|
170
|
+
|
171
|
+
def disable_smart_proxy
|
172
|
+
params = {:enabled => false}
|
173
|
+
smart_proxy(params)
|
174
|
+
end
|
175
|
+
|
176
|
+
def smart_proxy(params)
|
177
|
+
nexus["service/local/smartproxy/settings"].put(create_smart_proxy_settings_json(params), :content_type => "application/json") do |response|
|
178
|
+
case response.code
|
179
|
+
when 200
|
180
|
+
return true
|
181
|
+
else
|
182
|
+
raise UnexpectedStatusCodeException.new(response.code)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def get_smart_proxy_settings
|
188
|
+
nexus["service/local/smartproxy/settings"].get(:accept => "application/json")
|
189
|
+
end
|
190
|
+
|
191
|
+
def get_smart_proxy_key
|
192
|
+
nexus["service/local/smartproxy/settings"].get(:accept => "application/json")
|
193
|
+
end
|
194
|
+
|
195
|
+
def add_trusted_key(certificate, description, path=true)
|
196
|
+
params = {:description => description}
|
197
|
+
params[:certificate] = path ? File.read(File.expand_path(certificate)) : certificate
|
198
|
+
nexus["service/local/smartproxy/trusted-keys"].post(create_add_trusted_key_json(params), :content_type => "application/json") do |response|
|
199
|
+
case response.code
|
200
|
+
when 201
|
201
|
+
return true
|
202
|
+
else
|
203
|
+
raise UnexpectedStatusCodeException.new(response.code)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def delete_trusted_key(key_id)
|
209
|
+
nexus["service/local/smartproxy/trusted-keys/#{key_id}"].delete do |response|
|
210
|
+
case response.code
|
211
|
+
when 204
|
212
|
+
return true
|
213
|
+
else
|
214
|
+
raise UnexpectedStatusCodeException.new(response.code)
|
137
215
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
def
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
artifact += piece
|
160
|
-
artifacts.push(artifact)
|
161
|
-
artifact = nil
|
162
|
-
elsif !artifact.nil?
|
163
|
-
artifact += piece
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def get_trusted_keys
|
220
|
+
nexus["service/local/smartproxy/trusted-keys"].get(:accept => "application/json")
|
221
|
+
end
|
222
|
+
|
223
|
+
def get_license_info
|
224
|
+
nexus["service/local/licensing"].get(:accept => "application/json")
|
225
|
+
end
|
226
|
+
|
227
|
+
def install_license(license_file)
|
228
|
+
file = File.read(File.expand_path(license_file))
|
229
|
+
nexus["service/local/licensing/upload"].post(file, :content_type => "application/octet-stream") do |response|
|
230
|
+
case response.code
|
231
|
+
when 201
|
232
|
+
return true
|
233
|
+
when 403
|
234
|
+
raise LicenseInstallFailure
|
235
|
+
else
|
236
|
+
raise UnexpectedStatusCodeException.new(response.code)
|
164
237
|
end
|
165
238
|
end
|
166
|
-
return artifacts
|
167
239
|
end
|
240
|
+
|
241
|
+
def install_license_bytes(bytes)
|
242
|
+
nexus["service/local/licensing/upload"].post(bytes, :content_type => "application/octet-stream") do |response|
|
243
|
+
case response.code
|
244
|
+
when 201
|
245
|
+
return true
|
246
|
+
when 403
|
247
|
+
raise LicenseInstallFailure
|
248
|
+
else
|
249
|
+
raise UnexpectedStatusCodeException.new(response.code)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
private
|
255
|
+
|
256
|
+
def create_add_trusted_key_json(params)
|
257
|
+
JSON.dump(:data => params)
|
258
|
+
end
|
259
|
+
|
260
|
+
def create_smart_proxy_settings_json(params)
|
261
|
+
JSON.dump(:data => params)
|
262
|
+
end
|
263
|
+
|
264
|
+
def create_pub_sub_json(params)
|
265
|
+
JSON.dump(:data => params)
|
266
|
+
end
|
267
|
+
|
268
|
+
def parse_update_params(*params)
|
269
|
+
begin
|
270
|
+
parsed_params = Hash.new
|
271
|
+
params.each do |param|
|
272
|
+
# The first colon separates key and value.
|
273
|
+
c1 = param.index(":")
|
274
|
+
key = param[0..(c1 - 1)]
|
275
|
+
value = param[(c1 + 1)..-1]
|
276
|
+
!c1.nil? && N3Metadata::valid_n3_key?(key) && N3Metadata::valid_n3_value?(value) ? parsed_params[key] = value : raise
|
277
|
+
end
|
278
|
+
return parsed_params
|
279
|
+
rescue
|
280
|
+
raise N3ParameterMalformedException
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def parse_search_params(*params)
|
285
|
+
begin
|
286
|
+
parsed_params = Array.new
|
287
|
+
params.each do |param|
|
288
|
+
# The first two colons separate key, type, and value.
|
289
|
+
c1 = param.index(":")
|
290
|
+
c2 = param.index(":", (c1 + 1))
|
291
|
+
key = param[0..(c1 - 1)]
|
292
|
+
type = param[(c1 + 1)..(c2 - 1)]
|
293
|
+
value = param[(c2 + 1)..-1]
|
294
|
+
!c1.nil? && !c2.nil? && N3Metadata::valid_n3_key?(key) && N3Metadata::valid_n3_value?(value) && N3Metadata::valid_n3_search_type?(type) ? parsed_params.push([key, type, value]) : raise
|
295
|
+
end
|
296
|
+
return parsed_params
|
297
|
+
rescue
|
298
|
+
raise SearchParameterMalformedException
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
# Expects the XML set with `data` as root.
|
303
|
+
def get_common_artifact_set(set1, set2)
|
304
|
+
intersection = get_artifact_array(set1) & get_artifact_array(set2)
|
305
|
+
return intersection.count > 0 ? Nokogiri::XML("<data>#{intersection.join}</data>").root : Nokogiri::XML("").root
|
306
|
+
end
|
307
|
+
|
308
|
+
# Collect <artifact>...</artifact> elements into an array.
|
309
|
+
# This will allow use of array intersection to find common artifacts in searches.
|
310
|
+
def get_artifact_array(set)
|
311
|
+
artifacts = Array.new
|
312
|
+
artifact = nil
|
313
|
+
set.to_s.split("\n").collect {|x| x.to_s.strip}.each do |piece|
|
314
|
+
if piece == "<artifact>"
|
315
|
+
artifact = piece
|
316
|
+
elsif piece == "</artifact>"
|
317
|
+
artifact += piece
|
318
|
+
artifacts.push(artifact)
|
319
|
+
artifact = nil
|
320
|
+
elsif !artifact.nil?
|
321
|
+
artifact += piece
|
322
|
+
end
|
323
|
+
end
|
324
|
+
return artifacts
|
325
|
+
end
|
168
326
|
end
|
169
327
|
end
|
data/lib/nexus_cli/tasks.rb
CHANGED
@@ -138,9 +138,15 @@ module NexusCli
|
|
138
138
|
say "Your Nexus global settings have been reset to their default values", :blue
|
139
139
|
end
|
140
140
|
|
141
|
+
method_option :proxy,
|
142
|
+
:type => :boolean,
|
143
|
+
:desc => "True if the new repository should be a proxy repository"
|
144
|
+
method_option :url,
|
145
|
+
:type => :string,
|
146
|
+
:desc => "The url of the actual repository for the proxy repository to use."
|
141
147
|
desc "create_repository name", "Creates a new Repository with the provided name."
|
142
148
|
def create_repository(name)
|
143
|
-
if @nexus_remote.create_repository(name)
|
149
|
+
if @nexus_remote.create_repository(name, options[:proxy], options[:url])
|
144
150
|
say "A new Repository named #{name} has been created.", :blue
|
145
151
|
end
|
146
152
|
end
|
@@ -159,7 +165,7 @@ module NexusCli
|
|
159
165
|
|
160
166
|
desc "get_users", "Returns XML representing the users in Nexus."
|
161
167
|
def get_users
|
162
|
-
say @nexus_remote.get_users
|
168
|
+
say @nexus_remote.get_users, :green
|
163
169
|
end
|
164
170
|
|
165
171
|
method_option :username,
|
@@ -267,10 +273,112 @@ module NexusCli
|
|
267
273
|
params[:oldPassword] = oldPassword
|
268
274
|
params[:newPassword] = newPassword
|
269
275
|
if @nexus_remote.change_password(params)
|
270
|
-
say "The password for user #{user_id} has been updated."
|
276
|
+
say "The password for user #{user_id} has been updated.", :blue
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
desc "get_pub_sub repository_id", "Returns the publish/subscribe status of the given repository."
|
281
|
+
def get_pub_sub(repository_id)
|
282
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
283
|
+
say @nexus_remote.get_pub_sub(repository_id), :green
|
284
|
+
end
|
285
|
+
|
286
|
+
desc "enable_artifact_publish repository_id", "Sets a repository to enable the publishing of updates about its artifacts."
|
287
|
+
def enable_artifact_publish(repository_id)
|
288
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
289
|
+
if @nexus_remote.enable_artifact_publish(repository_id)
|
290
|
+
say "The repository #{repository_id} will now publish updates.", :blue
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
desc "disable_artifact_publish repository_id", "Sets a repository to disable the publishing of updates about its artifacts."
|
295
|
+
def disable_artifact_publish(repository_id)
|
296
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
297
|
+
if @nexus_remote.disable_artifact_publish(repository_id)
|
298
|
+
say "The repository #{repository_id} is no longer publishing updates.", :blue
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
desc "enable_artifact_subscribe repository_id", "Sets a repository to subscribe to updates about artifacts."
|
303
|
+
def enable_artifact_subscribe(repository_id)
|
304
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
305
|
+
if @nexus_remote.enable_artifact_subscribe(repository_id)
|
306
|
+
say "The repository #{repository_id} is now subscribed for artifact updates.", :blue
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
desc "disable_artifact_subscribe repository_id", "Sets a repository to stop subscribing to updates about artifacts."
|
311
|
+
def disable_artifact_subscribe(repository_id)
|
312
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
313
|
+
if @nexus_remote.disable_artifact_subscribe(repository_id)
|
314
|
+
say "The repository #{repository_id} is no longer subscribed for artifact updates.", :blue
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
method_option :host,
|
319
|
+
:type => :string,
|
320
|
+
:desc => "An IP address for the Nexus server at which publishing will be available."
|
321
|
+
method_option :port,
|
322
|
+
:type => :numeric,
|
323
|
+
:desc => "An available port that will be used for Smart Proxy connections."
|
324
|
+
desc "enable_smart_proxy", "Enables Smart Proxy on the server."
|
325
|
+
def enable_smart_proxy
|
326
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
327
|
+
say @nexus_remote.enable_smart_proxy(options[:host], options[:port])
|
328
|
+
end
|
329
|
+
|
330
|
+
desc "disable_smart_proxy", "Disables Smart Proxy on the server."
|
331
|
+
def disable_smart_proxy
|
332
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
333
|
+
say @nexus_remote.disable_smart_proxy
|
334
|
+
end
|
335
|
+
|
336
|
+
desc "get_smart_proxy_settings", "Returns the Smart Proxy settings of the server."
|
337
|
+
def get_smart_proxy_settings
|
338
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
339
|
+
say JSON.pretty_generate(JSON.parse(@nexus_remote.get_smart_proxy_settings)), :green
|
340
|
+
end
|
341
|
+
|
342
|
+
method_option :certificate,
|
343
|
+
:type => :string,
|
344
|
+
:required => :true,
|
345
|
+
:desc => "A path to a file containing a certificate."
|
346
|
+
method_option :description,
|
347
|
+
:type => :string,
|
348
|
+
:required => true,
|
349
|
+
:desc => "A description to give to the trusted key. It is probably best to make this meaningful."
|
350
|
+
desc "add_trusted_key", "Adds a new trusted key to the Smart Proxy configuration."
|
351
|
+
def add_trusted_key
|
352
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
353
|
+
if @nexus_remote.add_trusted_key(options[:certificate], options[:description])
|
354
|
+
say "A new trusted key has been added to the nexus.", :blue
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
desc "delete_trusted_key key_id", "Deletes a trusted key using the given key_id."
|
359
|
+
def delete_trusted_key(key_id)
|
360
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
361
|
+
if @nexus_remote.delete_trusted_key(key_id)
|
362
|
+
say "The trusted key with an id of #{key_id} has been deleted.", :blue
|
271
363
|
end
|
272
364
|
end
|
273
365
|
|
366
|
+
desc "get_trusted_keys", "Returns the trusted keys of the server."
|
367
|
+
def get_trusted_keys
|
368
|
+
raise NotNexusProException unless @nexus_remote.kind_of? ProRemote
|
369
|
+
say JSON.pretty_generate(JSON.parse(@nexus_remote.get_trusted_keys)), :green
|
370
|
+
end
|
371
|
+
|
372
|
+
desc "get_license_info", "Returns the license information of the server."
|
373
|
+
def get_license_info
|
374
|
+
say @nexus_remote.get_license_info, :green
|
375
|
+
end
|
376
|
+
|
377
|
+
desc "install_license license_file", "Installs a license file into the server."
|
378
|
+
def install_license(license_file)
|
379
|
+
@nexus_remote.install_license(license_file)
|
380
|
+
end
|
381
|
+
|
274
382
|
private
|
275
383
|
|
276
384
|
def ask_user(params, ask_username=true, ask_password=true)
|
data/pro/nexus_pro.feature
CHANGED
@@ -107,4 +107,94 @@ Feature: Use the Nexus Pro CLI
|
|
107
107
|
"""
|
108
108
|
The artifact you requested information for could not be found. Please ensure it exists inside the Nexus.
|
109
109
|
"""
|
110
|
-
And the exit status should be 101
|
110
|
+
And the exit status should be 101
|
111
|
+
|
112
|
+
Scenario: Set a repository to publish updates
|
113
|
+
When I call the nexus "enable_artifact_publish releases" command
|
114
|
+
And I call the nexus "get_pub_sub releases" command
|
115
|
+
Then the output should contain:
|
116
|
+
"""
|
117
|
+
<publish>true</publish>
|
118
|
+
"""
|
119
|
+
And the exit status should be 0
|
120
|
+
|
121
|
+
Scenario: Set a repository to not publish updates
|
122
|
+
When I call the nexus "disable_artifact_publish releases" command
|
123
|
+
And I call the nexus "get_pub_sub releases" command
|
124
|
+
Then the output should contain:
|
125
|
+
"""
|
126
|
+
<publish>false</publish>
|
127
|
+
"""
|
128
|
+
And the exit status should be 0
|
129
|
+
|
130
|
+
Scenario: Set a repository to subscribe to updates
|
131
|
+
When I call the nexus "enable_artifact_subscribe central" command
|
132
|
+
And I call the nexus "get_pub_sub central" command
|
133
|
+
Then the output should contain:
|
134
|
+
"""
|
135
|
+
<subscribe>true</subscribe>
|
136
|
+
"""
|
137
|
+
And the exit status should be 0
|
138
|
+
|
139
|
+
Scenario: Set a repository to not subscribe to updates
|
140
|
+
When I call the nexus "disable_artifact_subscribe central" command
|
141
|
+
And I call the nexus "get_pub_sub central" command
|
142
|
+
Then the output should contain:
|
143
|
+
"""
|
144
|
+
<subscribe>false</subscribe>
|
145
|
+
"""
|
146
|
+
And the exit status should be 0
|
147
|
+
|
148
|
+
Scenario: Enable Smart Proxy on the Server
|
149
|
+
When I call the nexus "enable_smart_proxy" command
|
150
|
+
And I call the nexus "get_smart_proxy_settings" command
|
151
|
+
Then the output should contain:
|
152
|
+
"""
|
153
|
+
"enabled": true
|
154
|
+
"""
|
155
|
+
And the exit status should be 0
|
156
|
+
|
157
|
+
Scenario: Enable Smart Proxy and set the host
|
158
|
+
When I call the nexus "enable_smart_proxy --host=0.0.0.1" command
|
159
|
+
And I call the nexus "get_smart_proxy_settings" command
|
160
|
+
Then the output should contain:
|
161
|
+
"""
|
162
|
+
"host": "0.0.0.1"
|
163
|
+
"""
|
164
|
+
And the exit status should be 0
|
165
|
+
|
166
|
+
Scenario: Enable Smart Proxy and set the host
|
167
|
+
When I call the nexus "enable_smart_proxy --port=1234" command
|
168
|
+
And I call the nexus "get_smart_proxy_settings" command
|
169
|
+
Then the output should contain:
|
170
|
+
"""
|
171
|
+
"port": 1234
|
172
|
+
"""
|
173
|
+
And the exit status should be 0
|
174
|
+
|
175
|
+
Scenario: Disable Smart Proxy on the Server
|
176
|
+
When I call the nexus "disable_smart_proxy" command
|
177
|
+
And I call the nexus "get_smart_proxy_settings" command
|
178
|
+
Then the output should contain:
|
179
|
+
"""
|
180
|
+
"enabled": false
|
181
|
+
"""
|
182
|
+
And the exit status should be 0
|
183
|
+
|
184
|
+
Scenario: Add a trusted key
|
185
|
+
When I add a trusted key to nexus
|
186
|
+
And I call the nexus "get_trusted_keys" command
|
187
|
+
Then the output should contain:
|
188
|
+
"""
|
189
|
+
cucumber
|
190
|
+
"""
|
191
|
+
And the exit status should be 0
|
192
|
+
|
193
|
+
Scenario: Delete a trusted key
|
194
|
+
When I delete a trusted key in nexus
|
195
|
+
And I call the nexus "get_trusted_keys" command
|
196
|
+
Then the output should not contain:
|
197
|
+
"""
|
198
|
+
cucumber
|
199
|
+
"""
|
200
|
+
And the exit status should be 0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -252,7 +252,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
252
|
version: '0'
|
253
253
|
segments:
|
254
254
|
- 0
|
255
|
-
hash: -
|
255
|
+
hash: -3285789410207275915
|
256
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
257
|
none: false
|
258
258
|
requirements:
|
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
261
|
version: '0'
|
262
262
|
segments:
|
263
263
|
- 0
|
264
|
-
hash: -
|
264
|
+
hash: -3285789410207275915
|
265
265
|
requirements: []
|
266
266
|
rubyforge_project:
|
267
267
|
rubygems_version: 1.8.21
|