phoseum-cli 0.0.14 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/phoseum-cli +32 -8
- data/lib/phoseum/phoseum-cli-lib.rb +74 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '092592a7b73a29fb773b199b9e29f7054da0da5701583c1162c2500a1860635f'
|
4
|
+
data.tar.gz: fc71817a9eb49a14d2567694efaa91ee076e991a1780b8abdbf20b3a2c2032db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78a80cda0d947299a0b95b86f2ccebcf1df4d263bdad641ff0d0aec8d3e2445a28d2062ba52f49d520bf334051448adcf02674069992f7b55d22e1eb60e9f288
|
7
|
+
data.tar.gz: 2b296a8c6ab2f30de4e7c85dd0b9acf55a3c5b8130ed9887c359220da14879d2b73895894b29f450c4b4a390f04edae6473fe317874183284d336066ddaac3cb
|
data/bin/phoseum-cli
CHANGED
@@ -277,6 +277,15 @@ def user_mgmt(action,user,pass='',role='')
|
|
277
277
|
end
|
278
278
|
|
279
279
|
def user_login(puser='',ppass='')
|
280
|
+
|
281
|
+
server_value = cross_versions()
|
282
|
+
if server_value['version'] != VERSION_SIGN
|
283
|
+
puts "Server and Client version won't match, please make them match to continue.".red
|
284
|
+
puts "Remote version: #{server_value['version']}"
|
285
|
+
puts "Local version: #{VERSION_SIGN}"
|
286
|
+
exit 1
|
287
|
+
end
|
288
|
+
|
280
289
|
post_body={}
|
281
290
|
user= !puser ? '' : puser
|
282
291
|
pass= !ppass ? '' : ppass
|
@@ -332,7 +341,6 @@ def user_login(puser='',ppass='')
|
|
332
341
|
return false
|
333
342
|
end
|
334
343
|
|
335
|
-
|
336
344
|
def delete(what='',path='')
|
337
345
|
if !validate_token($config['TOKEN'])
|
338
346
|
if token = user_login()
|
@@ -452,15 +460,23 @@ case options
|
|
452
460
|
end
|
453
461
|
when -> (o) { o[:options] }
|
454
462
|
if options[:user]
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
print "\n Change [P]assword, [U]sername, [R]ole :[P/U/R]: "
|
459
|
-
confirm=STDIN.gets.chomp
|
460
|
-
else
|
461
|
-
puts "User Check Failed".red
|
463
|
+
tokeninfo = api_caller({"action" => "token-payload", "token" => "#{$config['TOKEN']}"})
|
464
|
+
if tokeninfo['error']
|
465
|
+
puts "Your token seems invalid, please login again".red
|
462
466
|
exit 1
|
463
467
|
end
|
468
|
+
if tokeninfo['success']
|
469
|
+
puts tokeninfo.payload
|
470
|
+
end
|
471
|
+
# print "Please confirm #{options[:user]} password.\n\t"
|
472
|
+
# current_password=STDIN.getpass('Password: ')
|
473
|
+
# if token = user_login(options[:user],current_password)
|
474
|
+
# print "\n Change [P]assword, [U]sername, [R]ole :[P/U/R]: "
|
475
|
+
# confirm=STDIN.gets.chomp
|
476
|
+
# else
|
477
|
+
# puts "User Check Failed".red
|
478
|
+
# exit 1
|
479
|
+
# end
|
464
480
|
else
|
465
481
|
# if !what
|
466
482
|
puts "Got no user to work with. Exiting.".red
|
@@ -504,6 +520,14 @@ case options
|
|
504
520
|
else
|
505
521
|
puts "Login failed".red
|
506
522
|
end
|
523
|
+
when -> (vs) { vs[:version] }
|
524
|
+
local_version
|
525
|
+
exit 0
|
526
|
+
when -> (x) { x[:crossv] }
|
527
|
+
server_value = cross_versions()
|
528
|
+
puts "Remote version: #{server_value['version']}"
|
529
|
+
puts "Local version: #{VERSION_SIGN}"
|
530
|
+
exit 0
|
507
531
|
when -> (t) { t[:test] }
|
508
532
|
puts "Making local analysis of files on directory".green if !$QUIET
|
509
533
|
test
|
@@ -48,6 +48,14 @@ def option_parser(opts)
|
|
48
48
|
options[:verbose] = v
|
49
49
|
end
|
50
50
|
|
51
|
+
opts.on("-V", "--version", "What version we are") do |vs|
|
52
|
+
options[:version] = vs
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("-x", "--cross-versions", "Check version match between Client and API") do |x|
|
56
|
+
options[:crossv] = x
|
57
|
+
end
|
58
|
+
|
51
59
|
opts.on("-r", "--role ROLE", "Role for user: [User, Super]. Use with 'create-user'") do |r|
|
52
60
|
options[:role] = r
|
53
61
|
end
|
@@ -253,6 +261,65 @@ def validate_token(token)
|
|
253
261
|
end
|
254
262
|
end
|
255
263
|
|
264
|
+
def api_caller(json_body)
|
265
|
+
headers = {}
|
266
|
+
if $config['TOKEN']
|
267
|
+
headers={ "bearer" => "#{$config['TOKEN']}" }
|
268
|
+
else
|
269
|
+
return false
|
270
|
+
end
|
271
|
+
base = URI.parse("#{$config['SERVERURL']}")
|
272
|
+
request = Net::HTTP::Post.new(base,headers)
|
273
|
+
request.body = JSON.generate(json_body)
|
274
|
+
response = Net::HTTP.start(base.hostname, $config['PORT'],
|
275
|
+
:timeout => $config['CALL_TIMEOUT'],
|
276
|
+
:use_ssl => base.scheme == "https",
|
277
|
+
:verify_mode => OpenSSL::SSL::VERIFY_PEER,
|
278
|
+
:ca_file => $config['CA_TRUST']
|
279
|
+
) do |http|
|
280
|
+
http.request(request)
|
281
|
+
end
|
282
|
+
begin
|
283
|
+
list = JSON.parse(response.body)
|
284
|
+
return list
|
285
|
+
rescue
|
286
|
+
puts "\nThe server sent out an Error:".red
|
287
|
+
puts clean_html(response.body)
|
288
|
+
exit 1
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
|
293
|
+
def cross_versions
|
294
|
+
headers = {}
|
295
|
+
base = URI.parse("#{$config['SERVERURL']}")
|
296
|
+
request = Net::HTTP::Post.new(base,headers)
|
297
|
+
request.basic_auth("cli", "loginNOauth")
|
298
|
+
request.body = JSON.generate({"action" => "version-check" })
|
299
|
+
response = Net::HTTP.start(base.hostname, $config['PORT'],
|
300
|
+
:timeout => $config['CALL_TIMEOUT'],
|
301
|
+
:use_ssl => base.scheme == "https",
|
302
|
+
:verify_mode => OpenSSL::SSL::VERIFY_PEER,
|
303
|
+
:ca_file => $config['CA_TRUST']
|
304
|
+
) do |http|
|
305
|
+
http.request(request)
|
306
|
+
end
|
307
|
+
begin
|
308
|
+
list = JSON.parse(response.body)
|
309
|
+
return list
|
310
|
+
# if list['error']
|
311
|
+
# return false
|
312
|
+
# end
|
313
|
+
# if list['success']
|
314
|
+
# return true
|
315
|
+
# end
|
316
|
+
rescue
|
317
|
+
puts "\nThe server sent out an Error:".red
|
318
|
+
puts clean_html(response.body)
|
319
|
+
exit 1
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
256
323
|
def delete_user(username)
|
257
324
|
headers = {}
|
258
325
|
if $config['TOKEN']
|
@@ -285,3 +352,10 @@ def delete_user(username)
|
|
285
352
|
exit 1
|
286
353
|
end
|
287
354
|
end
|
355
|
+
|
356
|
+
def local_version
|
357
|
+
puts "This CLI library is running version: #{VERSION_SIGN}"
|
358
|
+
return
|
359
|
+
end
|
360
|
+
|
361
|
+
VERSION_SIGN="0.0.19"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phoseum-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julio C Hegedus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yaml
|