MuranoCLI 3.1.0 → 3.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.trustme.sh +6 -2
- data/lib/MrMurano/Account.rb +8 -262
- data/lib/MrMurano/AccountBase.rb +214 -0
- data/lib/MrMurano/Business.rb +3 -19
- data/lib/MrMurano/Config-Migrate.rb +0 -4
- data/lib/MrMurano/Config.rb +159 -70
- data/lib/MrMurano/Content.rb +3 -2
- data/lib/MrMurano/Exchange.rb +3 -1
- data/lib/MrMurano/Gateway.rb +3 -2
- data/lib/MrMurano/HttpAuthed.rb +287 -0
- data/lib/MrMurano/Passwords.rb +82 -35
- data/lib/MrMurano/ReCommander.rb +2 -0
- data/lib/MrMurano/Solution.rb +3 -2
- data/lib/MrMurano/SyncRoot.rb +2 -0
- data/lib/MrMurano/Webservice.rb +3 -2
- data/lib/MrMurano/commands/business.rb +2 -2
- data/lib/MrMurano/commands/globals.rb +41 -0
- data/lib/MrMurano/commands/init.rb +1 -1
- data/lib/MrMurano/commands/login.rb +30 -6
- data/lib/MrMurano/commands/logs.rb +1 -6
- data/lib/MrMurano/commands/password.rb +15 -11
- data/lib/MrMurano/commands/show.rb +1 -1
- data/lib/MrMurano/commands/token.rb +209 -0
- data/lib/MrMurano/commands.rb +1 -0
- data/lib/MrMurano/http.rb +13 -24
- data/lib/MrMurano/version.rb +1 -1
- data/lib/MrMurano.rb +1 -0
- data/spec/Account_spec.rb +8 -8
- data/spec/Http_spec.rb +0 -1
- data/spec/cmd_token_spec.rb +56 -0
- data/spec/fixtures/websocket/README.rst +2 -2
- metadata +8 -4
data/lib/MrMurano/commands.rb
CHANGED
data/lib/MrMurano/http.rb
CHANGED
@@ -13,26 +13,25 @@ require 'uri'
|
|
13
13
|
# 2017-06-07: [lb] getting "execution expired (Net::OpenTimeout)" on http.start.
|
14
14
|
# Suggestions online say to load the pure-Ruby DNS implementation, resolv.rb.
|
15
15
|
require 'resolv-replace'
|
16
|
+
|
16
17
|
require 'MrMurano/progress'
|
18
|
+
require 'MrMurano/verbosing'
|
17
19
|
|
18
20
|
module MrMurano
|
19
21
|
module Http
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#raise 'Not logged in!' if @token.nil?
|
25
|
-
ensure_token! @token
|
26
|
-
# MAYBE: Check that ADC is enabled on the business. If not, tell
|
27
|
-
# user to run Murano 2.x. See adc_compat_check for comments.
|
28
|
-
#acc.adc_compat_check
|
29
|
-
@token
|
22
|
+
include Verbose
|
23
|
+
|
24
|
+
def host
|
25
|
+
$cfg['net.host'].to_s
|
30
26
|
end
|
31
27
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
def user
|
29
|
+
$cfg['user.name'].to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
# Default endpoint unless Class overrides it.
|
33
|
+
def endpoint(path)
|
34
|
+
URI($cfg['net.protocol'] + '://' + host + '/api:1/' + path.to_s)
|
36
35
|
end
|
37
36
|
|
38
37
|
def json_opts
|
@@ -78,11 +77,6 @@ module MrMurano
|
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
|
-
# Default endpoint unless Class overrides it.
|
82
|
-
def endpoint(path)
|
83
|
-
URI($cfg['net.protocol'] + '://' + $cfg['net.host'] + '/api:1/' + path.to_s)
|
84
|
-
end
|
85
|
-
|
86
80
|
def http
|
87
81
|
uri = URI($cfg['net.protocol'] + '://' + $cfg['net.host'])
|
88
82
|
if !defined?(@http) || @http.nil?
|
@@ -109,10 +103,6 @@ module MrMurano
|
|
109
103
|
|
110
104
|
def add_headers(request)
|
111
105
|
request.content_type = 'application/json'
|
112
|
-
# 2017-08-14: MrMurano::Account overrides the token method, and
|
113
|
-
# it doesn't exit if no token, and then we end up here.
|
114
|
-
ensure_token! token
|
115
|
-
request['Authorization'] = 'token ' + token unless token.to_s.empty?
|
116
106
|
request['User-Agent'] = "MrMurano/#{MrMurano::VERSION}"
|
117
107
|
request
|
118
108
|
end
|
@@ -152,7 +142,6 @@ module MrMurano
|
|
152
142
|
else
|
153
143
|
resp += (jsn || 'nil')
|
154
144
|
end
|
155
|
-
# assuming verbosing was included.
|
156
145
|
error resp
|
157
146
|
end
|
158
147
|
|
data/lib/MrMurano/version.rb
CHANGED
@@ -26,7 +26,7 @@ module MrMurano
|
|
26
26
|
# '3.0.0-beta.2' is changed to '3.0.0.pre.beta.2'
|
27
27
|
# which breaks our build (which expects the version to match herein).
|
28
28
|
# So stick to using the '.pre.X' syntax, which ruby/gems knows.
|
29
|
-
VERSION = '3.
|
29
|
+
VERSION = '3.2.0.beta.1'
|
30
30
|
EXE_NAME = File.basename($PROGRAM_NAME)
|
31
31
|
SIGN_UP_URL = 'https://exosite.com/signup/'
|
32
32
|
end
|
data/lib/MrMurano.rb
CHANGED
data/spec/Account_spec.rb
CHANGED
@@ -26,7 +26,7 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
26
26
|
$project = MrMurano::ProjectFile.new
|
27
27
|
$project.load
|
28
28
|
|
29
|
-
@acc = MrMurano::Account.
|
29
|
+
@acc = MrMurano::Account.new
|
30
30
|
end
|
31
31
|
|
32
32
|
after(:example) do
|
@@ -69,7 +69,7 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
69
69
|
expect(@acc).to receive(:error).once
|
70
70
|
expect($terminal).to receive(:ask).once.and_return('dog')
|
71
71
|
expect(@pswd).to receive(:set).once.with('bizapi.hosted.exosite.io', 'bob', 'dog')
|
72
|
-
expect(@pswd).to receive(:set).once.with('bizapi.hosted.exosite.io', 'bob/
|
72
|
+
expect(@pswd).to receive(:set).once.with('bizapi.hosted.exosite.io', 'bob/token', nil)
|
73
73
|
# 2017-07-31: login_info may exit unless the command okays prompting for the password.
|
74
74
|
# (If we don't set this, login_info exits, which we'd want to
|
75
75
|
# catch with
|
@@ -112,16 +112,16 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'uses existing token' do
|
115
|
-
@acc.token_reset
|
115
|
+
@acc.token_reset
|
116
116
|
ret = @acc.token
|
117
|
-
expect(ret).to eq('
|
117
|
+
expect(ret).to eq('')
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'uses existing token, even with new instance' do
|
121
|
-
@acc.token_reset
|
122
|
-
acc = MrMurano::Account.
|
121
|
+
@acc.token_reset
|
122
|
+
acc = MrMurano::Account.new
|
123
123
|
ret = acc.token
|
124
|
-
expect(ret).to eq('
|
124
|
+
expect(ret).to eq('')
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
@@ -137,7 +137,7 @@ RSpec.describe MrMurano::Account do
|
|
137
137
|
$cfg['business.id'] = 'XYZxyz'
|
138
138
|
$cfg['product.id'] = 'XYZ'
|
139
139
|
|
140
|
-
@acc = MrMurano::Account.
|
140
|
+
@acc = MrMurano::Account.new
|
141
141
|
allow(@acc).to receive(:token).and_return('TTTTTTTTTT')
|
142
142
|
end
|
143
143
|
after(:example) do
|
data/spec/Http_spec.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright © 2016-2017 Exosite LLC. All Rights Reserved
|
2
|
+
# License: PROPRIETARY. See LICENSE.txt.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
6
|
+
# Unauthorized copying of this file is strictly prohibited.
|
7
|
+
|
8
|
+
require 'fileutils'
|
9
|
+
require 'open3'
|
10
|
+
|
11
|
+
require 'cmd_common'
|
12
|
+
require 'MrMurano/Config'
|
13
|
+
require 'MrMurano/commands/token'
|
14
|
+
|
15
|
+
RSpec.describe 'murano token', :cmd, :needs_password, :nondeterministic do
|
16
|
+
include_context 'CI_CMD'
|
17
|
+
|
18
|
+
context 'without project' do
|
19
|
+
it 'help' do
|
20
|
+
cmd_verify_help('token')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with project' do
|
25
|
+
#before(:example) { project_up }
|
26
|
+
#after(:example) { project_down }
|
27
|
+
|
28
|
+
def expect_token_host_user_table(stdout, stderr, num_cols: nil)
|
29
|
+
expect(stderr).to eq('')
|
30
|
+
lines = stdout.lines
|
31
|
+
# FIXME/2017-08-29: Is this too much detail??
|
32
|
+
# What about running test once, dumping output to file,
|
33
|
+
# and expecting same output next time?
|
34
|
+
# Outline of table. n columns. '+-----+-----+---...----+\n'
|
35
|
+
expect(lines[0]).to match(/^(\+-+){#{num_cols}}\+$/)
|
36
|
+
# Header.
|
37
|
+
expect(lines[1]).to match(/^\| Host/)
|
38
|
+
# Separator.
|
39
|
+
expect(lines[2]).to match(/^(\+-+){#{num_cols}}\+$/)
|
40
|
+
# Content. Starts with elementId.
|
41
|
+
(3..(lines.length - 2)).to_a.each do |line|
|
42
|
+
expect(lines[line]).to match(/^\| [0-9a-f]+ \| /)
|
43
|
+
end
|
44
|
+
expect(lines[-1]).to match(/^(\+-+){#{num_cols}}\+$/)
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'list' do
|
48
|
+
it 'as table' do
|
49
|
+
stdout, stderr = murano_command_run('token list')
|
50
|
+
# 2 columns: elementId, name, status, description.
|
51
|
+
expect_token_host_user_table(stdout, stderr, num_cols: 2)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MuranoCLI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Conrad Tadpol Tilstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: certified
|
@@ -478,6 +478,7 @@ files:
|
|
478
478
|
- docs/develop.rst
|
479
479
|
- lib/MrMurano.rb
|
480
480
|
- lib/MrMurano/Account.rb
|
481
|
+
- lib/MrMurano/AccountBase.rb
|
481
482
|
- lib/MrMurano/Business.rb
|
482
483
|
- lib/MrMurano/Commander-Entry.rb
|
483
484
|
- lib/MrMurano/Config-Migrate.rb
|
@@ -486,6 +487,7 @@ files:
|
|
486
487
|
- lib/MrMurano/Exchange-Element.rb
|
487
488
|
- lib/MrMurano/Exchange.rb
|
488
489
|
- lib/MrMurano/Gateway.rb
|
490
|
+
- lib/MrMurano/HttpAuthed.rb
|
489
491
|
- lib/MrMurano/Keystore.rb
|
490
492
|
- lib/MrMurano/Logs.rb
|
491
493
|
- lib/MrMurano/Mock.rb
|
@@ -537,6 +539,7 @@ files:
|
|
537
539
|
- lib/MrMurano/commands/status.rb
|
538
540
|
- lib/MrMurano/commands/sync.rb
|
539
541
|
- lib/MrMurano/commands/timeseries.rb
|
542
|
+
- lib/MrMurano/commands/token.rb
|
540
543
|
- lib/MrMurano/commands/tsdb.rb
|
541
544
|
- lib/MrMurano/commands/usage.rb
|
542
545
|
- lib/MrMurano/hash.rb
|
@@ -602,6 +605,7 @@ files:
|
|
602
605
|
- spec/cmd_syncdown_application_spec.rb
|
603
606
|
- spec/cmd_syncdown_both_spec.rb
|
604
607
|
- spec/cmd_syncup_spec.rb
|
608
|
+
- spec/cmd_token_spec.rb
|
605
609
|
- spec/cmd_usage_spec.rb
|
606
610
|
- spec/fixtures/.mrmuranorc
|
607
611
|
- spec/fixtures/ProjectFiles/invalid.yaml
|
@@ -661,9 +665,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
661
665
|
version: '2.0'
|
662
666
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
663
667
|
requirements:
|
664
|
-
- - "
|
668
|
+
- - ">"
|
665
669
|
- !ruby/object:Gem::Version
|
666
|
-
version:
|
670
|
+
version: 1.3.1
|
667
671
|
requirements: []
|
668
672
|
rubyforge_project:
|
669
673
|
rubygems_version: 2.7.4
|