MuranoCLI 3.0.2 → 3.0.4

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +30 -59
  3. data/Gemfile +9 -3
  4. data/MuranoCLI.gemspec +11 -4
  5. data/bin/murano +2 -90
  6. data/lib/MrMurano.rb +5 -1
  7. data/lib/MrMurano/{spec_commander.rb → Commander-Entry.rb} +1 -2
  8. data/lib/MrMurano/Solution.rb +12 -15
  9. data/lib/MrMurano/SolutionId.rb +1 -5
  10. data/lib/MrMurano/SyncAllowed.rb +2 -2
  11. data/lib/MrMurano/SyncUpDown.rb +6 -3
  12. data/lib/MrMurano/progress.rb +11 -2
  13. data/lib/MrMurano/verbosing.rb +3 -2
  14. data/lib/MrMurano/version.rb +2 -2
  15. data/spec/Account-Passwords_spec.rb +34 -48
  16. data/spec/Account_spec.rb +58 -63
  17. data/spec/Business_spec.rb +151 -139
  18. data/spec/ConfigFile_spec.rb +15 -11
  19. data/spec/ConfigMigrate_spec.rb +23 -12
  20. data/spec/Config_spec.rb +57 -54
  21. data/spec/Content_spec.rb +233 -201
  22. data/spec/GatewayBase_spec.rb +35 -27
  23. data/spec/GatewayDevice_spec.rb +149 -149
  24. data/spec/GatewayResource_spec.rb +115 -102
  25. data/spec/GatewaySettings_spec.rb +69 -62
  26. data/spec/Http_spec.rb +66 -56
  27. data/spec/MakePretties_spec.rb +82 -73
  28. data/spec/Mock_spec.rb +38 -29
  29. data/spec/ProjectFile_spec.rb +118 -106
  30. data/spec/Setting_spec.rb +24 -15
  31. data/spec/Solution-ServiceConfig_spec.rb +168 -140
  32. data/spec/Solution-ServiceEventHandler_spec.rb +186 -188
  33. data/spec/Solution-ServiceModules_spec.rb +314 -232
  34. data/spec/Solution-UsersRoles_spec.rb +136 -86
  35. data/spec/Solution_spec.rb +78 -50
  36. data/spec/SyncRoot_spec.rb +26 -24
  37. data/spec/SyncUpDown_spec.rb +268 -249
  38. data/spec/Verbosing_spec.rb +95 -93
  39. data/spec/Webservice-Cors_spec.rb +141 -95
  40. data/spec/Webservice-Endpoint_spec.rb +382 -346
  41. data/spec/Webservice-File_spec.rb +148 -109
  42. data/spec/Webservice-Setting_spec.rb +47 -41
  43. data/spec/cmd_business_spec.rb +17 -17
  44. data/spec/cmd_common.rb +27 -7
  45. data/spec/cmd_config_spec.rb +31 -20
  46. data/spec/cmd_content_spec.rb +80 -68
  47. data/spec/cmd_cors_spec.rb +11 -5
  48. data/spec/cmd_device_spec.rb +16 -14
  49. data/spec/cmd_domain_spec.rb +10 -8
  50. data/spec/cmd_exchange_spec.rb +3 -3
  51. data/spec/cmd_init_spec.rb +100 -101
  52. data/spec/cmd_keystore_spec.rb +17 -12
  53. data/spec/cmd_link_spec.rb +22 -37
  54. data/spec/cmd_password_spec.rb +11 -7
  55. data/spec/cmd_setting_application_spec.rb +47 -33
  56. data/spec/cmd_setting_product_spec.rb +32 -27
  57. data/spec/cmd_status_spec.rb +125 -114
  58. data/spec/cmd_syncdown_spec.rb +70 -65
  59. data/spec/cmd_syncup_spec.rb +19 -15
  60. data/spec/cmd_usage_spec.rb +14 -10
  61. metadata +29 -15
@@ -1,3 +1,10 @@
1
+ # Last Modified: 2017.09.12 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
1
8
  require 'fileutils'
2
9
  require 'MrMurano/version'
3
10
  require 'MrMurano/Gateway'
@@ -6,7 +13,7 @@ require 'MrMurano/SyncRoot'
6
13
  require '_workspace'
7
14
 
8
15
  RSpec.describe MrMurano::Gateway::Resources do
9
- include_context "WORKSPACE"
16
+ include_context 'WORKSPACE'
10
17
  before(:example) do
11
18
  MrMurano::SyncRoot.instance.reset
12
19
  $cfg = MrMurano::Config.new
@@ -17,87 +24,89 @@ RSpec.describe MrMurano::Gateway::Resources do
17
24
  $project.load
18
25
 
19
26
  @gw = MrMurano::Gateway::Resources.new
20
- allow(@gw).to receive(:token).and_return("TTTTTTTTTT")
27
+ allow(@gw).to receive(:token).and_return('TTTTTTTTTT')
21
28
  end
22
29
 
23
- it "initializes" do
30
+ it 'initializes' do
24
31
  uri = @gw.endpoint('/')
25
- expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/")
32
+ expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/')
26
33
  end
27
34
 
28
- it "lists" do
35
+ it 'lists' do
29
36
  resources = [
30
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"},
31
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"fuzz"},
32
- {:format=>"string", :unit=>"bits", :settable=>true, :alias=>"gruble"}
37
+ { format: 'string', unit: 'c', settable: true, alias: 'bob' },
38
+ { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
39
+ { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
33
40
  ]
34
- body = { :resources => {
35
- :bob=>{:format=>"string", :unit=>"c", :settable=>true},
36
- :fuzz=>{:format=>"string", :unit=>"c", :settable=>true},
37
- :gruble=>{:format=>"string", :unit=>"bits", :settable=>true}
38
- }}
39
- stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2').
40
- to_return(:body=>body.to_json)
41
+ body = { resources: {
42
+ bob: { format: 'string', unit: 'c', settable: true },
43
+ fuzz: { format: 'string', unit: 'c', settable: true },
44
+ gruble: { format: 'string', unit: 'bits', settable: true },
45
+ }, }
46
+ stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
47
+ .to_return(body: body.to_json)
41
48
 
42
49
  ret = @gw.list
43
50
  expect(ret).to eq(resources)
44
51
  end
45
52
 
46
- it "uploads all" do
53
+ it 'uploads all' do
47
54
  res_before = [
48
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"},
49
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"fuzz"},
50
- {:format=>"string", :unit=>"bits", :settable=>true, :alias=>"gruble"}
55
+ { format: 'string', unit: 'c', settable: true, alias: 'bob' },
56
+ { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
57
+ { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
51
58
  ]
52
59
  res_after = {
53
- :bob=>{:format=>"string", :unit=>"c", :settable=>true},
54
- :fuzz=>{:format=>"string", :unit=>"c", :settable=>true},
55
- :gruble=>{:format=>"string", :unit=>"bits", :settable=>true}
60
+ bob: { format: 'string', unit: 'c', settable: true },
61
+ fuzz: { format: 'string', unit: 'c', settable: true },
62
+ gruble: { format: 'string', unit: 'bits', settable: true },
56
63
  }
57
- stub_request(:patch, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2').
58
- with(:body=>{:resources=>res_after}.to_json)
64
+ stub_request(:patch, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
65
+ .with(body: { resources: res_after }.to_json)
59
66
 
60
67
  ret = @gw.upload_all(res_before)
61
68
  expect(ret).to eq({})
62
69
  end
63
70
 
64
- context "compares" do
71
+ context 'compares' do
65
72
  before(:example) do
66
- @iA = {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"}
67
- @iB = {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"}
73
+ @i_a = { format: 'string', unit: 'c', settable: true, alias: 'bob' }
74
+ @i_b = { format: 'string', unit: 'c', settable: true, alias: 'bob' }
68
75
  end
69
- it "Are equal" do
70
- ret = @gw.docmp(@iA, @iB)
76
+ it 'Are equal' do
77
+ ret = @gw.docmp(@i_a, @i_b)
71
78
  expect(ret).to eq(false)
72
79
  end
73
80
  end
74
81
 
75
- context "Lookup functions" do
76
- it "local path is into" do
82
+ context 'Lookup functions' do
83
+ it 'local path is into' do
77
84
  ret = @gw.tolocalpath('bob', 'rich')
78
85
  expect(ret).to eq('bob')
79
86
  end
80
87
 
81
- it "gets synckey" do
82
- ret = @gw.synckey({ :alias=>'bob' })
83
- expect(ret).to eq("bob")
88
+ it 'gets synckey' do
89
+ ret = @gw.synckey(alias: 'bob')
90
+ expect(ret).to eq('bob')
84
91
  end
85
92
  end
86
93
 
87
- context "local items" do
88
- it "succeeds" do
94
+ context 'local items' do
95
+ it 'succeeds' do
89
96
  resfile = Pathname.new('resources.yaml')
90
97
  src = File.join(@testdir, 'spec', 'fixtures', 'gateway_resource_files', 'resources.yaml')
91
98
  FileUtils.copy(src, resfile.to_path)
92
99
  ret = @gw.localitems(resfile)
93
- expect(ret).to eq([
94
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"},
95
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"fuzz"},
96
- {:format=>"string", :unit=>"bits", :settable=>true, :alias=>"gruble"}
97
- ])
100
+ expect(ret).to eq(
101
+ [
102
+ { format: 'string', unit: 'c', settable: true, alias: 'bob' },
103
+ { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
104
+ { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
105
+ ]
106
+ )
98
107
  end
99
108
 
100
- it "missing file" do
109
+ it 'missing file' do
101
110
  resfile = Pathname.new('resources.yaml')
102
111
  saved = $stderr
103
112
  $stderr = StringIO.new
@@ -123,9 +132,9 @@ RSpec.describe MrMurano::Gateway::Resources do
123
132
  src = File.join(@testdir, 'spec', 'fixtures', 'gateway_resource_files', 'resources.notyaml')
124
133
  FileUtils.copy(src, resfile.to_path)
125
134
  #expect{ @gw.localitems(resfile) }.to raise_error(JSON::Schema::ValidationError)
126
- expect {
135
+ expect do
127
136
  @gw.localitems(resfile)
128
- }.to raise_error(SystemExit).and output("\e[31mThere is an error in the config file, resources.yaml\e[0m\n\e[31m\"The property '#/' of type Array did not match the following type: object\"\e[0m\n").to_stderr
137
+ end.to raise_error(SystemExit).and output("\e[31mThere is an error in the config file, resources.yaml\e[0m\n\e[31m\"The property '#/' of type Array did not match the following type: object\"\e[0m\n").to_stderr
129
138
  end
130
139
 
131
140
  it "isn't valid" do
@@ -133,58 +142,63 @@ RSpec.describe MrMurano::Gateway::Resources do
133
142
  src = File.join(@testdir, 'spec', 'fixtures', 'gateway_resource_files', 'resources.notyaml')
134
143
  FileUtils.copy(src, resfile.to_path)
135
144
  #expect{ @gw.localitems(resfile) }.to raise_error(JSON::Schema::ValidationError)
136
- expect {
145
+ expect do
137
146
  @gw.localitems(resfile)
138
- }.to raise_error(SystemExit).and output("\e[31mThere is an error in the config file, resources.yaml\e[0m\n\e[31m\"The property '#/' of type Array did not match the following type: object\"\e[0m\n").to_stderr
147
+ end.to raise_error(SystemExit).and output("\e[31mThere is an error in the config file, resources.yaml\e[0m\n\e[31m\"The property '#/' of type Array did not match the following type: object\"\e[0m\n").to_stderr
139
148
  end
140
149
  end
141
150
 
142
- context "syncup" do
151
+ context 'syncup' do
143
152
  before(:example) do
144
- expect(@gw).to receive(:list).once.and_return([
145
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"},
146
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"fuzz"},
147
- {:format=>"string", :unit=>"bits", :settable=>true, :alias=>"gruble"}
148
- ])
153
+ expect(@gw).to receive(:list).once.and_return(
154
+ [
155
+ { format: 'string', unit: 'c', settable: true, alias: 'bob' },
156
+ { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
157
+ { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
158
+ ]
159
+ )
149
160
  end
150
- it "removes keys" do
151
- expect(@gw).to receive(:upload_all).with([
152
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"},
153
- {:format=>"string", :unit=>"bits", :settable=>true, :alias=>"gruble"}
154
- ])
155
-
161
+ it 'removes keys' do
162
+ expect(@gw).to receive(:upload_all).with(
163
+ [
164
+ { format: 'string', unit: 'c', settable: true, alias: 'bob' },
165
+ { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
166
+ ]
167
+ )
156
168
  @gw.syncup_before
157
169
  @gw.remove('fuzz')
158
170
  @gw.syncup_after
159
171
  end
160
172
 
161
- it "adds keys" do
162
- expect(@gw).to receive(:upload_all).with([
163
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"},
164
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"fuzz"},
165
- {:format=>"string", :unit=>"bits", :settable=>true, :alias=>"gruble"},
166
- {:format=>"number", :unit=>"bibs", :settable=>false, :alias=>"greeble"},
167
- ])
168
-
173
+ it 'adds keys' do
174
+ expect(@gw).to receive(:upload_all).with(
175
+ [
176
+ { format: 'string', unit: 'c', settable: true, alias: 'bob' },
177
+ { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
178
+ { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
179
+ { format: 'number', unit: 'bibs', settable: false, alias: 'greeble' },
180
+ ]
181
+ )
169
182
  @gw.syncup_before
170
- @gw.upload(nil, {:format=>"number", :unit=>"bibs", :settable=>false, :alias=>"greeble"}, nil)
183
+ @gw.upload(nil, { format: 'number', unit: 'bibs', settable: false, alias: 'greeble' }, nil)
171
184
  @gw.syncup_after
172
185
  end
173
186
 
174
- it "replaces keys" do
175
- expect(@gw).to receive(:upload_all).with([
176
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"},
177
- {:format=>"string", :unit=>"bits", :settable=>true, :alias=>"gruble"},
178
- {:format=>"number", :unit=>"bibs", :settable=>false, :alias=>"fuzz"},
179
- ])
180
-
187
+ it 'replaces keys' do
188
+ expect(@gw).to receive(:upload_all).with(
189
+ [
190
+ { format: 'string', unit: 'c', settable: true, alias: 'bob' },
191
+ { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
192
+ { format: 'number', unit: 'bibs', settable: false, alias: 'fuzz' },
193
+ ]
194
+ )
181
195
  @gw.syncup_before
182
- @gw.upload(nil, {:format=>"number", :unit=>"bibs", :settable=>false, :alias=>"fuzz"}, nil)
196
+ @gw.upload(nil, { format: 'number', unit: 'bibs', settable: false, alias: 'fuzz' }, nil)
183
197
  @gw.syncup_after
184
198
  end
185
199
  end
186
200
 
187
- context "syncdown" do
201
+ context 'syncdown' do
188
202
  before(:example) do
189
203
  # 2017-07-05: [lb] not sure what I had to add this just now;
190
204
  # this test had been working fine... I added a check for
@@ -201,66 +215,65 @@ RSpec.describe MrMurano::Gateway::Resources do
201
215
 
202
216
  expect(@gw).to receive(:locallist).once.and_return(
203
217
  [
204
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"bob"},
205
- {:format=>"string", :unit=>"c", :settable=>true, :alias=>"fuzz"},
206
- {:format=>"string", :unit=>"bits", :settable=>true, :alias=>"gruble"}
218
+ { format: 'string', unit: 'c', settable: true, alias: 'bob' },
219
+ { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
220
+ { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
207
221
  ],
208
222
  # 2017-07-05: [lb] also had to remove this check.
209
223
  # locallist returns a single array, not two of them!
210
224
  #[],
211
225
  )
212
226
 
213
- @io = instance_double("IO")
227
+ @io = instance_double('IO')
214
228
  @p = instance_double('Pathname')
215
229
  expect(@p).to receive(:dirname).and_return(resfile.dirname)
216
230
  expect(@p).to receive(:extname).and_return(resfile.extname)
217
231
  expect(@p).to receive(:open).and_yield(@io)
218
232
  end
219
- it "removes keys" do
233
+ it 'removes keys' do
220
234
  expect(@io).to receive(:write) do |args|
221
235
  fy = YAML.load(args)
222
- expect(fy).to eq({
223
- 'bob'=>{'format'=>"string", 'unit'=>"c", 'settable'=>true},
224
- 'gruble'=>{'format'=>"string", 'unit'=>"bits", 'settable'=>true}
225
- })
236
+ expect(fy).to eq(
237
+ 'bob' => { 'format' => 'string', 'unit' => 'c', 'settable' => true },
238
+ 'gruble' => { 'format' => 'string', 'unit' => 'bits', 'settable' => true }
239
+ )
226
240
  end
227
241
 
228
242
  @gw.syncdown_before
229
- @gw.removelocal(@p, {:alias=>'fuzz'})
243
+ @gw.removelocal(@p, alias: 'fuzz')
230
244
  @gw.syncdown_after(@p)
231
245
  end
232
246
 
233
- it "adds keys" do
247
+ it 'adds keys' do
234
248
  expect(@io).to receive(:write) do |args|
235
249
  fy = YAML.load(args)
236
- expect(fy).to eq({
237
- 'bob'=>{'format'=>"string", 'unit'=>"c", 'settable'=>true},
238
- 'gruble'=>{'format'=>"string", 'unit'=>"bits", 'settable'=>true},
239
- 'fuzz'=>{'format'=>"string", 'unit'=>"c", 'settable'=>true},
240
- 'greeble'=>{'format'=>"number", 'unit'=>"bibs", 'settable'=>false},
241
- })
250
+ expect(fy).to eq(
251
+ 'bob' => { 'format' => 'string', 'unit' => 'c', 'settable' => true },
252
+ 'gruble' => { 'format' => 'string', 'unit' => 'bits', 'settable' => true },
253
+ 'fuzz' => { 'format' => 'string', 'unit' => 'c', 'settable' => true },
254
+ 'greeble' => { 'format' => 'number', 'unit' => 'bibs', 'settable' => false }
255
+ )
242
256
  end
243
257
 
244
258
  @gw.syncdown_before
245
- @gw.download(@p, {:format=>"number", :unit=>"bibs", :settable=>false, :alias=>"greeble"})
259
+ @gw.download(@p, format: 'number', unit: 'bibs', settable: false, alias: 'greeble')
246
260
  @gw.syncdown_after(@p)
247
261
  end
248
262
 
249
- it "replaces keys" do
263
+ it 'replaces keys' do
250
264
  expect(@io).to receive(:write) do |args|
251
265
  fy = YAML.load(args)
252
- expect(fy).to eq({
253
- 'bob'=>{'format'=>"string", 'unit'=>"c", 'settable'=>true},
254
- 'gruble'=>{'format'=>"string", 'unit'=>"bits", 'settable'=>true},
255
- 'fuzz'=>{'format'=>"number", 'unit'=>"bibs", 'settable'=>false},
256
- })
266
+ expect(fy).to eq(
267
+ 'bob' => { 'format' => 'string', 'unit' => 'c', 'settable' => true },
268
+ 'gruble' => { 'format' => 'string', 'unit' => 'bits', 'settable' => true },
269
+ 'fuzz' => { 'format' => 'number', 'unit' => 'bibs', 'settable' => false }
270
+ )
257
271
  end
258
272
 
259
273
  @gw.syncdown_before
260
- @gw.download(@p, {:format=>"number", :unit=>"bibs", :settable=>false, :alias=>"fuzz"})
274
+ @gw.download(@p, format: 'number', unit: 'bibs', settable: false, alias: 'fuzz')
261
275
  @gw.syncdown_after(@p)
262
276
  end
263
277
  end
264
278
  end
265
279
 
266
- # vim: set ai et sw=2 ts=2 :
@@ -1,3 +1,10 @@
1
+ # Last Modified: 2017.09.12 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
1
8
  require 'fileutils'
2
9
  require 'MrMurano/version'
3
10
  require 'MrMurano/Gateway'
@@ -5,7 +12,7 @@ require 'MrMurano/SyncRoot'
5
12
  require '_workspace'
6
13
 
7
14
  RSpec.describe MrMurano::Gateway::Settings do
8
- include_context "WORKSPACE"
15
+ include_context 'WORKSPACE'
9
16
  before(:example) do
10
17
  MrMurano::SyncRoot.instance.reset
11
18
  $cfg = MrMurano::Config.new
@@ -14,107 +21,107 @@ RSpec.describe MrMurano::Gateway::Settings do
14
21
  $cfg['product.id'] = 'XYZ'
15
22
 
16
23
  @gw = MrMurano::Gateway::Settings.new
17
- allow(@gw).to receive(:token).and_return("TTTTTTTTTT")
24
+ allow(@gw).to receive(:token).and_return('TTTTTTTTTT')
18
25
 
19
26
  @infoblob = {
20
- :name=>"XXXXXXXX",
21
- :protocol=>{:name=>"onep", :devmode=>false},
22
- :description=>"XXXXXXXX",
23
- :identity_format=> {
24
- :prefix=>"", :type=>"opaque", :options=>{:casing=>"mixed", :length=>0}},
25
- :fqdn=>"XXXXXXXX.m2.exosite-staging.io",
26
- :provisioning=> {
27
- :auth_type => 'token',
28
- :enabled=>true,
29
- :generate_identity=>true,
30
- :presenter_identity=>true,
31
- :ip_whitelisting=>{:enabled=>false, :allowed=>[]}},
32
- :resources=> {
33
- :bob=>{:format=>"string", :unit=>"c", :settable=>true},
34
- :fuzz=>{:format=>"string", :unit=>"c", :settable=>true},
35
- :gruble=>{:format=>"string", :unit=>"bits", :settable=>true}
36
- }
27
+ name: 'XXXXXXXX',
28
+ protocol: { name: 'onep', devmode: false },
29
+ description: 'XXXXXXXX',
30
+ identity_format: {
31
+ prefix: '', type: 'opaque', options: { casing: 'mixed', length: 0 },
32
+ },
33
+ fqdn: 'XXXXXXXX.m2.exosite-staging.io',
34
+ provisioning: {
35
+ auth_type: 'token',
36
+ enabled: true,
37
+ generate_identity: true,
38
+ presenter_identity: true,
39
+ ip_whitelisting: { enabled: false, allowed: [] },
40
+ },
41
+ resources: {
42
+ bob: { format: 'string', unit: 'c', settable: true },
43
+ fuzz: { format: 'string', unit: 'c', settable: true },
44
+ gruble: { format: 'string', unit: 'bits', settable: true },
45
+ },
37
46
  }
38
47
  end
39
48
 
40
- it "initializes" do
49
+ it 'initializes' do
41
50
  uri = @gw.endpoint('/')
42
- expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/")
51
+ expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/')
43
52
  end
44
53
 
45
- context "protocol" do
46
- context "reads" do
47
- it "data" do
48
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
49
- with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
50
- to_return(:status => 200, :body => @infoblob.to_json, :headers => {})
54
+ context 'protocol' do
55
+ context 'reads' do
56
+ it 'data' do
57
+ stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
58
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' })
59
+ .to_return(status: 200, body: @infoblob.to_json, headers: {})
51
60
 
52
61
  ret = @gw.protocol
53
62
  expect(ret).to eq(@infoblob[:protocol])
54
63
  end
55
64
 
56
- it "returns empty if not Hash" do
57
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
58
- with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
59
- to_return(:status => 200, :body => ['bob'].to_json, :headers => {})
65
+ it 'returns empty if not Hash' do
66
+ stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
67
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' })
68
+ .to_return(status: 200, body: ['bob'].to_json, headers: {})
60
69
 
61
70
  ret = @gw.protocol
62
71
  expect(ret).to eq({})
63
72
  end
64
73
 
65
- it "returns empty if missing protocol" do
74
+ it 'returns empty if missing protocol' do
66
75
  foo = @infoblob.dup
67
76
  foo.delete :protocol
68
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
69
- with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
70
- to_return(:status => 200, :body => foo.to_json, :headers => {})
77
+ stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
78
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' })
79
+ .to_return(status: 200, body: foo.to_json, headers: {})
71
80
 
72
81
  ret = @gw.protocol
73
82
  expect(ret).to eq({})
74
83
  end
75
84
 
76
- it "returns empty if protocol not Hash" do
85
+ it 'returns empty if protocol not Hash' do
77
86
  foo = @infoblob.dup
78
- foo[:protocol] = "bob"
79
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
80
- with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
81
- to_return(:status => 200, :body => foo.to_json, :headers => {})
87
+ foo[:protocol] = 'bob'
88
+ stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
89
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' })
90
+ .to_return(status: 200, body: foo.to_json, headers: {})
82
91
 
83
92
  ret = @gw.protocol
84
93
  expect(ret).to eq({})
85
94
  end
86
95
  end
87
- context "writes" do
88
- it "data" do
89
- newvalues = {:name=>'twelve', :devmode=>true}
90
- stub_request(:patch, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
91
- with(:headers => {'Authorization'=>'token TTTTTTTTTT',
92
- 'Content-Type'=>'application/json'},
93
- :body => {:protocol=>newvalues}.to_json).
94
- to_return(:status => 200, :headers => {})
95
-
96
- ret = @gw.protocol=(newvalues)
96
+ context 'writes' do
97
+ it 'data' do
98
+ newvalues = { name: 'twelve', devmode: true }
99
+ stub_request(:patch, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
100
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
101
+ 'Content-Type' => 'application/json', },
102
+ body: { protocol: newvalues }.to_json)
103
+ .to_return(status: 200, headers: {})
104
+
105
+ ret = @gw.protocol = (newvalues)
97
106
  expect(ret).to eq(newvalues)
98
107
  end
99
108
 
100
- it "raises when not Hash" do
101
- expect{ @gw.protocol=('foo') }.to raise_error "Not Hash"
109
+ it 'raises when not Hash' do
110
+ expect { @gw.protocol = ('foo') }.to raise_error 'Not Hash'
102
111
  end
103
112
 
104
- it "strips extra keys" do
105
- newvalues = {:name=>'twelve', :devmode=>true, :auth=>"yes", :bob=>:built}
106
- stub_request(:patch, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
107
- with(:headers => {'Authorization'=>'token TTTTTTTTTT',
108
- 'Content-Type'=>'application/json'},
109
- :body => {:protocol=>{:name=>'twelve', :devmode=>true}}.to_json).
110
- to_return(:status => 200, :headers => {})
113
+ it 'strips extra keys' do
114
+ newvalues = { name: 'twelve', devmode: true, auth: 'yes', bob: :built }
115
+ stub_request(:patch, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
116
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
117
+ 'Content-Type' => 'application/json', },
118
+ body: { protocol: { name: 'twelve', devmode: true } }.to_json)
119
+ .to_return(status: 200, headers: {})
111
120
 
112
- ret = @gw.protocol=(newvalues)
121
+ ret = @gw.protocol = (newvalues)
113
122
  expect(ret).to eq(newvalues)
114
123
  end
115
124
  end
116
125
  end
117
-
118
126
  end
119
127
 
120
- # vim: set ai et sw=2 ts=2 :