MuranoCLI 3.2.1.pre.beta.6 → 3.2.1.pre.beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +10 -0
  3. data/MuranoCLI.gemspec +37 -6
  4. data/Rakefile +38 -11
  5. data/lib/MrMurano/commands/business.rb +0 -4
  6. data/lib/MrMurano/version.rb +1 -1
  7. metadata +2 -251
  8. data/dockers/Dockerfile.2.2.9 +0 -40
  9. data/dockers/Dockerfile.2.3.6 +0 -40
  10. data/dockers/Dockerfile.2.4.3 +0 -40
  11. data/dockers/Dockerfile.2.5.0 +0 -40
  12. data/dockers/Dockerfile.GemRelease +0 -49
  13. data/dockers/Dockerfile.m4 +0 -122
  14. data/dockers/README.rst +0 -362
  15. data/dockers/RELEASE.rst +0 -135
  16. data/dockers/docker-test.sh +0 -163
  17. data/dockers/gem-release.sh +0 -4
  18. data/docs/basic_example.rst +0 -436
  19. data/docs/ci/.trustme.plugin +0 -140
  20. data/docs/ci/.trustme.sh +0 -516
  21. data/docs/ci/.trustme.vim +0 -55
  22. data/docs/completions/murano_completion-bash +0 -4484
  23. data/docs/demo.md +0 -109
  24. data/docs/develop.rst +0 -392
  25. data/docs/release.rst +0 -295
  26. data/spec/Account-Passwords_spec.rb +0 -245
  27. data/spec/Account_spec.rb +0 -256
  28. data/spec/Business_spec.rb +0 -307
  29. data/spec/ConfigFile_spec.rb +0 -55
  30. data/spec/ConfigMigrate_spec.rb +0 -108
  31. data/spec/Config_spec.rb +0 -440
  32. data/spec/Content_spec.rb +0 -422
  33. data/spec/GatewayBase_spec.rb +0 -65
  34. data/spec/GatewayDevice_spec.rb +0 -403
  35. data/spec/GatewayResource_spec.rb +0 -283
  36. data/spec/GatewaySettings_spec.rb +0 -130
  37. data/spec/HttpAuthed_spec.rb +0 -87
  38. data/spec/Http_spec.rb +0 -220
  39. data/spec/MakePretties_spec.rb +0 -127
  40. data/spec/Mock_spec.rb +0 -62
  41. data/spec/ProjectFile_spec.rb +0 -381
  42. data/spec/Setting_spec.rb +0 -120
  43. data/spec/Solution-ServiceConfig_spec.rb +0 -272
  44. data/spec/Solution-ServiceEventHandler_spec.rb +0 -442
  45. data/spec/Solution-ServiceModules_spec.rb +0 -562
  46. data/spec/Solution-UsersRoles_spec.rb +0 -269
  47. data/spec/Solution_spec.rb +0 -140
  48. data/spec/SyncRoot_spec.rb +0 -111
  49. data/spec/SyncUpDown_spec.rb +0 -868
  50. data/spec/Verbosing_spec.rb +0 -332
  51. data/spec/Webservice-Cors_spec.rb +0 -225
  52. data/spec/Webservice-Endpoint_spec.rb +0 -650
  53. data/spec/Webservice-File_spec.rb +0 -282
  54. data/spec/Webservice-Setting_spec.rb +0 -105
  55. data/spec/_workspace.rb +0 -43
  56. data/spec/cmd_business_spec.rb +0 -64
  57. data/spec/cmd_common.rb +0 -507
  58. data/spec/cmd_config_spec.rb +0 -73
  59. data/spec/cmd_content_spec.rb +0 -109
  60. data/spec/cmd_cors_spec.rb +0 -54
  61. data/spec/cmd_device_spec.rb +0 -130
  62. data/spec/cmd_domain_spec.rb +0 -62
  63. data/spec/cmd_element_spec.rb +0 -401
  64. data/spec/cmd_exchange_spec.rb +0 -114
  65. data/spec/cmd_help_spec.rb +0 -72
  66. data/spec/cmd_init_spec.rb +0 -475
  67. data/spec/cmd_keystore_spec.rb +0 -97
  68. data/spec/cmd_link_spec.rb +0 -105
  69. data/spec/cmd_logs_spec.rb +0 -162
  70. data/spec/cmd_password_spec.rb +0 -64
  71. data/spec/cmd_setting_application_spec.rb +0 -300
  72. data/spec/cmd_setting_product_spec.rb +0 -246
  73. data/spec/cmd_status_spec.rb +0 -300
  74. data/spec/cmd_syncdown_application_spec.rb +0 -128
  75. data/spec/cmd_syncdown_both_spec.rb +0 -178
  76. data/spec/cmd_syncdown_unit_spec.rb +0 -861
  77. data/spec/cmd_syncup_spec.rb +0 -148
  78. data/spec/cmd_token_spec.rb +0 -53
  79. data/spec/cmd_usage_spec.rb +0 -79
  80. data/spec/dry_run_formatter.rb +0 -28
  81. data/spec/fixtures/.mrmuranorc +0 -9
  82. data/spec/fixtures/ProjectFiles/invalid.yaml +0 -9
  83. data/spec/fixtures/ProjectFiles/only_meta.yaml +0 -24
  84. data/spec/fixtures/ProjectFiles/with_routes.yaml +0 -27
  85. data/spec/fixtures/SolutionFiles/0.2.0.json +0 -20
  86. data/spec/fixtures/SolutionFiles/0.2.0_invalid.json +0 -18
  87. data/spec/fixtures/SolutionFiles/0.2.json +0 -21
  88. data/spec/fixtures/SolutionFiles/0.3.0.json +0 -20
  89. data/spec/fixtures/SolutionFiles/0.3.0_invalid.json +0 -19
  90. data/spec/fixtures/SolutionFiles/0.3.json +0 -20
  91. data/spec/fixtures/SolutionFiles/basic.json +0 -20
  92. data/spec/fixtures/SolutionFiles/secret.json +0 -6
  93. data/spec/fixtures/configfile +0 -9
  94. data/spec/fixtures/dumped_config +0 -57
  95. data/spec/fixtures/exchange_element/element-show.json +0 -1
  96. data/spec/fixtures/exchange_element/swagger-mur-6407__10k.yaml +0 -282
  97. data/spec/fixtures/exchange_element/swagger-mur-6407__20k.yaml +0 -588
  98. data/spec/fixtures/gateway_resource_files/resources.notyaml +0 -12
  99. data/spec/fixtures/gateway_resource_files/resources.yaml +0 -13
  100. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +0 -13
  101. data/spec/fixtures/mrmuranorc_deleted_bob +0 -6
  102. data/spec/fixtures/mrmuranorc_tool_bob +0 -3
  103. data/spec/fixtures/product_spec_files/example.exoline.spec.yaml +0 -116
  104. data/spec/fixtures/product_spec_files/example.murano.spec.yaml +0 -14
  105. data/spec/fixtures/product_spec_files/gwe.exoline.spec.yaml +0 -21
  106. data/spec/fixtures/product_spec_files/gwe.murano.spec.yaml +0 -16
  107. data/spec/fixtures/product_spec_files/lightbulb-no-state.yaml +0 -11
  108. data/spec/fixtures/product_spec_files/lightbulb.yaml +0 -21
  109. data/spec/fixtures/roles-three.yaml +0 -11
  110. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 0.webmock +0 -98
  111. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 1.webmock +0 -98
  112. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value No.webmock +0 -98
  113. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value Yes.webmock +0 -98
  114. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value bob.webmock +0 -72
  115. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value false.webmock +0 -98
  116. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value off.webmock +0 -98
  117. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on STDIN.webmock +0 -98
  118. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on.webmock +0 -98
  119. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value true.webmock +0 -98
  120. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob with STDIN.webmock +0 -98
  121. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob.webmock +0 -98
  122. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) an array.webmock +0 -98
  123. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) appends an array.webmock +0 -98
  124. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors to a file.webmock +0 -72
  125. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors.webmock +0 -72
  126. data/spec/fixtures/snapshots/murano business list as json.webmock +0 -27
  127. data/spec/fixtures/snapshots/murano business list as table.webmock +0 -27
  128. data/spec/fixtures/snapshots/murano business list fewer fields.webmock +0 -27
  129. data/spec/fixtures/snapshots/murano business list only ids.webmock +0 -27
  130. data/spec/fixtures/snapshots/murano business list output to file.webmock +0 -27
  131. data/spec/fixtures/snapshots/murano business without project help.webmock +0 -9
  132. data/spec/fixtures/snapshots/murano config Needs a key.webmock +0 -9
  133. data/spec/fixtures/snapshots/murano config Reads a key.webmock +0 -9
  134. data/spec/fixtures/snapshots/murano config Removes a key.webmock +0 -9
  135. data/spec/fixtures/snapshots/murano config Sets a key.webmock +0 -9
  136. data/spec/fixtures/snapshots/murano config Sets a user key.webmock +0 -9
  137. data/spec/fixtures/snapshots/murano content life cycle.webmock +0 -144
  138. data/spec/fixtures/snapshots/murano cors sets CORS.webmock +0 -78
  139. data/spec/fixtures/snapshots/murano cors show CORS.webmock +0 -64
  140. data/spec/fixtures/snapshots/murano device activates.webmock +0 -86
  141. data/spec/fixtures/snapshots/murano device enables a batch.webmock +0 -76
  142. data/spec/fixtures/snapshots/murano device enables and lists.webmock +0 -78
  143. data/spec/fixtures/snapshots/murano device writes and reads.webmock +0 -136
  144. data/spec/fixtures/snapshots/murano domain show domain.webmock +0 -101
  145. data/spec/fixtures/snapshots/murano element edit unknown as unknown element.webmock +0 -43
  146. data/spec/fixtures/snapshots/murano element show --help.webmock +0 -9
  147. data/spec/fixtures/snapshots/murano element show as csv.webmock +0 -43
  148. data/spec/fixtures/snapshots/murano element show as default-table.webmock +0 -43
  149. data/spec/fixtures/snapshots/murano element show as json.webmock +0 -43
  150. data/spec/fixtures/snapshots/murano element show as table truncate.webmock +0 -43
  151. data/spec/fixtures/snapshots/murano element show as table wrap.webmock +0 -43
  152. data/spec/fixtures/snapshots/murano element show as yaml.webmock +0 -43
  153. data/spec/fixtures/snapshots/murano element show using ambiguous name.webmock +0 -43
  154. data/spec/fixtures/snapshots/murano element without project usage.webmock +0 -9
  155. data/spec/fixtures/snapshots/murano exchange with project list as json.webmock +0 -59
  156. data/spec/fixtures/snapshots/murano exchange with project list as table.webmock +0 -59
  157. data/spec/fixtures/snapshots/murano exchange with project list fewer fields.webmock +0 -59
  158. data/spec/fixtures/snapshots/murano exchange with project list only ids.webmock +0 -59
  159. data/spec/fixtures/snapshots/murano exchange with project list output to file.webmock +0 -59
  160. data/spec/fixtures/snapshots/murano exchange with project list purchase is already added ID.webmock +0 -83
  161. data/spec/fixtures/snapshots/murano exchange with project list purchase is ambiguous name.webmock +0 -59
  162. data/spec/fixtures/snapshots/murano exchange without project help.webmock +0 -9
  163. data/spec/fixtures/snapshots/murano help using commander as --help.webmock +0 -9
  164. data/spec/fixtures/snapshots/murano help using commander no args.webmock +0 -9
  165. data/spec/fixtures/snapshots/murano help using subshell no args.webmock +0 -9
  166. data/spec/fixtures/snapshots/murano help using subshell with --help.webmock +0 -9
  167. data/spec/fixtures/snapshots/murano init Won't init in HOME (gracefully).webmock +0 -9
  168. data/spec/fixtures/snapshots/murano init in empty directory with existing project.webmock +0 -201
  169. data/spec/fixtures/snapshots/murano init in empty directory without existing project.webmock +0 -193
  170. data/spec/fixtures/snapshots/murano init in existing project directory with ProjectFile.webmock +0 -213
  171. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.2.0.webmock +0 -213
  172. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.3.0.webmock +0 -213
  173. data/spec/fixtures/snapshots/murano init in existing project directory without ProjectFile.webmock +0 -213
  174. data/spec/fixtures/snapshots/murano keystore can call other commands.webmock +0 -108
  175. data/spec/fixtures/snapshots/murano keystore clearAll.webmock +0 -124
  176. data/spec/fixtures/snapshots/murano keystore deletes.webmock +0 -112
  177. data/spec/fixtures/snapshots/murano keystore gets.webmock +0 -96
  178. data/spec/fixtures/snapshots/murano keystore infos.webmock +0 -96
  179. data/spec/fixtures/snapshots/murano keystore lists.webmock +0 -96
  180. data/spec/fixtures/snapshots/murano link with project links and lists.webmock +0 -149
  181. data/spec/fixtures/snapshots/murano link with project unlinks.webmock +0 -165
  182. data/spec/fixtures/snapshots/murano link without project help.webmock +0 -9
  183. data/spec/fixtures/snapshots/murano link without project subshell vs inline using commander will not list.webmock +0 -27
  184. data/spec/fixtures/snapshots/murano link without project subshell vs inline using subshell will not list.webmock +0 -27
  185. data/spec/fixtures/snapshots/murano logs when project is setup tail log.webmock +0 -9
  186. data/spec/fixtures/snapshots/murano password Lists when no file.webmock +0 -9
  187. data/spec/fixtures/snapshots/murano password deletes a password.webmock +0 -9
  188. data/spec/fixtures/snapshots/murano password sets a password.webmock +0 -9
  189. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value on STDIN.webmock +0 -90
  190. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value.webmock +0 -90
  191. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value fiftyHalf.webmock +0 -64
  192. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value float 12.67.webmock +0 -90
  193. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value integer 12.webmock +0 -90
  194. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value on STDIN.webmock +0 -90
  195. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a string value.webmock +0 -90
  196. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) merges into a dictionary.webmock +0 -90
  197. data/spec/fixtures/snapshots/murano single sync without ProjectFile syncdown.webmock +0 -322
  198. data/spec/fixtures/snapshots/murano status with ProjectFile status.webmock +0 -153
  199. data/spec/fixtures/snapshots/murano status with Solutionfile 0.2.0 status.webmock +0 -153
  200. data/spec/fixtures/snapshots/murano status with Solutionfile 0.3.0 status.webmock +0 -153
  201. data/spec/fixtures/snapshots/murano status without ProjectFile matches file path.webmock +0 -153
  202. data/spec/fixtures/snapshots/murano status without ProjectFile matches route.webmock +0 -153
  203. data/spec/fixtures/snapshots/murano status without ProjectFile status.webmock +0 -153
  204. data/spec/fixtures/snapshots/murano syncdown stubbed without ProjectFile syncdown.webmock +0 -151
  205. data/spec/fixtures/snapshots/murano syncdown without ProjectFile syncdown.webmock +0 -479
  206. data/spec/fixtures/snapshots/murano syncup without ProjectFile syncup.webmock +0 -357
  207. data/spec/fixtures/snapshots/murano token with project list as table.webmock +0 -9
  208. data/spec/fixtures/snapshots/murano token without project help.webmock +0 -9
  209. data/spec/fixtures/snapshots/murano usage show usage.webmock +0 -93
  210. data/spec/fixtures/syncable_conflict/services/devdata.lua +0 -18
  211. data/spec/fixtures/syncable_conflict/services/timers.lua +0 -4
  212. data/spec/fixtures/syncable_content/assets/icon.png +0 -0
  213. data/spec/fixtures/syncable_content/assets/index.html +0 -0
  214. data/spec/fixtures/syncable_content/assets/js/script.js +0 -0
  215. data/spec/fixtures/syncable_content/modules/table_util.lua +0 -58
  216. data/spec/fixtures/syncable_content/routes/manyRoutes.lua +0 -11
  217. data/spec/fixtures/syncable_content/routes/singleRoute.lua +0 -5
  218. data/spec/fixtures/websocket/README.rst +0 -110
  219. data/spec/fixtures/websocket/logs_blather.rb +0 -27
  220. data/spec/fixtures/websocket/logs_faker.rb +0 -153
  221. data/spec/fixtures/websocket/simple_connection.rb +0 -45
  222. data/spec/fixtures/websocket/simple_options.rb +0 -77
  223. data/spec/fixtures/websocket/simple_server.rb +0 -69
  224. data/spec/fixtures/websocket/wss-echo.rb +0 -48
  225. data/spec/fixtures/websocket/wss-fake-logs.rb +0 -20
  226. data/spec/spec_helper.rb +0 -131
  227. data/spec/variegated_TruthyFalsey_spec.rb +0 -29
  228. data/spec/webmock_snapshot.rb +0 -296
@@ -1,130 +0,0 @@
1
- # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
- # License: PROPRIETARY. See LICENSE.txt.
3
- # frozen_string_literal: true
4
-
5
- # vim:tw=0:ts=2:sw=2:et:ai
6
- # Unauthorized copying of this file is strictly prohibited.
7
-
8
- require 'fileutils'
9
- require 'MrMurano/version'
10
- require 'MrMurano/HttpAuthed'
11
- require 'MrMurano/Gateway'
12
- require 'MrMurano/SyncRoot'
13
- require '_workspace'
14
- require 'HttpAuthed_spec'
15
-
16
- RSpec.describe MrMurano::Gateway::Settings do
17
- include_context 'WORKSPACE'
18
-
19
- before(:example) do
20
- $cfg = MrMurano::Config.new
21
- $cfg.load
22
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
23
- $cfg['product.id'] = 'XYZ'
24
- stub_request_email_password
25
-
26
- @gw = MrMurano::Gateway::Settings.new
27
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
28
-
29
- @infoblob = {
30
- name: 'XXXXXXXX',
31
- protocol: { name: 'onep', devmode: false },
32
- description: 'XXXXXXXX',
33
- identity_format: {
34
- prefix: '', type: 'opaque', options: { casing: 'mixed', length: 0 },
35
- },
36
- fqdn: 'XXXXXXXX.m2.exosite-staging.io',
37
- provisioning: {
38
- auth_type: 'token',
39
- enabled: true,
40
- generate_identity: true,
41
- presenter_identity: true,
42
- ip_whitelisting: { enabled: false, allowed: [] },
43
- },
44
- resources: {
45
- bob: { format: 'string', unit: 'c', settable: true },
46
- fuzz: { format: 'string', unit: 'c', settable: true },
47
- gruble: { format: 'string', unit: 'bits', settable: true },
48
- },
49
- }
50
- end
51
-
52
- it 'initializes' do
53
- uri = @gw.endpoint('/')
54
- expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/')
55
- end
56
-
57
- context 'protocol' do
58
- context 'reads' do
59
- it 'data' do
60
- stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
61
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' })
62
- .to_return(status: 200, body: @infoblob.to_json, headers: {})
63
-
64
- ret = @gw.protocol
65
- expect(ret).to eq(@infoblob[:protocol])
66
- end
67
-
68
- it 'returns empty if not Hash' do
69
- stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
70
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' })
71
- .to_return(status: 200, body: ['bob'].to_json, headers: {})
72
-
73
- ret = @gw.protocol
74
- expect(ret).to eq({})
75
- end
76
-
77
- it 'returns empty if missing protocol' do
78
- foo = @infoblob.dup
79
- foo.delete :protocol
80
- stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
81
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' })
82
- .to_return(status: 200, body: foo.to_json, headers: {})
83
-
84
- ret = @gw.protocol
85
- expect(ret).to eq({})
86
- end
87
-
88
- it 'returns empty if protocol not Hash' do
89
- foo = @infoblob.dup
90
- foo[:protocol] = 'bob'
91
- stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
92
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' })
93
- .to_return(status: 200, body: foo.to_json, headers: {})
94
-
95
- ret = @gw.protocol
96
- expect(ret).to eq({})
97
- end
98
- end
99
- context 'writes' do
100
- it 'data' do
101
- newvalues = { name: 'twelve', devmode: true }
102
- stub_request(:patch, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
103
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
104
- 'Content-Type' => 'application/json', },
105
- body: { protocol: newvalues }.to_json)
106
- .to_return(status: 200, headers: {})
107
-
108
- ret = @gw.protocol = (newvalues)
109
- expect(ret).to eq(newvalues)
110
- end
111
-
112
- it 'raises when not Hash' do
113
- expect { @gw.protocol = ('foo') }.to raise_error 'Not Hash'
114
- end
115
-
116
- it 'strips extra keys' do
117
- newvalues = { name: 'twelve', devmode: true, auth: 'yes', bob: :built }
118
- stub_request(:patch, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
119
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
120
- 'Content-Type' => 'application/json', },
121
- body: { protocol: { name: 'twelve', devmode: true } }.to_json)
122
- .to_return(status: 200, headers: {})
123
-
124
- ret = @gw.protocol = (newvalues)
125
- expect(ret).to eq(newvalues)
126
- end
127
- end
128
- end
129
- end
130
-
@@ -1,87 +0,0 @@
1
- # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
- # License: PROPRIETARY. See LICENSE.txt.
3
- # frozen_string_literal: true
4
-
5
- # vim:tw=0:ts=2:sw=2:et:ai
6
- # Unauthorized copying of this file is strictly prohibited.
7
-
8
- require 'MrMurano/HttpAuthed'
9
-
10
- # (lb): Not sure why, but getting "method redefined" errors, so need
11
- # defined? guard clauses around method definitions. Otherwise, e.g.,:
12
- # MuranoCLI/spec/HttpAuthed_spec.rb:10: warning: method redefined;
13
- # discarding old stub_request_email_password_from_cfg
14
- # MuranoCLI/spec/HttpAuthed_spec.rb:10: warning: previous definition of
15
- # stub_request_email_password_from_cfg was here
16
-
17
- unless defined? LEGIT_LOOKING_TOKEN
18
- LEGIT_LOOKING_TOKEN = '0123456789ABCDEF0123456789ABCDEF01234567'
19
- end
20
-
21
- unless defined? stub_request_email_password_from_cfg
22
- def stub_request_email_password_from_cfg
23
- stub_request(
24
- :post,
25
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/token/"
26
- ).with(
27
- body: {
28
- email: $cfg['user.name'],
29
- password: MrMurano::HttpAuthed.instance.password,
30
- }.to_json
31
- ).to_return(
32
- status: 200,
33
- body: { token: LEGIT_LOOKING_TOKEN }.to_json,
34
- headers: {}
35
- )
36
- end
37
- end
38
-
39
- unless defined? stub_request_email_password_from_bob
40
- def stub_request_email_password_from_bob
41
- stub_request(
42
- :post,
43
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/token/"
44
- ).with(
45
- body: {
46
- email: 'bob',
47
- password: 'v',
48
- }.to_json
49
- ).to_return(
50
- status: 200,
51
- body: { token: LEGIT_LOOKING_TOKEN }.to_json,
52
- headers: {}
53
- )
54
- end
55
- end
56
-
57
- unless defined? stub_request_token_verification
58
- def stub_request_token_verification
59
- stub_request(
60
- :get,
61
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/token/#{LEGIT_LOOKING_TOKEN}"
62
- ).to_return(
63
- status: 200,
64
- body: {}.to_json,
65
- headers: {}
66
- )
67
- end
68
- end
69
-
70
- unless defined? stub_request_email_password
71
- def stub_request_email_password
72
- stub_request_email_password_from_cfg
73
- stub_request_email_password_from_bob
74
- stub_request_token_verification
75
- end
76
- end
77
-
78
- unless defined? create_instance_double_passwords
79
- def create_instance_double_passwords
80
- pswd = instance_double('MrMurano::Passwords')
81
- allow(pswd).to receive(:load).and_return(nil)
82
- allow(pswd).to receive(:save).and_return(nil)
83
- allow(MrMurano::Passwords).to receive(:new).and_return(pswd)
84
- pswd
85
- end
86
- end
87
-
data/spec/Http_spec.rb DELETED
@@ -1,220 +0,0 @@
1
- # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
- # License: PROPRIETARY. See LICENSE.txt.
3
- # frozen_string_literal: true
4
-
5
- # vim:tw=0:ts=2:sw=2:et:ai
6
- # Unauthorized copying of this file is strictly prohibited.
7
-
8
- require 'MrMurano/version'
9
- require 'MrMurano/http'
10
- require 'MrMurano/verbosing'
11
- require 'MrMurano/Account'
12
- require 'MrMurano/HttpAuthed'
13
- require '_workspace'
14
-
15
- RSpec.describe MrMurano::Http do
16
- include_context 'WORKSPACE'
17
-
18
- before(:example) do
19
- $cfg = MrMurano::Config.new
20
- $cfg.load
21
- @hauth = MrMurano::HttpAuthed.instance
22
- end
23
-
24
- context 'gets a token' do
25
- before(:example) do
26
- @acc = instance_double('MrMurano::Account')
27
- allow(MrMurano::Account).to receive(:new).and_return(@acc)
28
- end
29
-
30
- it 'already has one' do
31
- @hauth.instance_variable_set(:@token_biz, 'ABCDEFG')
32
- ret = @hauth.token
33
- expect(ret).to eq('ABCDEFG')
34
- end
35
-
36
- it 'gets one' do
37
- expect(@hauth).to receive(:token).and_return('ABCDEFG')
38
- ret = @hauth.token
39
- expect(ret).to eq('ABCDEFG')
40
- end
41
-
42
- it 'raises when not logged in' do
43
- expect(@hauth).to receive(:token).and_return(nil)
44
- # 2017-07-13: The token command used to raise an error, but [lb]
45
- # doesn't like seeing the "use --trace" message that Ruby spits
46
- # out. So write to stderr and exit instead. Here, use check that
47
- # the function exits by expecting it to raise SystemExit.
48
- expect do
49
- @hauth.ensure_token!
50
- end.to raise_error(SystemExit).and output("\e[31mNot logged in!\e[0m\n").to_stderr
51
- end
52
- end
53
-
54
- context 'puts curl request' do
55
- before(:example) do
56
- @req = Net::HTTP::Get.new URI('https://test.host/this/is/a/test')
57
- @req.content_type = 'application/json'
58
- @req['User-Agent'] = 'test'
59
- end
60
- it 'puts nothing' do
61
- $cfg['tool.curldebug'] = false
62
- $stdout = StringIO.new
63
- @hauth.curldebug(@req)
64
- expect($stdout.string).to eq('')
65
- end
66
-
67
- it 'puts something' do
68
- $cfg['tool.curldebug'] = true
69
- $cfg.curlfile_f = nil
70
- $stdout = StringIO.new
71
- @hauth.curldebug(@req)
72
- expect($stdout.string).to eq(
73
- %(curl -s -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test'\n)
74
- )
75
- end
76
-
77
- it 'puts something with Auth' do
78
- $cfg['tool.curldebug'] = true
79
- $cfg.curlfile_f = nil
80
- $stdout = StringIO.new
81
- @req['Authorization'] = 'LetMeIn'
82
- @hauth.curldebug(@req)
83
- expect($stdout.string).to eq(
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)
85
- )
86
- end
87
-
88
- it 'puts something with Body' do
89
- $cfg['tool.curldebug'] = true
90
- $cfg.curlfile_f = nil
91
- $stdout = StringIO.new
92
- @req.body = 'builder'
93
- @hauth.curldebug(@req)
94
- expect($stdout.string).to eq(
95
- %(curl -s -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test' -d 'builder'\n)
96
- )
97
- end
98
- end
99
-
100
- context 'checks if JSON' do
101
- it 'is JSON' do
102
- ok, data = @hauth.isJSON(%({"one": "two", "three":[1,2,3,4,5,6]}))
103
- expect(ok).to be true
104
- expect(data).to eq(one: 'two',
105
- three: [1, 2, 3, 4, 5, 6])
106
- end
107
- it 'is not JSON' do
108
- ok, data = @hauth.isJSON(%(woeiutepoxam))
109
- expect(ok).to be false
110
- expect(data).to eq('woeiutepoxam')
111
- end
112
- end
113
-
114
- context 'shows HTTP errors' do
115
- before(:example) do
116
- @req = Net::HTTP::Get.new URI('https://test.host/this/is/a/test')
117
- @req.content_type = 'application/json'
118
- @req['User-Agent'] = 'test'
119
- @rsp = Net::HTTPGone.new('1.1', 410, 'ok')
120
- end
121
-
122
- it 'shows debug details' do
123
- $cfg['tool.debug'] = true
124
- $stdout = StringIO.new
125
- $stderr = StringIO.new
126
-
127
- allow(@rsp).to receive(:body).and_return('ok')
128
- expect(@hauth).to receive(:error).once.with('Request Failed: 410: ok')
129
-
130
- @hauth.showHttpError(@req, @rsp)
131
- expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
132
- > Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
133
- > Accept: */*
134
- > User-Agent: test
135
- > Host: test.host
136
- > Content-Type: application/json
137
- Got 410 ok
138
- ).gsub(/^\s+/, ''))
139
- expect($stderr.string).to eq('')
140
- end
141
-
142
- it 'shows debug details; has req body' do
143
- $cfg['tool.debug'] = true
144
- $stdout = StringIO.new
145
- $stderr = StringIO.new
146
-
147
- allow(@req).to receive(:body).and_return('this is my body')
148
- allow(@rsp).to receive(:body).and_return('ok')
149
- expect(@hauth).to receive(:error).once.with('Request Failed: 410: ok')
150
-
151
- @hauth.showHttpError(@req, @rsp)
152
- expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
153
- > Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
154
- > Accept: */*
155
- > User-Agent: test
156
- > Host: test.host
157
- > Content-Type: application/json
158
- >> this is my body
159
- Got 410 ok
160
- ).gsub(/^\s+/, ''))
161
- expect($stderr.string).to eq('')
162
- end
163
-
164
- it 'shows debug details; json body' do
165
- $cfg['tool.debug'] = true
166
- $stdout = StringIO.new
167
- $stderr = StringIO.new
168
-
169
- allow(@rsp).to receive(:body).and_return(%({"statusCode": 123, "message": "ok"}))
170
- expect(@hauth).to receive(:error).once.with('Request Failed: 410: [123] ok')
171
-
172
- @hauth.showHttpError(@req, @rsp)
173
- expect($stdout.string).to eq(%(Sent GET https://test.host/this/is/a/test
174
- > Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
175
- > Accept: */*
176
- > User-Agent: test
177
- > Host: test.host
178
- > Content-Type: application/json
179
- Got 410 ok
180
- ).gsub(/^\s+/, ''))
181
- expect($stderr.string).to eq('')
182
- end
183
-
184
- it 'shows full error responses' do
185
- $cfg['tool.fullerror'] = true
186
- $stdout = StringIO.new
187
- $stderr = StringIO.new
188
-
189
- allow(@rsp).to receive(:body).and_return(%({"statusCode": 123, "message": "ok"}))
190
- expect(@hauth).to receive(:error).once.with(
191
- "Request Failed: 410: {\n \"statusCode\": 123,\n \"message\": \"ok\"\n}"
192
- )
193
-
194
- @hauth.showHttpError(@req, @rsp)
195
- expect($stdout.string).to eq('')
196
- expect($stderr.string).to eq('')
197
- end
198
-
199
- it 'calls showHttpError' do
200
- $stdout = StringIO.new
201
- $stderr = StringIO.new
202
-
203
- idhttp = instance_double('Net::HTTP')
204
- expect(idhttp).to receive(:request).once.and_return(@rsp)
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
- )
213
-
214
- @hauth.workit(@req)
215
- expect($stdout.string).to eq('')
216
- expect($stderr.string).to eq("\e[31mRequest Failed: 410: [123] gone\e[0m\n")
217
- end
218
- end
219
- end
220
-
@@ -1,127 +0,0 @@
1
- # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
- # License: PROPRIETARY. See LICENSE.txt.
3
- # frozen_string_literal: true
4
-
5
- # vim:tw=0:ts=2:sw=2:et:ai
6
- # Unauthorized copying of this file is strictly prohibited.
7
-
8
- require 'MrMurano/version'
9
- require 'MrMurano/makePretty'
10
-
11
- RSpec.describe MrMurano::Pretties do
12
- before(:example) do
13
- @options = { pretty: true, localtime: false }
14
- # [lb] not sure how to fix this warning...
15
- # rubocop:disable Style/MethodMissing
16
- # "When using method_missing, define respond_to_missing?"
17
- def @options.method_missing(mid)
18
- self[mid]
19
- end
20
- end
21
-
22
- it 'makes json pretty with color' do
23
- data = { type: 'debug', timestamp: 1_476_386_031,
24
- subject: 'websocket_websocket_info',
25
- data: 'Script Error: ', }
26
- str = "\e[35m{\e[0m\n \"type\": \"debug\",\n \"timestamp\": 1476386031,\n \"subject\": \"websocket_websocket_info\",\n \"data\": \"Script Error: \"\n\e[35m}\e[0m"
27
- ret = MrMurano::Pretties.makeJsonPretty(data, @options)
28
- expect(ret).to eq(str)
29
- end
30
- it 'makes json pretty without color' do
31
- data = { type: 'debug', timestamp: 1_476_386_031,
32
- subject: 'websocket_websocket_info',
33
- data: 'Script Error: ', }
34
- str = '{"type":"debug","timestamp":1476386031,"subject":"websocket_websocket_info","data":"Script Error: "}'
35
- @options[:pretty] = false
36
- ret = MrMurano::Pretties.makeJsonPretty(data, @options)
37
- expect(ret).to eq(str)
38
- end
39
-
40
- it 'makes it pretty.' do
41
- data = { type: 'debug', timestamp: 1_476_386_031,
42
- subject: 'websocket_websocket_info',
43
- data: 'Script Error: ', }
44
- str = "\e[36mDEBUG \e[0m\e[36m[websocket_websocket_info]\e[0m \e[34m2016-10-13 19:13:51\e[0m:\nScript Error: "
45
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
46
- expect(ret).to eq(str)
47
- end
48
-
49
- it 'makes it pretty; missing type' do
50
- data = { timestamp: 1_476_386_031,
51
- subject: 'websocket_websocket_info',
52
- data: 'Script Error: ', }
53
- str = "\e[36m-- \e[0m\e[36m[websocket_websocket_info]\e[0m \e[34m2016-10-13 19:13:51\e[0m:\nScript Error: "
54
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
55
- expect(ret).to eq(str)
56
- end
57
-
58
- it 'makes it pretty; localtime' do
59
- data = { type: 'debug', timestamp: 1_476_386_031,
60
- subject: 'websocket_websocket_info',
61
- data: 'Script Error: ', }
62
- ldt = Time.at(1_476_386_031).localtime.strftime('%Y-%m-%d %H:%M:%S')
63
- str = "\e[36mDEBUG \e[0m\e[36m[websocket_websocket_info]\e[0m \e[34m#{ldt}\e[0m:\nScript Error: "
64
- @options[:localtime] = true
65
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
66
- @options[:localtime] = false
67
- expect(ret).to eq(str)
68
- end
69
-
70
- it 'makes it pretty; missing timestamp' do
71
- data = { type: 'debug',
72
- subject: 'websocket_websocket_info',
73
- data: 'Script Error: ', }
74
- str = "\e[36mDEBUG \e[0m\e[36m[websocket_websocket_info]\e[0m \e[34m<no timestamp>\e[0m:\nScript Error: "
75
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
76
- expect(ret).to eq(str)
77
- end
78
-
79
- it 'makes it pretty; missing subject' do
80
- data = { type: 'debug', timestamp: 1_476_386_031,
81
- data: 'Script Error: ', }
82
- str = "\e[36mDEBUG \e[0m\e[36m[]\e[0m \e[34m2016-10-13 19:13:51\e[0m:\nScript Error: "
83
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
84
- expect(ret).to eq(str)
85
- end
86
-
87
- it 'makes it pretty; missing data' do
88
- data = { type: 'debug', timestamp: 1_476_386_031,
89
- subject: 'websocket_websocket_info', }
90
- str = "\e[36mDEBUG \e[0m\e[36m[websocket_websocket_info]\e[0m \e[34m2016-10-13 19:13:51\e[0m:\n\e[35m{\e[0m\n\e[35m}\e[0m"
91
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
92
- expect(ret).to eq(str)
93
- end
94
-
95
- it 'makes it pretty; NAN timestamp' do
96
- data = { type: 'debug', timestamp: 'bob',
97
- subject: 'websocket_websocket_info',
98
- data: 'Script Error: ', }
99
- str = "\e[36mDEBUG \e[0m\e[36m[websocket_websocket_info]\e[0m \e[34mbob\e[0m:\nScript Error: "
100
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
101
- expect(ret).to eq(str)
102
- end
103
-
104
- it 'makes it pretty; hash data' do
105
- data = { type: 'debug', timestamp: 1_476_386_031,
106
- subject: 'websocket_websocket_info',
107
- data: {
108
- random: 'junk',
109
- }, }
110
- str = "\e[36mDEBUG \e[0m\e[36m[websocket_websocket_info]\e[0m \e[34m2016-10-13 19:13:51\e[0m:\n\e[35m{\e[0m\n \"random\": \"junk\"\n\e[35m}\e[0m"
111
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
112
- expect(ret).to eq(str)
113
- end
114
-
115
- it 'makes it pretty; http hash data' do
116
- data = { type: 'debug', timestamp: 1_476_386_031,
117
- subject: 'websocket_websocket_info',
118
- data: {
119
- request: { method: 'get' },
120
- response: { status: 200 },
121
- }, }
122
- str = %(\e[36mDEBUG \e[0m\e[36m[websocket_websocket_info]\e[0m \e[34m2016-10-13 19:13:51\e[0m:\n---------\nrequest:\e[35m{\e[0m\n \"method\": \"get\"\n\e[35m}\e[0m\n---------\nresponse:\e[35m{\e[0m\n \"status\": 200\n\e[35m}\e[0m)
123
- ret = MrMurano::Pretties.MakePrettyLogsV1(data, @options)
124
- expect(ret).to eq(str)
125
- end
126
- end
127
-