MuranoCLI 3.0.2 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +30 -59
- data/Gemfile +9 -3
- data/MuranoCLI.gemspec +11 -4
- data/bin/murano +2 -90
- data/lib/MrMurano.rb +5 -1
- data/lib/MrMurano/{spec_commander.rb → Commander-Entry.rb} +1 -2
- data/lib/MrMurano/Solution.rb +12 -15
- data/lib/MrMurano/SolutionId.rb +1 -5
- data/lib/MrMurano/SyncAllowed.rb +2 -2
- data/lib/MrMurano/SyncUpDown.rb +6 -3
- data/lib/MrMurano/progress.rb +11 -2
- data/lib/MrMurano/verbosing.rb +3 -2
- data/lib/MrMurano/version.rb +2 -2
- data/spec/Account-Passwords_spec.rb +34 -48
- data/spec/Account_spec.rb +58 -63
- data/spec/Business_spec.rb +151 -139
- data/spec/ConfigFile_spec.rb +15 -11
- data/spec/ConfigMigrate_spec.rb +23 -12
- data/spec/Config_spec.rb +57 -54
- data/spec/Content_spec.rb +233 -201
- data/spec/GatewayBase_spec.rb +35 -27
- data/spec/GatewayDevice_spec.rb +149 -149
- data/spec/GatewayResource_spec.rb +115 -102
- data/spec/GatewaySettings_spec.rb +69 -62
- data/spec/Http_spec.rb +66 -56
- data/spec/MakePretties_spec.rb +82 -73
- data/spec/Mock_spec.rb +38 -29
- data/spec/ProjectFile_spec.rb +118 -106
- data/spec/Setting_spec.rb +24 -15
- data/spec/Solution-ServiceConfig_spec.rb +168 -140
- data/spec/Solution-ServiceEventHandler_spec.rb +186 -188
- data/spec/Solution-ServiceModules_spec.rb +314 -232
- data/spec/Solution-UsersRoles_spec.rb +136 -86
- data/spec/Solution_spec.rb +78 -50
- data/spec/SyncRoot_spec.rb +26 -24
- data/spec/SyncUpDown_spec.rb +268 -249
- data/spec/Verbosing_spec.rb +95 -93
- data/spec/Webservice-Cors_spec.rb +141 -95
- data/spec/Webservice-Endpoint_spec.rb +382 -346
- data/spec/Webservice-File_spec.rb +148 -109
- data/spec/Webservice-Setting_spec.rb +47 -41
- data/spec/cmd_business_spec.rb +17 -17
- data/spec/cmd_common.rb +27 -7
- data/spec/cmd_config_spec.rb +31 -20
- data/spec/cmd_content_spec.rb +80 -68
- data/spec/cmd_cors_spec.rb +11 -5
- data/spec/cmd_device_spec.rb +16 -14
- data/spec/cmd_domain_spec.rb +10 -8
- data/spec/cmd_exchange_spec.rb +3 -3
- data/spec/cmd_init_spec.rb +100 -101
- data/spec/cmd_keystore_spec.rb +17 -12
- data/spec/cmd_link_spec.rb +22 -37
- data/spec/cmd_password_spec.rb +11 -7
- data/spec/cmd_setting_application_spec.rb +47 -33
- data/spec/cmd_setting_product_spec.rb +32 -27
- data/spec/cmd_status_spec.rb +125 -114
- data/spec/cmd_syncdown_spec.rb +70 -65
- data/spec/cmd_syncup_spec.rb +19 -15
- data/spec/cmd_usage_spec.rb +14 -10
- metadata +29 -15
data/lib/MrMurano/verbosing.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Last Modified: 2017.
|
1
|
+
# Last Modified: 2017.09.12 /coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Copyright © 2016-2017 Exosite LLC.
|
@@ -9,6 +9,7 @@ require 'csv'
|
|
9
9
|
require 'highline'
|
10
10
|
require 'inflecto'
|
11
11
|
require 'json'
|
12
|
+
require 'os'
|
12
13
|
require 'paint'
|
13
14
|
require 'pp'
|
14
15
|
require 'terminal-table'
|
@@ -173,7 +174,7 @@ module MrMurano
|
|
173
174
|
end
|
174
175
|
|
175
176
|
def self.fancy_ticks(obj)
|
176
|
-
if $cfg.nil? || $cfg['tool.ascii']
|
177
|
+
if $cfg.nil? || $cfg['tool.ascii'] || OS.windows?
|
177
178
|
"'#{obj}'"
|
178
179
|
else
|
179
180
|
"‘#{obj}’"
|
data/lib/MrMurano/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Last Modified: 2017.
|
1
|
+
# Last Modified: 2017.09.13 /coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Copyright © 2016-2017 Exosite LLC.
|
@@ -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.0.
|
29
|
+
VERSION = '3.0.4'
|
30
30
|
EXE_NAME = File.basename($PROGRAM_NAME)
|
31
31
|
SIGN_UP_URL = 'https://exosite.com/signup/'
|
32
32
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
# Last Modified: 2017.
|
1
|
+
# Last Modified: 2017.09.12 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
# Copyright © 2016-2017 Exosite LLC.
|
4
5
|
# License: MIT. See LICENSE.txt.
|
@@ -9,12 +10,12 @@ require 'MrMurano/version'
|
|
9
10
|
require 'MrMurano/Account'
|
10
11
|
require '_workspace'
|
11
12
|
|
12
|
-
RSpec.describe MrMurano::Passwords,
|
13
|
-
# Weird: This tests works on its own without the
|
13
|
+
RSpec.describe MrMurano::Passwords, '#pwd' do
|
14
|
+
# Weird: This tests works on its own without the 'WORKSPACE',
|
14
15
|
# but when run with other tests, it fails. (2017-07-05: I think
|
15
16
|
# I just added the $cfg lines, because MrMurano::Passwords
|
16
17
|
# expects $cfg to be loaded... [lb].)
|
17
|
-
include_context
|
18
|
+
include_context 'WORKSPACE'
|
18
19
|
|
19
20
|
before(:example) do
|
20
21
|
@saved_cfg = ENV['MURANO_CONFIGFILE']
|
@@ -31,13 +32,13 @@ RSpec.describe MrMurano::Passwords, "#pwd" do
|
|
31
32
|
ENV['MURANO_CONFIGFILE'] = @saved_cfg
|
32
33
|
end
|
33
34
|
|
34
|
-
it
|
35
|
+
it 'Creates a file ' do
|
35
36
|
tmpfile = Dir.tmpdir + '/pwtest' # This way because Tempfile.new creates.
|
36
37
|
begin
|
37
|
-
pwd = MrMurano::Passwords.new(
|
38
|
+
pwd = MrMurano::Passwords.new(tmpfile)
|
38
39
|
pwd.save
|
39
40
|
|
40
|
-
expect(
|
41
|
+
expect(FileTest.exist?(tmpfile))
|
41
42
|
ensure
|
42
43
|
File.unlink(tmpfile) if File.exist? tmpfile
|
43
44
|
end
|
@@ -46,31 +47,31 @@ RSpec.describe MrMurano::Passwords, "#pwd" do
|
|
46
47
|
it "Creates a file in a directory that doesn't exist." do
|
47
48
|
tmpfile = Dir.tmpdir + '/deeper/pwtest' # This way because Tempfile.new creates.
|
48
49
|
begin
|
49
|
-
pwd = MrMurano::Passwords.new(
|
50
|
+
pwd = MrMurano::Passwords.new(tmpfile)
|
50
51
|
pwd.save
|
51
52
|
|
52
|
-
expect(
|
53
|
+
expect(FileTest.exist?(tmpfile))
|
53
54
|
ensure
|
54
55
|
File.unlink(tmpfile) if File.exist? tmpfile
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
58
|
-
it
|
59
|
+
it 'Loads a file' do
|
59
60
|
Tempfile.open('test') do |tf|
|
60
|
-
tf << %
|
61
|
+
tf << %(---
|
61
62
|
this.is.a.host:
|
62
63
|
user: password
|
63
|
-
|
64
|
+
)
|
64
65
|
tf.close
|
65
66
|
|
66
|
-
pwd = MrMurano::Passwords.new(
|
67
|
+
pwd = MrMurano::Passwords.new(tf.path)
|
67
68
|
pwd.load
|
68
69
|
ps = pwd.get('this.is.a.host', 'user')
|
69
70
|
expect(ps).to eq('password')
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
|
-
it
|
74
|
+
it 'Saves a file' do
|
74
75
|
Tempfile.open('pstest') do |tf|
|
75
76
|
tf.close
|
76
77
|
|
@@ -80,34 +81,31 @@ this.is.a.host:
|
|
80
81
|
|
81
82
|
File.open(tf.path) do |io|
|
82
83
|
data = io.read
|
83
|
-
expect(data).to eq(%
|
84
|
+
expect(data).to eq(%(---
|
84
85
|
this.is.a.host:
|
85
86
|
user3: passwords4
|
86
|
-
|
87
|
+
))
|
87
88
|
end
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
it
|
92
|
+
it 'Writes multiple hosts' do
|
92
93
|
Tempfile.open('pwtest') do |tf|
|
93
94
|
tf.close
|
94
95
|
|
95
96
|
pwd = MrMurano::Passwords.new(tf.path)
|
96
97
|
pwd.set('this.is.a.host', 'user3', 'passwords4')
|
97
98
|
pwd.save
|
98
|
-
pwd = nil
|
99
99
|
|
100
100
|
pwd = MrMurano::Passwords.new(tf.path)
|
101
101
|
pwd.load
|
102
102
|
ps = pwd.get('this.is.a.host', 'user3')
|
103
103
|
expect(ps).to eq('passwords4')
|
104
|
-
pwd = nil
|
105
104
|
|
106
105
|
pwd = MrMurano::Passwords.new(tf.path)
|
107
106
|
pwd.load
|
108
107
|
pwd.set('another.host', 'user9', 'passwords2')
|
109
108
|
pwd.save
|
110
|
-
pwd = nil
|
111
109
|
|
112
110
|
pwd = MrMurano::Passwords.new(tf.path)
|
113
111
|
pwd.load
|
@@ -115,25 +113,21 @@ this.is.a.host:
|
|
115
113
|
expect(ps).to eq('passwords4')
|
116
114
|
ps = pwd.get('another.host', 'user9')
|
117
115
|
expect(ps).to eq('passwords2')
|
118
|
-
pwd = nil
|
119
|
-
|
120
116
|
end
|
121
117
|
end
|
122
118
|
|
123
|
-
it
|
119
|
+
it 'Write multiple users to same host' do
|
124
120
|
Tempfile.open('pwstest') do |tf|
|
125
121
|
tf.close
|
126
122
|
|
127
123
|
pwd = MrMurano::Passwords.new(tf.path)
|
128
124
|
pwd.set('this.is.a.host', 'user3', 'passwords4')
|
129
125
|
pwd.save
|
130
|
-
pwd = nil
|
131
126
|
|
132
127
|
pwd = MrMurano::Passwords.new(tf.path)
|
133
128
|
pwd.load
|
134
129
|
pwd.set('this.is.a.host', 'user9', 'passwords2')
|
135
130
|
pwd.save
|
136
|
-
pwd = nil
|
137
131
|
|
138
132
|
pwd = MrMurano::Passwords.new(tf.path)
|
139
133
|
pwd.load
|
@@ -141,65 +135,57 @@ this.is.a.host:
|
|
141
135
|
expect(ps).to eq('passwords4')
|
142
136
|
ps = pwd.get('this.is.a.host', 'user9')
|
143
137
|
expect(ps).to eq('passwords2')
|
144
|
-
pwd = nil
|
145
|
-
|
146
138
|
end
|
147
139
|
end
|
148
140
|
|
149
|
-
it
|
141
|
+
it 'lists usernames' do
|
150
142
|
Tempfile.open('pwstest') do |tf|
|
151
143
|
tf.close
|
152
144
|
|
153
145
|
pwd = MrMurano::Passwords.new(tf.path)
|
154
146
|
pwd.set('this.is.a.host', 'user3', 'passwords4')
|
155
147
|
pwd.save
|
156
|
-
pwd = nil
|
157
148
|
|
158
149
|
pwd = MrMurano::Passwords.new(tf.path)
|
159
150
|
pwd.load
|
160
151
|
pwd.set('this.is.a.host', 'user9', 'passwords2')
|
161
152
|
pwd.save
|
162
|
-
pwd = nil
|
163
153
|
|
164
154
|
pwd = MrMurano::Passwords.new(tf.path)
|
165
155
|
pwd.load
|
166
156
|
ret = pwd.list
|
167
|
-
expect(ret).to match(
|
168
|
-
|
169
|
-
|
157
|
+
expect(ret).to match(
|
158
|
+
'this.is.a.host' => a_collection_containing_exactly('user9', 'user3')
|
159
|
+
)
|
170
160
|
end
|
171
161
|
end
|
172
162
|
|
173
|
-
|
174
|
-
it "removes username" do
|
163
|
+
it 'removes username' do
|
175
164
|
Tempfile.open('pwstest') do |tf|
|
176
165
|
tf.close
|
177
166
|
|
178
167
|
pwd = MrMurano::Passwords.new(tf.path)
|
179
168
|
pwd.set('this.is.a.host', 'user3', 'passwords4')
|
180
169
|
pwd.save
|
181
|
-
pwd = nil
|
182
170
|
|
183
171
|
pwd = MrMurano::Passwords.new(tf.path)
|
184
172
|
pwd.load
|
185
173
|
pwd.set('this.is.a.host', 'user9', 'passwords2')
|
186
174
|
pwd.save
|
187
|
-
pwd = nil
|
188
175
|
|
189
176
|
pwd = MrMurano::Passwords.new(tf.path)
|
190
177
|
pwd.load
|
191
178
|
pwd.remove('this.is.a.host', 'user3')
|
192
179
|
pwd.save
|
193
|
-
pwd = nil
|
194
180
|
|
195
181
|
pwd = MrMurano::Passwords.new(tf.path)
|
196
182
|
pwd.load
|
197
183
|
ret = pwd.list
|
198
|
-
expect(ret).to match(
|
184
|
+
expect(ret).to match('this.is.a.host' => ['user9'])
|
199
185
|
end
|
200
186
|
end
|
201
187
|
|
202
|
-
context
|
188
|
+
context 'Uses ENV' do
|
203
189
|
before(:example) do
|
204
190
|
ENV['MR_PASSWORD'] = nil
|
205
191
|
end
|
@@ -207,16 +193,16 @@ this.is.a.host:
|
|
207
193
|
ENV['MR_PASSWORD'] = nil
|
208
194
|
end
|
209
195
|
|
210
|
-
it
|
196
|
+
it 'Uses ENV instead' do
|
211
197
|
Tempfile.open('test') do |tf|
|
212
|
-
tf << %
|
198
|
+
tf << %(---
|
213
199
|
this.is.a.host:
|
214
200
|
user: password
|
215
|
-
|
201
|
+
)
|
216
202
|
tf.close
|
217
203
|
|
218
204
|
ENV['MURANO_PASSWORD'] = 'a test!'
|
219
|
-
pwd = MrMurano::Passwords.new(
|
205
|
+
pwd = MrMurano::Passwords.new(tf.path)
|
220
206
|
pwd.load
|
221
207
|
expect(pwd).not_to receive(:warning)
|
222
208
|
ps = pwd.get('this.is.a.host', 'user')
|
@@ -225,12 +211,12 @@ this.is.a.host:
|
|
225
211
|
end
|
226
212
|
end
|
227
213
|
|
228
|
-
it
|
214
|
+
it 'Uses ENV instead, even with empty file' do
|
229
215
|
Tempfile.open('test') do |tf|
|
230
216
|
tf.close
|
231
217
|
|
232
218
|
ENV['MURANO_PASSWORD'] = 'a test!'
|
233
|
-
pwd = MrMurano::Passwords.new(
|
219
|
+
pwd = MrMurano::Passwords.new(tf.path)
|
234
220
|
pwd.load
|
235
221
|
expect(pwd).not_to receive(:warning)
|
236
222
|
ps = pwd.get('this.is.a.host', 'user')
|
@@ -242,12 +228,12 @@ this.is.a.host:
|
|
242
228
|
end
|
243
229
|
end
|
244
230
|
|
245
|
-
it
|
231
|
+
it 'Warns about migrating' do
|
246
232
|
Tempfile.open('test') do |tf|
|
247
233
|
tf.close
|
248
234
|
|
249
235
|
ENV['MR_PASSWORD'] = 'a test!'
|
250
|
-
pwd = MrMurano::Passwords.new(
|
236
|
+
pwd = MrMurano::Passwords.new(tf.path)
|
251
237
|
pwd.load
|
252
238
|
expect(pwd).to receive(:warning).once
|
253
239
|
ps = pwd.get('this.is.a.host', 'user')
|
data/spec/Account_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# Last Modified: 2017.
|
1
|
+
# Last Modified: 2017.09.12 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
# Copyright © 2016-2017 Exosite LLC.
|
4
5
|
# License: MIT. See LICENSE.txt.
|
@@ -11,8 +12,8 @@ require 'MrMurano/Config'
|
|
11
12
|
require 'MrMurano/ProjectFile'
|
12
13
|
require '_workspace'
|
13
14
|
|
14
|
-
RSpec.describe MrMurano::Account,
|
15
|
-
include_context
|
15
|
+
RSpec.describe MrMurano::Account, 'token' do
|
16
|
+
include_context 'WORKSPACE'
|
16
17
|
before(:example) do
|
17
18
|
@saved_cfg = ENV['MURANO_CONFIGFILE']
|
18
19
|
ENV['MURANO_CONFIGFILE'] = nil
|
@@ -33,43 +34,39 @@ RSpec.describe MrMurano::Account, "token" do
|
|
33
34
|
ENV['MURANO_CONFIGFILE'] = @saved_cfg
|
34
35
|
end
|
35
36
|
|
36
|
-
context
|
37
|
+
context 'Get login info' do
|
37
38
|
before(:example) do
|
38
|
-
@pswd = instance_double(
|
39
|
+
@pswd = instance_double('MrMurano::Passwords')
|
39
40
|
allow(@pswd).to receive(:load).and_return(nil)
|
40
41
|
allow(@pswd).to receive(:save).and_return(nil)
|
41
42
|
allow(MrMurano::Passwords).to receive(:new).and_return(@pswd)
|
42
43
|
end
|
43
44
|
|
44
|
-
it
|
45
|
-
$cfg['user.name'] =
|
46
|
-
expect(@pswd).to receive(:get).once.and_return(
|
45
|
+
it 'Asks for nothing' do
|
46
|
+
$cfg['user.name'] = 'bob'
|
47
|
+
expect(@pswd).to receive(:get).once.and_return('built')
|
47
48
|
|
48
49
|
ret = @acc.login_info
|
49
|
-
expect(ret).to eq(
|
50
|
-
:email => "bob", :password=>"built"
|
51
|
-
})
|
50
|
+
expect(ret).to eq(email: 'bob', password: 'built')
|
52
51
|
end
|
53
52
|
|
54
|
-
it
|
53
|
+
it 'Asks for user name' do
|
55
54
|
$cfg['user.name'] = nil
|
56
55
|
expect($terminal).to receive(:ask).once.and_return('bob')
|
57
56
|
expect(@acc).to receive(:error).once
|
58
57
|
expect($cfg).to receive(:set).with('user.name', 'bob', :user).once.and_call_original
|
59
|
-
expect(@pswd).to receive(:get).once.and_return(
|
58
|
+
expect(@pswd).to receive(:get).once.and_return('built')
|
60
59
|
|
61
60
|
ret = @acc.login_info
|
62
|
-
expect(ret).to eq(
|
63
|
-
:email => "bob", :password=>"built"
|
64
|
-
})
|
61
|
+
expect(ret).to eq(email: 'bob', password: 'built')
|
65
62
|
end
|
66
63
|
|
67
|
-
it
|
68
|
-
$cfg['user.name'] =
|
64
|
+
it 'Asks for password' do
|
65
|
+
$cfg['user.name'] = 'bob'
|
69
66
|
expect(@pswd).to receive(:get).with('bizapi.hosted.exosite.io', 'bob').once.and_return(nil)
|
70
67
|
expect(@acc).to receive(:error).once
|
71
68
|
expect($terminal).to receive(:ask).once.and_return('dog')
|
72
|
-
expect(@pswd).to receive(:set).once.with('bizapi.hosted.exosite.io','bob','dog')
|
69
|
+
expect(@pswd).to receive(:set).once.with('bizapi.hosted.exosite.io', 'bob', 'dog')
|
73
70
|
# 2017-07-31: login_info may exit unless the command okays prompting for the password.
|
74
71
|
# (If we don't set this, login_info exits, which we'd want to
|
75
72
|
# catch with
|
@@ -77,28 +74,28 @@ RSpec.describe MrMurano::Account, "token" do
|
|
77
74
|
expect($cfg).to receive(:prompt_if_logged_off).and_return(true)
|
78
75
|
|
79
76
|
ret = @acc.login_info
|
80
|
-
expect(ret).to eq(email:
|
77
|
+
expect(ret).to eq(email: 'bob', password: 'dog')
|
81
78
|
end
|
82
79
|
end
|
83
80
|
|
84
|
-
context
|
81
|
+
context 'token' do
|
85
82
|
before(:example) do
|
86
|
-
allow(@acc).to receive(:login_info).and_return(
|
83
|
+
allow(@acc).to receive(:login_info).and_return(email: 'bob', password: 'v')
|
87
84
|
end
|
88
85
|
|
89
|
-
it
|
90
|
-
stub_request(:post,
|
91
|
-
with(:
|
92
|
-
to_return(body: {:
|
86
|
+
it 'gets a token' do
|
87
|
+
stub_request(:post, 'https://bizapi.hosted.exosite.io/api:1/token/')
|
88
|
+
.with(body: { email: 'bob', password: 'v' }.to_json)
|
89
|
+
.to_return(body: { token: 'ABCDEFGHIJKLMNOP' }.to_json)
|
93
90
|
|
94
91
|
ret = @acc.token
|
95
|
-
expect(ret).to eq(
|
92
|
+
expect(ret).to eq('ABCDEFGHIJKLMNOP')
|
96
93
|
end
|
97
94
|
|
98
|
-
it
|
99
|
-
stub_request(:post,
|
100
|
-
with(:
|
101
|
-
to_return(status: 401, body: {}.to_json)
|
95
|
+
it 'gets an error' do
|
96
|
+
stub_request(:post, 'https://bizapi.hosted.exosite.io/api:1/token/')
|
97
|
+
.with(body: { email: 'bob', password: 'v' }.to_json)
|
98
|
+
.to_return(status: 401, body: {}.to_json)
|
102
99
|
|
103
100
|
expect(@acc).to receive(:error).twice.and_return(nil)
|
104
101
|
ret = @acc.token
|
@@ -111,23 +108,23 @@ RSpec.describe MrMurano::Account, "token" do
|
|
111
108
|
#}.to raise_error(SystemExit).and output("\e[31mNot logged in!\e[0m\n").to_stderr
|
112
109
|
end
|
113
110
|
|
114
|
-
it
|
115
|
-
@acc.token_reset(
|
111
|
+
it 'uses existing token' do
|
112
|
+
@acc.token_reset('quxx')
|
116
113
|
ret = @acc.token
|
117
|
-
expect(ret).to eq(
|
114
|
+
expect(ret).to eq('quxx')
|
118
115
|
end
|
119
116
|
|
120
|
-
it
|
121
|
-
@acc.token_reset(
|
117
|
+
it 'uses existing token, even with new instance' do
|
118
|
+
@acc.token_reset('quxx')
|
122
119
|
acc = MrMurano::Account.instance
|
123
120
|
ret = acc.token
|
124
|
-
expect(ret).to eq(
|
121
|
+
expect(ret).to eq('quxx')
|
125
122
|
end
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
129
126
|
RSpec.describe MrMurano::Account do
|
130
|
-
include_context
|
127
|
+
include_context 'WORKSPACE'
|
131
128
|
before(:example) do
|
132
129
|
@saved_cfg = ENV['MURANO_CONFIGFILE']
|
133
130
|
ENV['MURANO_CONFIGFILE'] = nil
|
@@ -138,32 +135,30 @@ RSpec.describe MrMurano::Account do
|
|
138
135
|
$cfg['product.id'] = 'XYZ'
|
139
136
|
|
140
137
|
@acc = MrMurano::Account.instance
|
141
|
-
allow(@acc).to receive(:token).and_return(
|
138
|
+
allow(@acc).to receive(:token).and_return('TTTTTTTTTT')
|
142
139
|
end
|
143
140
|
after(:example) do
|
144
141
|
ENV['MURANO_CONFIGFILE'] = @saved_cfg
|
145
142
|
end
|
146
143
|
|
147
|
-
it
|
144
|
+
it 'initializes' do
|
148
145
|
uri = @acc.endpoint('')
|
149
|
-
expect(uri.to_s).to eq(
|
146
|
+
expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/')
|
150
147
|
end
|
151
148
|
|
152
|
-
context
|
153
|
-
it
|
149
|
+
context 'lists business' do
|
150
|
+
it 'for user.name' do
|
154
151
|
# http.rb::json_opts() sets :symbolize_names=>true, so use symbols, not strings.
|
155
152
|
bizlist = [
|
156
|
-
{:
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
:name=>"MPS",
|
163
|
-
},
|
153
|
+
{ bizid: 'YYY',
|
154
|
+
role: 'admin',
|
155
|
+
name: 'MAE', },
|
156
|
+
{ bizid: 'XXX',
|
157
|
+
role: 'admin',
|
158
|
+
name: 'MPS', },
|
164
159
|
]
|
165
|
-
stub_request(:get,
|
166
|
-
to_return(body: bizlist)
|
160
|
+
stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/user/BoB@place.net/membership/')
|
161
|
+
.to_return(body: bizlist)
|
167
162
|
|
168
163
|
buslist = []
|
169
164
|
buslist << MrMurano::Business.new(bizlist[0])
|
@@ -174,24 +169,24 @@ RSpec.describe MrMurano::Account do
|
|
174
169
|
expect(ret).to eq(buslist)
|
175
170
|
end
|
176
171
|
|
177
|
-
it
|
172
|
+
it 'asks for account when missing' do
|
178
173
|
bizlist = [
|
179
|
-
{:
|
180
|
-
|
181
|
-
|
182
|
-
{:
|
183
|
-
|
184
|
-
|
174
|
+
{ bizid: 'YYY',
|
175
|
+
role: 'admin',
|
176
|
+
name: 'MAE', },
|
177
|
+
{ bizid: 'XXX',
|
178
|
+
role: 'admin',
|
179
|
+
name: 'MPS', },
|
185
180
|
]
|
186
|
-
stub_request(:get,
|
187
|
-
to_return(body: bizlist)
|
181
|
+
stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/user/BoB@place.net/membership/')
|
182
|
+
.to_return(body: bizlist)
|
188
183
|
|
189
184
|
buslist = []
|
190
185
|
buslist << MrMurano::Business.new(bizlist[0])
|
191
186
|
buslist << MrMurano::Business.new(bizlist[1])
|
192
187
|
|
193
188
|
$cfg['user.name'] = nil
|
194
|
-
expect(@acc).to receive(:login_info) do |
|
189
|
+
expect(@acc).to receive(:login_info) do |_arg|
|
195
190
|
$cfg['user.name'] = 'BoB@place.net'
|
196
191
|
end
|
197
192
|
|