MuranoCLI 3.2.0.beta.1 → 3.2.0.beta.5

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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/.trustme.plugin +137 -0
  4. data/.trustme.sh +217 -117
  5. data/.trustme.vim +9 -3
  6. data/Gemfile +9 -3
  7. data/MuranoCLI.gemspec +8 -5
  8. data/Rakefile +1 -0
  9. data/dockers/Dockerfile.2.2.9 +6 -3
  10. data/dockers/Dockerfile.2.3.6 +6 -3
  11. data/dockers/Dockerfile.2.4.3 +6 -3
  12. data/dockers/Dockerfile.2.5.0 +6 -3
  13. data/dockers/Dockerfile.GemRelease +10 -8
  14. data/dockers/Dockerfile.m4 +23 -5
  15. data/dockers/docker-test.sh +65 -28
  16. data/docs/completions/murano_completion-bash +751 -57
  17. data/docs/develop.rst +10 -9
  18. data/lib/MrMurano/AccountBase.rb +95 -6
  19. data/lib/MrMurano/Commander-Entry.rb +9 -4
  20. data/lib/MrMurano/Config-Migrate.rb +2 -0
  21. data/lib/MrMurano/Config.rb +94 -26
  22. data/lib/MrMurano/Content.rb +1 -1
  23. data/lib/MrMurano/Exchange.rb +77 -42
  24. data/lib/MrMurano/Gateway.rb +1 -1
  25. data/lib/MrMurano/HttpAuthed.rb +20 -7
  26. data/lib/MrMurano/Logs.rb +10 -1
  27. data/lib/MrMurano/ProjectFile.rb +1 -1
  28. data/lib/MrMurano/ReCommander.rb +129 -73
  29. data/lib/MrMurano/Solution-ServiceConfig.rb +18 -11
  30. data/lib/MrMurano/Solution-Services.rb +78 -50
  31. data/lib/MrMurano/Solution-Users.rb +1 -1
  32. data/lib/MrMurano/Solution.rb +13 -63
  33. data/lib/MrMurano/SyncUpDown-Core.rb +185 -77
  34. data/lib/MrMurano/SyncUpDown-Item.rb +29 -4
  35. data/lib/MrMurano/SyncUpDown.rb +11 -11
  36. data/lib/MrMurano/Webservice-Cors.rb +1 -1
  37. data/lib/MrMurano/Webservice-Endpoint.rb +28 -17
  38. data/lib/MrMurano/Webservice-File.rb +103 -43
  39. data/lib/MrMurano/commands/domain.rb +1 -0
  40. data/lib/MrMurano/commands/element.rb +585 -0
  41. data/lib/MrMurano/commands/exchange.rb +211 -204
  42. data/lib/MrMurano/commands/gb.rb +1 -0
  43. data/lib/MrMurano/commands/globals.rb +17 -7
  44. data/lib/MrMurano/commands/init.rb +115 -101
  45. data/lib/MrMurano/commands/keystore.rb +1 -1
  46. data/lib/MrMurano/commands/logs.rb +2 -1
  47. data/lib/MrMurano/commands/postgresql.rb +17 -7
  48. data/lib/MrMurano/commands/service.rb +572 -0
  49. data/lib/MrMurano/commands/show.rb +7 -3
  50. data/lib/MrMurano/commands/solution.rb +2 -1
  51. data/lib/MrMurano/commands/solution_picker.rb +31 -15
  52. data/lib/MrMurano/commands/status.rb +205 -169
  53. data/lib/MrMurano/commands/sync.rb +70 -38
  54. data/lib/MrMurano/commands/token.rb +59 -14
  55. data/lib/MrMurano/commands/usage.rb +1 -0
  56. data/lib/MrMurano/commands.rb +2 -0
  57. data/lib/MrMurano/hash.rb +91 -0
  58. data/lib/MrMurano/http.rb +55 -6
  59. data/lib/MrMurano/makePretty.rb +47 -0
  60. data/lib/MrMurano/optparse.rb +60 -45
  61. data/lib/MrMurano/variegated/TruthyFalsey.rb +48 -0
  62. data/lib/MrMurano/variegated/ruby_dig.rb +64 -0
  63. data/lib/MrMurano/verbosing.rb +113 -3
  64. data/lib/MrMurano/version.rb +1 -1
  65. data/spec/Account_spec.rb +34 -20
  66. data/spec/Business_spec.rb +12 -9
  67. data/spec/Config_spec.rb +7 -1
  68. data/spec/Content_spec.rb +17 -1
  69. data/spec/GatewayBase_spec.rb +5 -2
  70. data/spec/GatewayDevice_spec.rb +4 -2
  71. data/spec/GatewayResource_spec.rb +4 -1
  72. data/spec/GatewaySettings_spec.rb +4 -1
  73. data/spec/HttpAuthed_spec.rb +73 -0
  74. data/spec/Http_spec.rb +32 -35
  75. data/spec/ProjectFile_spec.rb +1 -1
  76. data/spec/Solution-ServiceConfig_spec.rb +4 -1
  77. data/spec/Solution-ServiceEventHandler_spec.rb +6 -3
  78. data/spec/Solution-ServiceModules_spec.rb +4 -1
  79. data/spec/Solution-UsersRoles_spec.rb +4 -1
  80. data/spec/Solution_spec.rb +4 -1
  81. data/spec/SyncUpDown_spec.rb +1 -1
  82. data/spec/Webservice-Cors_spec.rb +4 -1
  83. data/spec/Webservice-Endpoint_spec.rb +9 -6
  84. data/spec/Webservice-File_spec.rb +17 -4
  85. data/spec/Webservice-Setting_spec.rb +6 -2
  86. data/spec/_workspace.rb +2 -0
  87. data/spec/cmd_common.rb +42 -13
  88. data/spec/cmd_content_spec.rb +17 -7
  89. data/spec/cmd_device_spec.rb +1 -1
  90. data/spec/cmd_domain_spec.rb +2 -2
  91. data/spec/cmd_element_spec.rb +400 -0
  92. data/spec/cmd_exchange_spec.rb +2 -2
  93. data/spec/cmd_init_spec.rb +59 -25
  94. data/spec/cmd_keystore_spec.rb +6 -3
  95. data/spec/cmd_link_spec.rb +10 -5
  96. data/spec/cmd_logs_spec.rb +1 -1
  97. data/spec/cmd_setting_application_spec.rb +18 -15
  98. data/spec/cmd_setting_product_spec.rb +7 -7
  99. data/spec/cmd_status_spec.rb +27 -17
  100. data/spec/cmd_syncdown_application_spec.rb +30 -3
  101. data/spec/cmd_syncdown_both_spec.rb +72 -18
  102. data/spec/cmd_syncup_spec.rb +71 -5
  103. data/spec/cmd_token_spec.rb +2 -2
  104. data/spec/cmd_usage_spec.rb +2 -2
  105. data/spec/dry_run_formatter.rb +27 -0
  106. data/spec/fixtures/dumped_config +8 -0
  107. data/spec/fixtures/exchange_element/element-show.json +1 -0
  108. data/spec/fixtures/exchange_element/swagger-mur-6407__10k.yaml +282 -0
  109. data/spec/fixtures/exchange_element/swagger-mur-6407__20k.yaml +588 -0
  110. data/spec/variegated_TruthyFalsey_spec.rb +29 -0
  111. metadata +51 -25
data/spec/Http_spec.rb CHANGED
@@ -9,53 +9,44 @@ require 'MrMurano/version'
9
9
  require 'MrMurano/http'
10
10
  require 'MrMurano/verbosing'
11
11
  require 'MrMurano/Account'
12
+ require 'MrMurano/HttpAuthed'
12
13
  require '_workspace'
13
14
 
14
- class Tst
15
- include MrMurano::Verbose
16
- include MrMurano::Http
17
-
18
- def initialize
19
- @token = nil
20
- end
21
- end
22
-
23
15
  RSpec.describe MrMurano::Http do
24
16
  include_context 'WORKSPACE'
25
17
 
26
18
  before(:example) do
27
19
  $cfg = MrMurano::Config.new
28
20
  $cfg.load
29
- @tst = Tst.new
21
+ @hauth = MrMurano::HttpAuthed.instance
30
22
  end
31
23
 
32
24
  context 'gets a token' do
33
25
  before(:example) do
34
26
  @acc = instance_double('MrMurano::Account')
35
- #allow(MrMurano::Account).to receive(:new).and_return(@acc)
36
- allow(MrMurano::Account).to receive(:instance).and_return(@acc)
27
+ allow(MrMurano::Account).to receive(:new).and_return(@acc)
37
28
  end
38
29
 
39
30
  it 'already has one' do
40
- @tst.instance_variable_set(:@token, 'ABCDEFG')
41
- ret = @tst.token
31
+ @hauth.instance_variable_set(:@token_biz, 'ABCDEFG')
32
+ ret = @hauth.token
42
33
  expect(ret).to eq('ABCDEFG')
43
34
  end
44
35
 
45
36
  it 'gets one' do
46
- expect(@acc).to receive(:token).and_return('ABCDEFG')
47
- ret = @tst.token
37
+ expect(@hauth).to receive(:token).and_return('ABCDEFG')
38
+ ret = @hauth.token
48
39
  expect(ret).to eq('ABCDEFG')
49
40
  end
50
41
 
51
42
  it 'raises when not logged in' do
52
- expect(@acc).to receive(:token).and_return(nil)
43
+ expect(@hauth).to receive(:token).and_return(nil)
53
44
  # 2017-07-13: The token command used to raise an error, but [lb]
54
45
  # doesn't like seeing the "use --trace" message that Ruby spits
55
46
  # out. So write to stderr and exit instead. Here, use check that
56
47
  # the function exits by expecting it to raise SystemExit.
57
48
  expect do
58
- @tst.token
49
+ @hauth.ensure_token!
59
50
  end.to raise_error(SystemExit).and output("\e[31mNot logged in!\e[0m\n").to_stderr
60
51
  end
61
52
  end
@@ -69,7 +60,7 @@ RSpec.describe MrMurano::Http do
69
60
  it 'puts nothing' do
70
61
  $cfg['tool.curldebug'] = false
71
62
  $stdout = StringIO.new
72
- @tst.curldebug(@req)
63
+ @hauth.curldebug(@req)
73
64
  expect($stdout.string).to eq('')
74
65
  end
75
66
 
@@ -77,7 +68,7 @@ RSpec.describe MrMurano::Http do
77
68
  $cfg['tool.curldebug'] = true
78
69
  $cfg.curlfile_f = nil
79
70
  $stdout = StringIO.new
80
- @tst.curldebug(@req)
71
+ @hauth.curldebug(@req)
81
72
  expect($stdout.string).to eq(
82
73
  %(curl -s -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test'\n)
83
74
  )
@@ -88,7 +79,7 @@ RSpec.describe MrMurano::Http do
88
79
  $cfg.curlfile_f = nil
89
80
  $stdout = StringIO.new
90
81
  @req['Authorization'] = 'LetMeIn'
91
- @tst.curldebug(@req)
82
+ @hauth.curldebug(@req)
92
83
  expect($stdout.string).to eq(
93
84
  %(curl -s -H 'Authorization: LetMeIn' -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test'\n)
94
85
  )
@@ -99,7 +90,7 @@ RSpec.describe MrMurano::Http do
99
90
  $cfg.curlfile_f = nil
100
91
  $stdout = StringIO.new
101
92
  @req.body = 'builder'
102
- @tst.curldebug(@req)
93
+ @hauth.curldebug(@req)
103
94
  expect($stdout.string).to eq(
104
95
  %(curl -s -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test' -d 'builder'\n)
105
96
  )
@@ -108,13 +99,13 @@ RSpec.describe MrMurano::Http do
108
99
 
109
100
  context 'checks if JSON' do
110
101
  it 'is JSON' do
111
- ok, data = @tst.isJSON(%({"one": "two", "three":[1,2,3,4,5,6]}))
102
+ ok, data = @hauth.isJSON(%({"one": "two", "three":[1,2,3,4,5,6]}))
112
103
  expect(ok).to be true
113
104
  expect(data).to eq(one: 'two',
114
105
  three: [1, 2, 3, 4, 5, 6])
115
106
  end
116
107
  it 'is not JSON' do
117
- ok, data = @tst.isJSON(%(woeiutepoxam))
108
+ ok, data = @hauth.isJSON(%(woeiutepoxam))
118
109
  expect(ok).to be false
119
110
  expect(data).to eq('woeiutepoxam')
120
111
  end
@@ -134,9 +125,9 @@ RSpec.describe MrMurano::Http do
134
125
  $stderr = StringIO.new
135
126
 
136
127
  allow(@rsp).to receive(:body).and_return('ok')
137
- expect(@tst).to receive(:error).once.with('Request Failed: 410: ok')
128
+ expect(@hauth).to receive(:error).once.with('Request Failed: 410: ok')
138
129
 
139
- @tst.showHttpError(@req, @rsp)
130
+ @hauth.showHttpError(@req, @rsp)
140
131
  expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
141
132
  > Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
142
133
  > Accept: */*
@@ -155,9 +146,9 @@ RSpec.describe MrMurano::Http do
155
146
 
156
147
  allow(@req).to receive(:body).and_return('this is my body')
157
148
  allow(@rsp).to receive(:body).and_return('ok')
158
- expect(@tst).to receive(:error).once.with('Request Failed: 410: ok')
149
+ expect(@hauth).to receive(:error).once.with('Request Failed: 410: ok')
159
150
 
160
- @tst.showHttpError(@req, @rsp)
151
+ @hauth.showHttpError(@req, @rsp)
161
152
  expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
162
153
  > Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
163
154
  > Accept: */*
@@ -176,9 +167,9 @@ RSpec.describe MrMurano::Http do
176
167
  $stderr = StringIO.new
177
168
 
178
169
  allow(@rsp).to receive(:body).and_return(%({"statusCode": 123, "message": "ok"}))
179
- expect(@tst).to receive(:error).once.with('Request Failed: 410: [123] ok')
170
+ expect(@hauth).to receive(:error).once.with('Request Failed: 410: [123] ok')
180
171
 
181
- @tst.showHttpError(@req, @rsp)
172
+ @hauth.showHttpError(@req, @rsp)
182
173
  expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
183
174
  > Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
184
175
  > Accept: */*
@@ -196,11 +187,11 @@ RSpec.describe MrMurano::Http do
196
187
  $stderr = StringIO.new
197
188
 
198
189
  allow(@rsp).to receive(:body).and_return(%({"statusCode": 123, "message": "ok"}))
199
- expect(@tst).to receive(:error).once.with(
190
+ expect(@hauth).to receive(:error).once.with(
200
191
  "Request Failed: 410: {\n \"statusCode\": 123,\n \"message\": \"ok\"\n}"
201
192
  )
202
193
 
203
- @tst.showHttpError(@req, @rsp)
194
+ @hauth.showHttpError(@req, @rsp)
204
195
  expect($stdout.string).to eq('')
205
196
  expect($stderr.string).to eq('')
206
197
  end
@@ -211,10 +202,16 @@ RSpec.describe MrMurano::Http do
211
202
 
212
203
  idhttp = instance_double('Net::HTTP')
213
204
  expect(idhttp).to receive(:request).once.and_return(@rsp)
214
- expect(@tst).to receive(:http).once.and_return(idhttp)
215
- expect(@rsp).to receive(:body).and_return(%({"statusCode": 123, "message": "gone"}))
205
+ expect(@hauth).to receive(:http).once.and_return(idhttp)
206
+
207
+ # To test this:
208
+ # $cfg['tool.curldebug'] = false
209
+ times = $cfg['tool.curldebug'] && 2 || 1
210
+ expect(@rsp).to receive(:body).exactly(times).times.and_return(
211
+ (%({"statusCode": 123, "message": "gone"}))
212
+ )
216
213
 
217
- @tst.workit(@req)
214
+ @hauth.workit(@req)
218
215
  expect($stdout.string).to eq('')
219
216
  expect($stderr.string).to eq("\e[31mRequest Failed: 410: [123] gone\e[0m\n")
220
217
  end
@@ -14,7 +14,7 @@ require 'MrMurano/ProjectFile'
14
14
  require '_workspace'
15
15
 
16
16
  RSpec.describe MrMurano::ProjectFile do
17
- context 'Basics ' do
17
+ context 'Basics' do
18
18
  include_context 'WORKSPACE'
19
19
  before(:example) do
20
20
  $cfg = MrMurano::Config.new
@@ -7,10 +7,12 @@
7
7
 
8
8
  require 'tempfile'
9
9
  require 'MrMurano/version'
10
+ require 'MrMurano/HttpAuthed'
10
11
  require 'MrMurano/ProjectFile'
11
12
  require 'MrMurano/Solution-ServiceConfig'
12
13
  require 'MrMurano/SyncRoot'
13
14
  require '_workspace'
15
+ require 'HttpAuthed_spec'
14
16
 
15
17
  RSpec.describe MrMurano::ServiceConfig do
16
18
  include_context 'WORKSPACE'
@@ -24,11 +26,12 @@ RSpec.describe MrMurano::ServiceConfig do
24
26
  # serviceconfig works on all solution types.
25
27
  $cfg['product.id'] = 'XYZ'
26
28
  $cfg['application.id'] = 'XYZ'
29
+ stub_request_email_password
27
30
 
28
31
  # ServiceConfig needs an api_id, else one could instantiate
29
32
  # ServiceConfigApplication or ServiceConfigProduct.
30
33
  @srv = MrMurano::ServiceConfig.new('XYZ')
31
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
34
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
32
35
  end
33
36
 
34
37
  it 'initializes' do
@@ -8,9 +8,11 @@
8
8
  require 'pathname'
9
9
  require 'tempfile'
10
10
  require 'MrMurano/version'
11
+ require 'MrMurano/HttpAuthed'
11
12
  require 'MrMurano/ProjectFile'
12
13
  require 'MrMurano/Solution-Services'
13
14
  require '_workspace'
15
+ require 'HttpAuthed_spec'
14
16
 
15
17
  RSpec.describe MrMurano::EventHandler do
16
18
  include_context 'WORKSPACE'
@@ -21,6 +23,7 @@ RSpec.describe MrMurano::EventHandler do
21
23
  $project.load
22
24
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
23
25
  $cfg['application.id'] = 'XYZ'
26
+ stub_request_email_password
24
27
 
25
28
  # 2017-06-23: EventHandler is an intermediate class now, and we
26
29
  # cannot use it because its @project_section is not defined.
@@ -29,7 +32,7 @@ RSpec.describe MrMurano::EventHandler do
29
32
  # the only different is if it uses application.id or product.id.
30
33
  @srv = MrMurano::EventHandlerSolnApp.new
31
34
  #@srv = MrMurano::EventHandlerSolnPrd.new
32
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
35
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
33
36
  end
34
37
 
35
38
  it 'initializes' do
@@ -346,7 +349,7 @@ end
346
349
  event: 'datapoint',
347
350
  svc_alias: nil,
348
351
  type: nil,
349
- line: 0,
352
+ line_beg: 0,
350
353
  line_end: 3,
351
354
  local_path: Pathname.new(tio.path),
352
355
  script: %(--#EVENT device datapoint\n-- do something.\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n)
@@ -383,7 +386,7 @@ end
383
386
  event: 'datapoint',
384
387
  svc_alias: nil,
385
388
  type: nil,
386
- line: 1,
389
+ line_beg: 1,
387
390
  line_end: 3,
388
391
  local_path: Pathname.new(tio.path),
389
392
  script: %(--#EVENT device datapoint\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n),
@@ -8,9 +8,11 @@
8
8
  require 'pathname'
9
9
  require 'tempfile'
10
10
  require 'MrMurano/version'
11
+ require 'MrMurano/HttpAuthed'
11
12
  require 'MrMurano/ProjectFile'
12
13
  require 'MrMurano/Solution-Services'
13
14
  require '_workspace'
15
+ require 'HttpAuthed_spec'
14
16
 
15
17
  RSpec.describe MrMurano::Module do
16
18
  include_context 'WORKSPACE'
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Module do
21
23
  $project.load
22
24
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
23
25
  $cfg['application.id'] = 'XYZ'
26
+ stub_request_email_password
24
27
 
25
28
  @srv = MrMurano::Module.new
26
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
29
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
27
30
  end
28
31
 
29
32
  it 'initializes' do
@@ -9,9 +9,11 @@ require 'pathname'
9
9
  require 'tempfile'
10
10
  require 'MrMurano/hash'
11
11
  require 'MrMurano/version'
12
+ require 'MrMurano/HttpAuthed'
12
13
  require 'MrMurano/Solution-Users'
13
14
  require 'MrMurano/SyncRoot'
14
15
  require '_workspace'
16
+ require 'HttpAuthed_spec'
15
17
 
16
18
  RSpec.describe MrMurano::Role do
17
19
  include_context 'WORKSPACE'
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Role do
21
23
  $cfg.load
22
24
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
23
25
  $cfg['application.id'] = 'XYZ'
26
+ stub_request_email_password
24
27
 
25
28
  @srv = MrMurano::Role.new
26
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
29
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
27
30
  end
28
31
 
29
32
  it 'initializes' do
@@ -8,10 +8,12 @@
8
8
  require 'tempfile'
9
9
  require 'yaml'
10
10
  require 'MrMurano/version'
11
+ require 'MrMurano/HttpAuthed'
11
12
  require 'MrMurano/ProjectFile'
12
13
  require 'MrMurano/Solution'
13
14
  require 'MrMurano/SyncRoot'
14
15
  require '_workspace'
16
+ require 'HttpAuthed_spec'
15
17
 
16
18
  RSpec.describe MrMurano::Solution do
17
19
  include_context 'WORKSPACE'
@@ -24,13 +26,14 @@ RSpec.describe MrMurano::Solution do
24
26
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
25
27
  $cfg['product.id'] = 'XYZ'
26
28
  $cfg['application.id'] = 'XYZ'
29
+ stub_request_email_password
27
30
 
28
31
  # NOTE: This test works on either Product or Application.
29
32
  # MAYBE: Add Application to this test.
30
33
  @srv = MrMurano::Product.new
31
34
  #@srv = MrMurano::Application.new
32
35
 
33
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
36
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
34
37
  end
35
38
 
36
39
  it 'initializes' do
@@ -34,7 +34,7 @@ class TSUD
34
34
  @valid_api_id
35
35
  end
36
36
 
37
- def fetch(id)
37
+ def fetch(id, _untainted=false)
38
38
  end
39
39
 
40
40
  def self.description
@@ -8,10 +8,12 @@
8
8
  require 'tempfile'
9
9
  require 'yaml'
10
10
  require 'MrMurano/version'
11
+ require 'MrMurano/HttpAuthed'
11
12
  require 'MrMurano/ProjectFile'
12
13
  require 'MrMurano/SyncRoot'
13
14
  require 'MrMurano/Webservice-Cors'
14
15
  require '_workspace'
16
+ require 'HttpAuthed_spec'
15
17
 
16
18
  RSpec.describe MrMurano::Webservice::Cors do
17
19
  include_context 'WORKSPACE'
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Webservice::Cors do
21
23
  $cfg.load
22
24
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
23
25
  $cfg['application.id'] = 'XYZ'
26
+ stub_request_email_password
24
27
 
25
28
  @srv = MrMurano::Webservice::Cors.new
26
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
29
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
27
30
 
28
31
  @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/cors'
29
32
  end
@@ -9,8 +9,10 @@ require 'pathname'
9
9
  require 'tempfile'
10
10
  require '_workspace'
11
11
  require 'MrMurano/version'
12
+ require 'MrMurano/HttpAuthed'
12
13
  require 'MrMurano/ProjectFile'
13
14
  require 'MrMurano/Webservice-Endpoint'
15
+ require 'HttpAuthed_spec'
14
16
 
15
17
  RSpec.describe MrMurano::Webservice::Endpoint do
16
18
  include_context 'WORKSPACE'
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Webservice::Endpoint do
21
23
  $project.load
22
24
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
23
25
  $cfg['application.id'] = 'XYZ'
26
+ stub_request_email_password
24
27
 
25
28
  @srv = MrMurano::Webservice::Endpoint.new
26
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
29
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
27
30
 
28
31
  @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/endpoint'
29
32
  end
@@ -483,7 +486,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
483
486
  path: '/one/two',
484
487
  content_type: 'application/json',
485
488
  local_path: Pathname.new(tio.path),
486
- line: 0,
489
+ line_beg: 0,
487
490
  script: "--#ENDPOINT GET /one/two\nreturn request\n",
488
491
  line_end: 2,
489
492
  }
@@ -512,7 +515,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
512
515
  path: '/one/two',
513
516
  content_type: 'application/json',
514
517
  local_path: Pathname.new(tio.path),
515
- line: 0,
518
+ line_beg: 0,
516
519
  script: "--#ENDPOINT GET /one/two\nreturn request\n",
517
520
  line_end: 2,
518
521
  },
@@ -521,7 +524,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
521
524
  path: '/one/two',
522
525
  content_type: 'application/json',
523
526
  local_path: Pathname.new(tio.path),
524
- line: 2,
527
+ line_beg: 2,
525
528
  script: "--#ENDPOINT PUT /one/two\nreturn request\n",
526
529
  line_end: 4,
527
530
  },
@@ -530,7 +533,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
530
533
  path: '/three/two',
531
534
  content_type: 'application/json',
532
535
  local_path: Pathname.new(tio.path),
533
- line: 4,
536
+ line_beg: 4,
534
537
  script: "--#ENDPOINT DELETE /three/two\nreturn request\n",
535
538
  line_end: 6,
536
539
  },
@@ -568,7 +571,7 @@ RSpec.describe MrMurano::Webservice::Endpoint do
568
571
  path: '/one/two',
569
572
  content_type: 'application/json',
570
573
  local_path: Pathname.new(tio.path),
571
- line: 1,
574
+ line_beg: 1,
572
575
  script: "--#ENDPOINT GET /one/two\nreturn request\n",
573
576
  line_end: 3,
574
577
  }
@@ -7,9 +7,11 @@
7
7
 
8
8
  require 'pathname'
9
9
  require 'MrMurano/version'
10
+ require 'MrMurano/HttpAuthed'
10
11
  require 'MrMurano/ProjectFile'
11
12
  require 'MrMurano/Webservice-File'
12
13
  require '_workspace'
14
+ require 'HttpAuthed_spec'
13
15
 
14
16
  RSpec.describe MrMurano::Webservice::File do
15
17
  include_context 'WORKSPACE'
@@ -21,9 +23,10 @@ RSpec.describe MrMurano::Webservice::File do
21
23
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
22
24
  $cfg['product.id'] = 'XYZ'
23
25
  $cfg['application.id'] = 'XYZ'
26
+ stub_request_email_password
24
27
 
25
28
  @srv = MrMurano::Webservice::File.new
26
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
29
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
27
30
 
28
31
  @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/file'
29
32
  @fileupload_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/fileupload'
@@ -104,6 +107,8 @@ RSpec.describe MrMurano::Webservice::File do
104
107
  }
105
108
  )
106
109
  .to_return(status: 200, body: 'nope')
110
+ # The progress bar clears itself, e.g., spaces to cover old message, than \r.
111
+ $cfg['tool.no-progress'] = true
107
112
  saved = $stdout
108
113
  $stdout = StringIO.new
109
114
  ret = @srv.fetch('/bob')
@@ -172,13 +177,17 @@ RSpec.describe MrMurano::Webservice::File do
172
177
  'Content-Type' => %r{multipart/form-data; boundary=.*},
173
178
  },
174
179
  )
180
+ $cfg['tool.no-progress'] = true
175
181
  $cfg['tool.curldebug'] = true
182
+ $cfg['tool.curlfancy'] = false
176
183
  $cfg.curlfile_f = nil
177
184
  saved = $stdout
178
185
  $stdout = StringIO.new
179
186
  @srv.upload(@lp, { path: '/one.text' }, false)
180
- expect($stdout.string).to match(
181
- %r{^curl -s -H 'Authorization: token TTTTTTTTTT'.*-X PUT '#{@fileupload_uri}/one.text' -F file=@.*$}
187
+ expect($stdout.string.lines).to match_array(
188
+ [
189
+ %r{^curl -s -H 'Authorization: token TTTTTTTTTT'.*-X PUT '#{@fileupload_uri}/one.text' -F file=@.*$},
190
+ ]
182
191
  )
183
192
  $stdout = saved
184
193
  end
@@ -255,7 +264,11 @@ RSpec.describe MrMurano::Webservice::File do
255
264
  expect(ret).to eq(
256
265
  path: '/files/one.text',
257
266
  mime_type: 'text/plain',
258
- checksum: 'd1af3dadf08479a1d43b282f95d61dda8efda5e7'
267
+ # 2018-04-16: Did backend change from SHA1 to MD5 hash function?
268
+ # You can calculate this with `sha1sum one.text`
269
+ #checksum: 'd1af3dadf08479a1d43b282f95d61dda8efda5e7'
270
+ # You can calculate this with `md5sum one.text`
271
+ checksum: 'e9ea4a5be73a09f541ad0b611083f0df'
259
272
  )
260
273
  end
261
274
  end
@@ -8,10 +8,12 @@
8
8
  require 'tempfile'
9
9
  require 'yaml'
10
10
  require 'MrMurano/version'
11
+ require 'MrMurano/HttpAuthed'
11
12
  require 'MrMurano/ProjectFile'
12
13
  require 'MrMurano/SyncRoot'
13
14
  require 'MrMurano/Webservice-Cors'
14
15
  require '_workspace'
16
+ require 'HttpAuthed_spec'
15
17
 
16
18
  RSpec.describe MrMurano::Webservice::Settings do
17
19
  include_context 'WORKSPACE'
@@ -21,11 +23,13 @@ RSpec.describe MrMurano::Webservice::Settings do
21
23
  $cfg.load
22
24
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
23
25
  $cfg['application.id'] = 'XYZ'
26
+ stub_request_email_password
24
27
 
25
28
  @srv = MrMurano::Webservice::Settings.new
26
- allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
27
29
 
28
- @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/cors'
30
+ MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
31
+
32
+ @base_uri = "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/XYZ/cors"
29
33
  end
30
34
 
31
35
  it 'initializes' do
data/spec/_workspace.rb CHANGED
@@ -12,6 +12,7 @@ require 'tmpdir'
12
12
  RSpec.shared_context 'WORKSPACE' do
13
13
  around(:example) do |ex|
14
14
  @testdir = Pathname.new(Dir.pwd).realpath
15
+ $exited_abnormally = true
15
16
  Dir.mktmpdir do |hdir|
16
17
  @tmpdir = hdir
17
18
  saved_home = ENV['HOME']
@@ -27,6 +28,7 @@ RSpec.shared_context 'WORKSPACE' do
27
28
  end
28
29
  ENV['HOME'] = saved_home
29
30
  end
31
+ $exited_abnormally = false
30
32
  end
31
33
  end
32
34