MuranoCLI 3.2.0.beta.9 → 3.2.1.pre.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Rakefile +5 -0
- data/dockers/README.rst +7 -0
- data/dockers/RELEASE.rst +6 -3
- data/dockers/docker-test.sh +45 -17
- data/docs/completions/murano_completion-bash +211 -86
- data/lib/MrMurano/Account.rb +72 -4
- data/lib/MrMurano/Business.rb +163 -2
- data/lib/MrMurano/Commander-Entry.rb +1 -2
- data/lib/MrMurano/Config.rb +19 -18
- data/lib/MrMurano/Content.rb +26 -19
- data/lib/MrMurano/Gateway.rb +51 -10
- data/lib/MrMurano/ReCommander.rb +1 -1
- data/lib/MrMurano/Solution-Services.rb +80 -35
- data/lib/MrMurano/Solution-Users.rb +1 -0
- data/lib/MrMurano/SyncRoot.rb +10 -3
- data/lib/MrMurano/SyncUpDown-Core.rb +47 -36
- data/lib/MrMurano/SyncUpDown-Item.rb +46 -14
- data/lib/MrMurano/SyncUpDown.rb +22 -20
- data/lib/MrMurano/Webservice-Endpoint.rb +20 -18
- data/lib/MrMurano/Webservice-File.rb +63 -20
- data/lib/MrMurano/commands/business.rb +14 -1
- data/lib/MrMurano/commands/child.rb +148 -0
- data/lib/MrMurano/commands/devices.rb +298 -149
- data/lib/MrMurano/commands/element.rb +2 -1
- data/lib/MrMurano/commands/globals.rb +3 -0
- data/lib/MrMurano/commands/network.rb +152 -33
- data/lib/MrMurano/commands/sync.rb +2 -2
- data/lib/MrMurano/commands.rb +1 -0
- data/lib/MrMurano/verbosing.rb +13 -2
- data/lib/MrMurano/version.rb +1 -1
- data/spec/Account_spec.rb +43 -11
- data/spec/Content_spec.rb +5 -3
- data/spec/GatewayBase_spec.rb +1 -1
- data/spec/GatewayDevice_spec.rb +47 -8
- data/spec/GatewayResource_spec.rb +1 -1
- data/spec/GatewaySettings_spec.rb +1 -1
- data/spec/HttpAuthed_spec.rb +17 -3
- data/spec/ProjectFile_spec.rb +59 -23
- data/spec/Setting_spec.rb +2 -1
- data/spec/Solution-ServiceConfig_spec.rb +1 -1
- data/spec/Solution-ServiceEventHandler_spec.rb +27 -20
- data/spec/Solution-ServiceModules_spec.rb +7 -5
- data/spec/Solution-UsersRoles_spec.rb +7 -1
- data/spec/Solution_spec.rb +9 -1
- data/spec/SyncRoot_spec.rb +5 -5
- data/spec/SyncUpDown_spec.rb +262 -211
- data/spec/Verbosing_spec.rb +49 -8
- data/spec/Webservice-Cors_spec.rb +10 -1
- data/spec/Webservice-Endpoint_spec.rb +84 -65
- data/spec/Webservice-File_spec.rb +16 -11
- data/spec/Webservice-Setting_spec.rb +7 -1
- data/spec/_workspace.rb +9 -0
- data/spec/cmd_business_spec.rb +5 -10
- data/spec/cmd_common.rb +67 -32
- data/spec/cmd_config_spec.rb +9 -14
- data/spec/cmd_content_spec.rb +15 -26
- data/spec/cmd_cors_spec.rb +9 -12
- data/spec/cmd_device_spec.rb +31 -45
- data/spec/cmd_domain_spec.rb +12 -10
- data/spec/cmd_element_spec.rb +18 -17
- data/spec/cmd_exchange_spec.rb +1 -4
- data/spec/cmd_init_spec.rb +56 -72
- data/spec/cmd_keystore_spec.rb +17 -26
- data/spec/cmd_link_spec.rb +13 -17
- data/spec/cmd_password_spec.rb +9 -10
- data/spec/cmd_setting_application_spec.rb +95 -68
- data/spec/cmd_setting_product_spec.rb +59 -37
- data/spec/cmd_status_spec.rb +46 -84
- data/spec/cmd_syncdown_application_spec.rb +28 -50
- data/spec/cmd_syncdown_both_spec.rb +44 -93
- data/spec/cmd_syncdown_unit_spec.rb +858 -0
- data/spec/cmd_syncup_spec.rb +21 -56
- data/spec/cmd_token_spec.rb +0 -3
- data/spec/cmd_usage_spec.rb +15 -10
- data/spec/dry_run_formatter.rb +1 -0
- data/spec/fixtures/dumped_config +4 -4
- data/spec/spec_helper.rb +3 -0
- metadata +4 -2
@@ -185,7 +185,8 @@ class ElementCmd
|
|
185
185
|
# And account for the middle column split.
|
186
186
|
width_taken += ' | '.length
|
187
187
|
width_taken += flatkeys.max_by(&:length).length
|
188
|
-
term_width
|
188
|
+
term_width = MrMurano::Pretties::TERM_WIDTH
|
189
|
+
term_width = 80 unless term_width != 0
|
189
190
|
width_avail = term_width - width_taken
|
190
191
|
end
|
191
192
|
width_avail
|
@@ -12,7 +12,8 @@ require 'MrMurano/ReCommander'
|
|
12
12
|
command :network do |c|
|
13
13
|
c.syntax = %(murano network)
|
14
14
|
c.summary = %(About network)
|
15
|
-
c.description = %(Commands for working with enterprise business networks.
|
15
|
+
c.description = %(Commands for working with enterprise business networks.
|
16
|
+
Note: See 'Murano child' commands for working with network child businesses)
|
16
17
|
c.project_not_required = true
|
17
18
|
c.subcmdgrouphelp = true
|
18
19
|
c.action do |_args, _options|
|
@@ -22,23 +23,25 @@ command :network do |c|
|
|
22
23
|
end
|
23
24
|
|
24
25
|
# View a business network
|
25
|
-
command 'network
|
26
|
-
c.syntax = %(murano network
|
26
|
+
command 'network show' do |c|
|
27
|
+
c.syntax = %(murano network show)
|
27
28
|
c.summary = %(View an enterprise business network)
|
28
29
|
c.description = %(
|
29
30
|
View business network belonging to an enterprise parent business.
|
30
31
|
).strip
|
31
|
-
c.example %(
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
c.example %(
|
33
|
+
View a business network using the config file's business.id
|
34
|
+
).strip, 'murano network show'
|
35
|
+
c.example %(
|
36
|
+
View a business network using a passed in business.id
|
37
|
+
).strip, 'murano network show -c business.id=<BUSINESS_ID>'
|
35
38
|
c.project_not_required = true
|
36
39
|
c.action do |_args, _options|
|
37
|
-
|
40
|
+
show_business_network
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
|
-
def
|
44
|
+
def show_business_network
|
42
45
|
biz = MrMurano::Business.new
|
43
46
|
biz.must_business_id!
|
44
47
|
MrMurano::Verbose.whirly_start(
|
@@ -48,19 +51,9 @@ def view_business_network
|
|
48
51
|
MrMurano::Verbose.whirly_stop
|
49
52
|
|
50
53
|
must_business_network!(business_network)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
'Child Business Tier',
|
55
|
-
'Child Business Price',
|
56
|
-
]
|
57
|
-
table.add_separator
|
58
|
-
table.add_row [
|
59
|
-
business_network[:name],
|
60
|
-
business_network[:tier][:id],
|
61
|
-
business_network[:tier][:price],
|
62
|
-
]
|
63
|
-
puts table
|
54
|
+
puts('Network Name: ' + business_network[:name])
|
55
|
+
puts('Child Business Tier: ' + business_network[:tier][:id])
|
56
|
+
puts('Child Business Price: ' + business_network[:tier][:price].to_s)
|
64
57
|
end
|
65
58
|
|
66
59
|
def must_business_network!(business_network)
|
@@ -78,7 +71,7 @@ def must_business_network!(business_network)
|
|
78
71
|
'Error with business network.'
|
79
72
|
)
|
80
73
|
end
|
81
|
-
exit
|
74
|
+
exit 1
|
82
75
|
end
|
83
76
|
|
84
77
|
# Configure/Update a business network
|
@@ -88,15 +81,17 @@ command 'network configure' do |c|
|
|
88
81
|
c.description = %(
|
89
82
|
Configure or update the name of an enterprise business network.
|
90
83
|
).strip
|
91
|
-
c.example %(
|
92
|
-
|
93
|
-
|
94
|
-
|
84
|
+
c.example %(
|
85
|
+
Configure a business network using the config file's business.id
|
86
|
+
).strip, 'murano network configure <NETWORK_NAME>'
|
87
|
+
c.example %(
|
88
|
+
Configure a business network using a passed in business.id
|
89
|
+
).strip, 'murano network configure <NETWORK_NAME> -c business.id=<BUSINESS_ID>'
|
95
90
|
c.project_not_required = true
|
96
91
|
|
97
92
|
c.action do |args, _options|
|
98
93
|
if args.empty?
|
99
|
-
MrMurano::Verbose.error
|
94
|
+
MrMurano::Verbose.error 'Please include a network name.'
|
100
95
|
exit 1
|
101
96
|
end
|
102
97
|
configure_business_network(args)
|
@@ -110,11 +105,135 @@ Configure or update the name of an enterprise business network.
|
|
110
105
|
response = biz.configure_business_network(biz.bid, network_name)
|
111
106
|
MrMurano::Verbose.whirly_stop
|
112
107
|
return unless response.nil?
|
113
|
-
MrMurano::Verbose.error
|
114
|
-
exit
|
108
|
+
MrMurano::Verbose.error 'Error configuring business network.'
|
109
|
+
exit 1
|
115
110
|
end
|
116
111
|
end
|
117
112
|
|
118
|
-
#
|
119
|
-
|
120
|
-
|
113
|
+
# View All Network Children
|
114
|
+
command 'network children' do |c|
|
115
|
+
c.syntax = %(murano network children)
|
116
|
+
c.summary = %(View all of the child businesses in a business network.)
|
117
|
+
c.description = %(
|
118
|
+
View all of the child businesses in a business network.
|
119
|
+
).strip
|
120
|
+
c.example %(
|
121
|
+
View all of the child businesses in a business network
|
122
|
+
).strip, 'murano network children'
|
123
|
+
c.example %(
|
124
|
+
View all of the child businesses in a business network using a passed in business.id
|
125
|
+
).strip, 'murano network children -c business.id=<PARENT_BUSINESS_ID>'
|
126
|
+
c.project_not_required = true
|
127
|
+
|
128
|
+
c.action do |_args, _options|
|
129
|
+
view_child_businesses
|
130
|
+
end
|
131
|
+
|
132
|
+
def view_child_businesses
|
133
|
+
biz = MrMurano::Business.new
|
134
|
+
biz.must_business_id!
|
135
|
+
MrMurano::Verbose.whirly_start 'Fetching network child businesses...'
|
136
|
+
business_network = biz.get_business_network(biz.bid)
|
137
|
+
child_businesses = biz.view_child_businesses(biz.bid)
|
138
|
+
MrMurano::Verbose.whirly_stop
|
139
|
+
|
140
|
+
table = Terminal::Table.new
|
141
|
+
table.title = 'Business Network Name: ' + business_network[:name]
|
142
|
+
table.add_row [
|
143
|
+
'Child Business ID',
|
144
|
+
'Child Business Name',
|
145
|
+
'Email',
|
146
|
+
'Contact',
|
147
|
+
'Number of Members',
|
148
|
+
]
|
149
|
+
table.add_separator
|
150
|
+
|
151
|
+
child_businesses.each do |child|
|
152
|
+
table.add_row [
|
153
|
+
child[:bizid],
|
154
|
+
child[:name],
|
155
|
+
child[:email],
|
156
|
+
child[:contact],
|
157
|
+
child[:members].length,
|
158
|
+
]
|
159
|
+
end
|
160
|
+
puts table
|
161
|
+
|
162
|
+
return unless child_businesses.nil?
|
163
|
+
MrMurano::Verbose.error 'Error fetching network child businesses.'
|
164
|
+
exit 1
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# Create Business Network Child Business
|
169
|
+
command 'network new' do |c|
|
170
|
+
c.syntax = %(murano network new <CHILD_BUSINESS_NAME>)
|
171
|
+
c.summary = %(Create a new child business.)
|
172
|
+
c.description = %(Create a new child business.)
|
173
|
+
c.example %(
|
174
|
+
Create a new network child business using the config file's parent business.id
|
175
|
+
).strip, 'murano network new <CHILD_BUSINESS_NAME>'
|
176
|
+
c.example %(
|
177
|
+
Create a new network child business using a passed in parent business.id
|
178
|
+
).strip, 'murano network new <CHILD_BUSINESS_NAME> -c business.id=<PARENT_BUSINESS_ID>'
|
179
|
+
c.project_not_required = true
|
180
|
+
|
181
|
+
c.action do |args, _options|
|
182
|
+
if args.empty?
|
183
|
+
MrMurano::Verbose.error 'Please include a child business name.'
|
184
|
+
exit 1
|
185
|
+
end
|
186
|
+
add_child_business(args)
|
187
|
+
end
|
188
|
+
|
189
|
+
def add_child_business(args)
|
190
|
+
child_biz_name = args[0]
|
191
|
+
biz = MrMurano::Business.new
|
192
|
+
biz.must_business_id!
|
193
|
+
MrMurano::Verbose.whirly_start 'Creating network child business...'
|
194
|
+
response = biz.add_network_child_business(biz.bid, child_biz_name)
|
195
|
+
|
196
|
+
MrMurano::Verbose.whirly_stop
|
197
|
+
return unless response.nil?
|
198
|
+
MrMurano::Verbose.error 'Error creating network child business.'
|
199
|
+
exit 1
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Delete Business Network Child Business
|
204
|
+
command 'network delete' do |c|
|
205
|
+
c.syntax = %(murano network delete <CHILD_BUSINESS_ID>)
|
206
|
+
c.summary = %(Delete a child business.)
|
207
|
+
c.description = %(
|
208
|
+
Delete child business.
|
209
|
+
).strip
|
210
|
+
c.example %(
|
211
|
+
Delete a network child business using the config file's parent business.id
|
212
|
+
).strip, 'murano network delete <CHILD_BUSINESS_ID>'
|
213
|
+
c.example %(
|
214
|
+
Delete a network child business using a passed in parent business.id
|
215
|
+
).strip, 'murano network delete <CHILD_BUSINESS_ID> -c business.id=<PARENT_BUSINESS_ID>'
|
216
|
+
c.project_not_required = true
|
217
|
+
|
218
|
+
c.action do |args, _options|
|
219
|
+
if args.empty?
|
220
|
+
MrMurano::Verbose.error 'Please include a child business ID.'
|
221
|
+
exit 1
|
222
|
+
end
|
223
|
+
delete_child_business(args)
|
224
|
+
end
|
225
|
+
|
226
|
+
def delete_child_business(args)
|
227
|
+
child_biz_id = args[0]
|
228
|
+
biz = MrMurano::Business.new
|
229
|
+
biz.must_business_id!
|
230
|
+
MrMurano::Verbose.whirly_start 'Deleting network child business...'
|
231
|
+
response = biz.delete_child_business(biz.bid, child_biz_id)
|
232
|
+
MrMurano::Verbose.whirly_stop
|
233
|
+
return unless response.nil?
|
234
|
+
MrMurano::Verbose.error 'Error deleting network child business.'
|
235
|
+
exit 1
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
|
@@ -17,7 +17,7 @@ def sync_add_options(cmd, locale)
|
|
17
17
|
cmd.option '--ignore-errors', %(Don't die on sync errors)
|
18
18
|
end
|
19
19
|
|
20
|
-
def syncdown_files(options, args=
|
20
|
+
def syncdown_files(options, args=[])
|
21
21
|
args = [] if args.nil?
|
22
22
|
num_synced = 0
|
23
23
|
MrMurano::SyncRoot.instance.each_filtered(options) do |_name, _type, klass, desc|
|
@@ -76,7 +76,7 @@ alias_command 'pull product', 'syncdown', '--no-delete', '--type', 'product'
|
|
76
76
|
alias_command 'application pull', 'syncdown', '--no-delete', '--type', 'application'
|
77
77
|
alias_command 'product pull', 'syncdown', '--no-delete', '--type', 'product'
|
78
78
|
|
79
|
-
def syncup_files(options, args=
|
79
|
+
def syncup_files(options, args=[])
|
80
80
|
MrMurano::SyncRoot.instance.each_filtered(options) do |_name, _type, klass, desc|
|
81
81
|
MrMurano::Verbose.whirly_msg "Syncing #{Inflecto.pluralize(desc)}..."
|
82
82
|
sol = klass.new
|
data/lib/MrMurano/commands.rb
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
# murano completion > docs/completions/murano_completion-bash
|
12
12
|
#require 'MrMurano/commands/completion'
|
13
13
|
|
14
|
+
require 'MrMurano/commands/child'
|
14
15
|
require 'MrMurano/commands/business'
|
15
16
|
require 'MrMurano/commands/config'
|
16
17
|
require 'MrMurano/commands/content'
|
data/lib/MrMurano/verbosing.rb
CHANGED
@@ -53,6 +53,17 @@ module MrMurano
|
|
53
53
|
whirly_interject { warn(HighLine.color(msg, :red)) }
|
54
54
|
end
|
55
55
|
|
56
|
+
def assert(condition, msg='')
|
57
|
+
MrMurano::Verbose.assert(condition, msg)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.assert(condition, msg='')
|
61
|
+
return if condition
|
62
|
+
msg = "Assertion raised! #{caller[1]}\n" + msg
|
63
|
+
whirly_interject { warn(HighLine.color(msg, :red)) }
|
64
|
+
raise msg
|
65
|
+
end
|
66
|
+
|
56
67
|
## Output tabular data
|
57
68
|
# +data+:: Data to write. Preferably a Hash with :headers and :rows
|
58
69
|
# +ios+:: Output stream to write to, if nil, then use $stdout
|
@@ -64,7 +75,7 @@ module MrMurano
|
|
64
75
|
MrMurano::Verbose.tabularize(data, ios)
|
65
76
|
end
|
66
77
|
|
67
|
-
def self.tabularize(data, ios=nil)
|
78
|
+
def self.tabularize(data, ios=nil, no_quotes: false)
|
68
79
|
fmt = $cfg['tool.outformat']
|
69
80
|
ios = $stdout if ios.nil?
|
70
81
|
cols = nil
|
@@ -93,7 +104,7 @@ module MrMurano
|
|
93
104
|
ios,
|
94
105
|
headers: cols,
|
95
106
|
write_headers: !cols.empty?,
|
96
|
-
force_quotes:
|
107
|
+
force_quotes: !no_quotes,
|
97
108
|
) do |csv|
|
98
109
|
# MAYBE/2017-07-02: Does shover operator work on frozen string literals?
|
99
110
|
rows.each { |v| csv << v }
|
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.2.
|
29
|
+
VERSION = '3.2.1.pre.beta.3'
|
30
30
|
EXE_NAME = File.basename($PROGRAM_NAME)
|
31
31
|
SIGN_UP_URL = 'https://exosite.com/signup/'
|
32
32
|
end
|
data/spec/Account_spec.rb
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
# Unauthorized copying of this file is strictly prohibited.
|
7
7
|
|
8
8
|
require 'highline/import'
|
9
|
+
require 'webmock'
|
10
|
+
|
9
11
|
require 'MrMurano/version'
|
10
12
|
require 'MrMurano/Account'
|
11
13
|
require 'MrMurano/Config'
|
@@ -16,6 +18,7 @@ require 'HttpAuthed_spec'
|
|
16
18
|
|
17
19
|
RSpec.describe MrMurano::Account, 'token' do
|
18
20
|
include_context 'WORKSPACE'
|
21
|
+
|
19
22
|
before(:example) do
|
20
23
|
$cfg = MrMurano::Config.new
|
21
24
|
$cfg.load
|
@@ -32,6 +35,9 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
32
35
|
# using user.name from test runner's ~/.murano/config.
|
33
36
|
$cfg.unload(:env)
|
34
37
|
|
38
|
+
# Reset the Net::HTTP object, which was configured with the old net.host, etc.
|
39
|
+
MrMurano::HttpAuthed.instance.http_reset
|
40
|
+
|
35
41
|
stub_request_email_password
|
36
42
|
|
37
43
|
$project = MrMurano::ProjectFile.new
|
@@ -42,14 +48,12 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
42
48
|
|
43
49
|
after(:example) do
|
44
50
|
@acc.token_reset
|
51
|
+
WebMock.reset!
|
45
52
|
end
|
46
53
|
|
47
54
|
context 'Get login info' do
|
48
55
|
before(:example) do
|
49
|
-
@pswd =
|
50
|
-
allow(@pswd).to receive(:load).and_return(nil)
|
51
|
-
allow(@pswd).to receive(:save).and_return(nil)
|
52
|
-
allow(MrMurano::Passwords).to receive(:new).and_return(@pswd)
|
56
|
+
@pswd = create_instance_double_passwords
|
53
57
|
end
|
54
58
|
|
55
59
|
it 'Asks for nothing' do
|
@@ -66,7 +70,9 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
66
70
|
$cfg['user.name'] = nil
|
67
71
|
expect($terminal).to receive(:ask).once.and_return('bob')
|
68
72
|
expect(@acc).to receive(:error).once
|
69
|
-
expect($cfg).to receive(:set).with(
|
73
|
+
expect($cfg).to receive(:set).with(
|
74
|
+
'user.name', 'bob', :user,
|
75
|
+
).once.and_call_original
|
70
76
|
expect(@pswd).to receive(:get).once.and_return('built')
|
71
77
|
|
72
78
|
ret = @acc.login_info
|
@@ -76,7 +82,9 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
76
82
|
it 'Asks for password' do
|
77
83
|
@acc.credentials_reset
|
78
84
|
$cfg['user.name'] = 'bob'
|
79
|
-
expect(@pswd).to receive(:get).with(
|
85
|
+
expect(@pswd).to receive(:get).with(
|
86
|
+
'bizapi.hosted.exosite.io', 'bob',
|
87
|
+
).once.and_return(nil)
|
80
88
|
expect(@acc).to receive(:error).once
|
81
89
|
expect($terminal).to receive(:ask).once.and_return('dog')
|
82
90
|
$cfg['auth.persist-basic'] = true
|
@@ -107,6 +115,9 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
107
115
|
|
108
116
|
ret = @acc.token
|
109
117
|
expect(ret).to eq('ABCDEFGHIJKLMNOP')
|
118
|
+
|
119
|
+
# Remove all stub_request mocks.
|
120
|
+
WebMock.reset!
|
110
121
|
end
|
111
122
|
|
112
123
|
it 'gets an error' do
|
@@ -115,10 +126,14 @@ RSpec.describe MrMurano::Account, 'token' do
|
|
115
126
|
.to_return(status: 401, body: {}.to_json)
|
116
127
|
|
117
128
|
# Note that we stub out error and warning so nothing gets output.
|
118
|
-
expect(
|
129
|
+
expect(
|
130
|
+
MrMurano::HttpAuthed.instance
|
131
|
+
).to receive(:error).exactly(3).times.and_return(nil)
|
119
132
|
# The warning is about ENV['MURANO_PASSWORD'] specifying the password.
|
120
133
|
expect(MrMurano::HttpAuthed.instance).to receive(:warning).once.and_return(nil)
|
121
134
|
expect { @acc.token }.to raise_error(SystemExit).and output(//).to_stderr
|
135
|
+
|
136
|
+
WebMock.reset!
|
122
137
|
end
|
123
138
|
|
124
139
|
it 'uses existing token' do
|
@@ -147,13 +162,21 @@ RSpec.describe MrMurano::Account do
|
|
147
162
|
$cfg['business.id'] = 'XYZxyz'
|
148
163
|
$cfg['product.id'] = 'XYZ'
|
149
164
|
$cfg['user.name'] = 'BoB@place.net'
|
165
|
+
|
166
|
+
# Reset the Net::HTTP object, which was configured with the old net.host, etc.
|
167
|
+
MrMurano::HttpAuthed.instance.http_reset
|
168
|
+
|
169
|
+
# Reset the Http mocks (probably not necessary).
|
170
|
+
WebMock.reset!
|
150
171
|
stub_request_email_password
|
151
172
|
|
152
173
|
@acc = MrMurano::Account.new
|
153
174
|
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
154
175
|
end
|
176
|
+
|
155
177
|
after(:example) do
|
156
178
|
ENV['MURANO_CONFIGFILE'] = @saved_cfg
|
179
|
+
WebMock.reset!
|
157
180
|
end
|
158
181
|
|
159
182
|
it 'initializes' do
|
@@ -172,8 +195,10 @@ RSpec.describe MrMurano::Account do
|
|
172
195
|
role: 'admin',
|
173
196
|
name: 'MPS', },
|
174
197
|
]
|
175
|
-
stub_request(
|
176
|
-
|
198
|
+
stub_request(
|
199
|
+
:get,
|
200
|
+
'https://bizapi.hosted.exosite.io/api:1/user/BoB@place.net/membership/',
|
201
|
+
).to_return(body: bizlist)
|
177
202
|
|
178
203
|
buslist = []
|
179
204
|
buslist << MrMurano::Business.new(bizlist[0])
|
@@ -181,8 +206,11 @@ RSpec.describe MrMurano::Account do
|
|
181
206
|
|
182
207
|
$cfg['user.name'] = 'BoB@place.net'
|
183
208
|
stub_request_email_password
|
209
|
+
|
184
210
|
ret = @acc.businesses
|
185
211
|
expect(ret).to eq(buslist)
|
212
|
+
|
213
|
+
WebMock.reset!
|
186
214
|
end
|
187
215
|
|
188
216
|
it 'asks for account when missing' do
|
@@ -194,8 +222,10 @@ RSpec.describe MrMurano::Account do
|
|
194
222
|
role: 'admin',
|
195
223
|
name: 'MPS', },
|
196
224
|
]
|
197
|
-
stub_request(
|
198
|
-
|
225
|
+
stub_request(
|
226
|
+
:get,
|
227
|
+
'https://bizapi.hosted.exosite.io/api:1/user/BoB@place.net/membership/',
|
228
|
+
).to_return(body: bizlist)
|
199
229
|
|
200
230
|
buslist = []
|
201
231
|
buslist << MrMurano::Business.new(bizlist[0])
|
@@ -209,6 +239,8 @@ RSpec.describe MrMurano::Account do
|
|
209
239
|
|
210
240
|
ret = @acc.businesses
|
211
241
|
expect(ret).to eq(buslist)
|
242
|
+
|
243
|
+
WebMock.reset!
|
212
244
|
end
|
213
245
|
end
|
214
246
|
end
|