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,650 +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 'pathname'
9
- require 'tempfile'
10
- require '_workspace'
11
- require 'MrMurano/version'
12
- require 'MrMurano/HttpAuthed'
13
- require 'MrMurano/ProjectFile'
14
- require 'MrMurano/Webservice-Endpoint'
15
- require 'HttpAuthed_spec'
16
-
17
- RSpec.describe MrMurano::Webservice::Endpoint do
18
- include_context 'WORKSPACE'
19
-
20
- before(:example) do
21
- $cfg = MrMurano::Config.new
22
- $cfg.load
23
- $project = MrMurano::ProjectFile.new
24
- $project.load
25
-
26
- @pswd = create_instance_double_passwords
27
- allow(@pswd).to receive(:get).and_return('built')
28
-
29
- $cfg['user.name'] = 'bob'
30
-
31
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
32
- $cfg['application.id'] = 'XYZ'
33
- stub_request_email_password
34
-
35
- @srv = MrMurano::Webservice::Endpoint.new
36
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
37
-
38
- @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/endpoint'
39
- end
40
-
41
- it 'initializes' do
42
- uri = @srv.endpoint('/')
43
- expect(uri.to_s).to eq("#{@base_uri}/")
44
- end
45
-
46
- context 'lists' do
47
- it 'same content_type' do
48
- body = [
49
- {
50
- id: '9K0',
51
- method: 'websocket',
52
- path: '/api/v1/bar',
53
- content_type: 'application/json',
54
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
55
- },
56
- {
57
- id: 'B76',
58
- method: 'websocket',
59
- path: '/api/v1/foo/{id}',
60
- content_type: 'application/json',
61
- script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n",
62
- },
63
- ]
64
- stub_request(:get, @base_uri)
65
- .with(
66
- headers: {
67
- 'Authorization' => 'token TTTTTTTTTT',
68
- 'Content-Type' => 'application/json',
69
- }
70
- ).to_return(body: body.to_json)
71
-
72
- ret = @srv.list
73
- expect(ret).to eq(body)
74
- end
75
-
76
- it 'missing headers' do
77
- body = [
78
- {
79
- id: '9K0',
80
- method: 'websocket',
81
- path: '/api/v1/bar',
82
- content_type: 'application/json',
83
- script: "response.message = \"HI\"\n\n",
84
- },
85
- { id: 'B76',
86
- method: 'websocket',
87
- path: '/api/v1/foo/{id}',
88
- content_type: 'application/json',
89
- script: "response.message = \"HI\"\n\n-- BOB WAS HERE\n", },
90
- ]
91
- stub_request(:get, @base_uri)
92
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
93
- 'Content-Type' => 'application/json', })
94
- .to_return(body: body.to_json)
95
-
96
- ret = @srv.list
97
- expect(ret).to eq(body)
98
- end
99
-
100
- it 'not default content_type' do
101
- body = [
102
- {
103
- id: '9K0',
104
- method: 'websocket',
105
- path: '/api/v1/bar',
106
- content_type: 'text/csv',
107
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n\n",
108
- },
109
- { id: 'B76',
110
- method: 'websocket',
111
- path: '/api/v1/foo/{id}',
112
- content_type: 'image/png',
113
- script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id} image/png\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
114
- ]
115
- stub_request(:get, @base_uri)
116
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
117
- 'Content-Type' => 'application/json', })
118
- .to_return(body: body.to_json)
119
-
120
- ret = @srv.list
121
- expect(ret).to eq(body)
122
- end
123
-
124
- it 'mismatched content_type header' do
125
- body = [
126
- {
127
- id: '9K0',
128
- method: 'websocket',
129
- path: '/api/v1/bar',
130
- content_type: 'text/csv',
131
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
132
- },
133
- { id: 'B76',
134
- method: 'websocket',
135
- path: '/api/v1/foo/{id}',
136
- content_type: 'image/png',
137
- script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
138
- ]
139
- stub_request(:get, @base_uri)
140
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
141
- 'Content-Type' => 'application/json', })
142
- .to_return(body: body.to_json)
143
-
144
- ret = @srv.list
145
- expect(ret).to eq(body)
146
- end
147
-
148
- it 'returns empty content type' do
149
- body = [
150
- {
151
- id: '9K0',
152
- method: 'websocket',
153
- path: '/api/v1/bar',
154
- content_type: '',
155
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
156
- },
157
- { id: 'B76',
158
- method: 'websocket',
159
- path: '/api/v1/foo/{id}',
160
- content_type: 'image/png',
161
- script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
162
- ]
163
- stub_request(:get, @base_uri)
164
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
165
- 'Content-Type' => 'application/json', })
166
- .to_return(body: body.to_json)
167
- ret = @srv.list
168
- body.first[:content_type] = 'application/json'
169
- expect(ret).to eq(body)
170
- end
171
-
172
- it 'returns missing content type' do
173
- body = [
174
- {
175
- id: '9K0',
176
- method: 'websocket',
177
- path: '/api/v1/bar',
178
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
179
- },
180
- { id: 'B76',
181
- method: 'websocket',
182
- path: '/api/v1/foo/{id}',
183
- content_type: 'image/png',
184
- script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
185
- ]
186
- stub_request(:get, @base_uri)
187
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
188
- 'Content-Type' => 'application/json', })
189
- .to_return(body: body.to_json)
190
-
191
- ret = @srv.list
192
- body.first[:content_type] = 'application/json'
193
- expect(ret).to eq(body)
194
- end
195
- end
196
-
197
- context 'fetches' do
198
- it 'fetches' do
199
- body = {
200
- id: '9K0',
201
- method: 'websocket',
202
- path: '/api/v1/bar',
203
- content_type: 'application/json',
204
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
205
- }
206
- stub_request(:get, "#{@base_uri}/9K0")
207
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
208
- 'Content-Type' => 'application/json', })
209
- .to_return(body: body.to_json)
210
-
211
- ret = @srv.fetch('9K0')
212
- expect(ret).to eq(body[:script])
213
- end
214
-
215
- it 'yields' do
216
- body = {
217
- id: '9K0',
218
- method: 'websocket',
219
- path: '/api/v1/bar',
220
- content_type: 'application/json',
221
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
222
- }
223
- stub_request(:get, "#{@base_uri}/9K0")
224
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
225
- 'Content-Type' => 'application/json', })
226
- .to_return(body: body.to_json)
227
-
228
- ret = nil
229
- @srv.fetch('9K0') do |sc|
230
- ret = sc
231
- end
232
- expect(ret).to eq(body[:script])
233
- end
234
-
235
- it 'missing headers' do
236
- body = {
237
- id: '9K0',
238
- method: 'websocket',
239
- path: '/api/v1/bar',
240
- content_type: 'application/json',
241
- script: "response.message = \"HI\"\n",
242
- }
243
- stub_request(:get, "#{@base_uri}/9K0")
244
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
245
- 'Content-Type' => 'application/json', })
246
- .to_return(body: body.to_json)
247
-
248
- ret = @srv.fetch('9K0')
249
- expect(ret).to eq("--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n")
250
- end
251
-
252
- it 'not default content_type' do
253
- body = {
254
- id: '9K0',
255
- method: 'websocket',
256
- path: '/api/v1/bar',
257
- content_type: 'text/csv',
258
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n",
259
- }
260
- stub_request(:get, "#{@base_uri}/9K0")
261
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
262
- 'Content-Type' => 'application/json', })
263
- .to_return(body: body.to_json)
264
-
265
- ret = @srv.fetch('9K0')
266
- expect(ret).to eq(body[:script])
267
- end
268
-
269
- it 'missing content_type header' do
270
- body = {
271
- id: '9K0',
272
- method: 'websocket',
273
- path: '/api/v1/bar',
274
- content_type: 'text/csv',
275
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
276
- }
277
- stub_request(:get, "#{@base_uri}/9K0")
278
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
279
- 'Content-Type' => 'application/json', })
280
- .to_return(body: body.to_json)
281
-
282
- ret = @srv.fetch('9K0')
283
- expect(ret).to eq("--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n")
284
- end
285
-
286
- it 'mismatched content_type header' do
287
- body = {
288
- id: '9K0',
289
- method: 'websocket',
290
- path: '/api/v1/bar',
291
- content_type: 'text/csv',
292
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar image/png\nresponse.message = \"HI\"\n",
293
- }
294
- stub_request(:get, "#{@base_uri}/9K0")
295
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
296
- 'Content-Type' => 'application/json', })
297
- .to_return(body: body.to_json)
298
-
299
- ret = @srv.fetch('9K0')
300
- expect(ret).to eq(
301
- "--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n"
302
- )
303
- end
304
- end
305
-
306
- it 'removes' do
307
- stub_request(:delete, "#{@base_uri}/9K0")
308
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
309
- 'Content-Type' => 'application/json', })
310
- .to_return(body: '')
311
-
312
- ret = @srv.remove('9K0')
313
- expect(ret).to eq({})
314
- end
315
-
316
- context 'uploads' do
317
- around(:example) do |ex|
318
- Tempfile.open('foo') do |tio|
319
- tio << %{-- lua code is here
320
- function foo(bar)
321
- return bar + 1
322
- end
323
- }
324
- tio.close
325
- @tio_ = tio
326
- ex.run
327
- end
328
- end
329
-
330
- it 'over old version' do
331
- stub_request(:put, "#{@base_uri}/9K0")
332
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
333
- 'Content-Type' => 'application/json', })
334
- .to_return(body: '')
335
-
336
- ret = @srv.upload(@tio_.path,
337
- MrMurano::Webservice::Endpoint::RouteItem.new(
338
- id: '9K0',
339
- method: 'websocket',
340
- path: '/api/v1/bar',
341
- content_type: 'application/json',
342
- ), true)
343
- expect(ret)
344
- end
345
-
346
- it 'when nothing is there' do
347
- stub_request(:put, "#{@base_uri}/9K0")
348
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
349
- 'Content-Type' => 'application/json', })
350
- .to_return(status: 404)
351
- stub_request(:post, "#{@base_uri}/")
352
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
353
- 'Content-Type' => 'application/json', })
354
- .to_return(body: '')
355
-
356
- ret = @srv.upload(
357
- @tio_.path,
358
- MrMurano::Webservice::Endpoint::RouteItem.new(
359
- id: '9K0',
360
- method: 'websocket',
361
- path: '/api/v1/bar',
362
- content_type: 'application/json',
363
- ), false
364
- )
365
- expect(ret)
366
- end
367
-
368
- it 'without an itemkey' do
369
- stub_request(:post, @base_uri)
370
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
371
- 'Content-Type' => 'application/json', })
372
- .to_return(body: '')
373
-
374
- ret = @srv.upload(
375
- @tio_.path,
376
- MrMurano::Webservice::Endpoint::RouteItem.new(
377
- method: 'websocket',
378
- path: '/api/v1/bar',
379
- content_type: 'application/json',
380
- ), false
381
- )
382
- expect(ret)
383
- end
384
-
385
- it 'Handles others errors' do
386
- stub_request(:put, "#{@base_uri}/9K0")
387
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
388
- 'Content-Type' => 'application/json', })
389
- .to_return(status: 502, body: '{}')
390
-
391
- expect(@srv).to receive(:error).and_return(nil)
392
- ret = @srv.upload(
393
- @tio_.path,
394
- MrMurano::Webservice::Endpoint::RouteItem.new(
395
- id: '9K0',
396
- method: 'websocket',
397
- path: '/api/v1/bar',
398
- content_type: 'application/json',
399
- ), true
400
- )
401
- expect(ret)
402
- end
403
- end
404
-
405
- context 'compares' do
406
- before(:example) do
407
- @i_a = {
408
- id: '9K0',
409
- method: 'websocket',
410
- path: '/api/v1/bar',
411
- content_type: 'application/json',
412
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
413
- }
414
- @i_b = {
415
- id: '9K0',
416
- method: 'websocket',
417
- path: '/api/v1/bar',
418
- content_type: 'application/json',
419
- script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
420
- }
421
- end
422
- it 'both have script' do
423
- ret = @srv.docmp(@i_a, @i_b)
424
- expect(ret).to eq(false)
425
- end
426
-
427
- it 'i_a is a local file' do
428
- Tempfile.open('foo') do |tio|
429
- tio << @i_a[:script]
430
- tio.close
431
- i_a = @i_a.reject do |k, _v|
432
- k == :script
433
- end.merge(local_path: Pathname.new(tio.path))
434
- ret = @srv.docmp(i_a, @i_b)
435
- expect(ret).to eq(false)
436
-
437
- i_b = @i_b.dup
438
- i_b[:script] = 'BOB'
439
- ret = @srv.docmp(i_a, i_b)
440
- expect(ret).to eq(true)
441
- end
442
- end
443
-
444
- it 'i_b is a local file' do
445
- Tempfile.open('foo') do |tio|
446
- tio << @i_b[:script]
447
- tio.close
448
- i_b = @i_b.reject do |k, _v|
449
- k == :script
450
- end.merge(local_path: Pathname.new(tio.path))
451
- ret = @srv.docmp(@i_a, i_b)
452
- expect(ret).to eq(false)
453
-
454
- i_a = @i_b.dup
455
- i_a[:script] = 'BOB'
456
- ret = @srv.docmp(i_a, i_b)
457
- expect(ret).to eq(true)
458
- end
459
- end
460
- end
461
-
462
- context 'Lookup functions' do
463
- it 'gets local name' do
464
- ret = @srv.tolocalname({ method: 'get', path: 'one/two/three' }, nil)
465
- expect(ret).to eq('one-two-three.get.lua')
466
- end
467
-
468
- it 'gets synckey' do
469
- ret = @srv.synckey(method: 'get', path: 'one/two/three')
470
- expect(ret).to eq('GET_one/two/three')
471
- end
472
-
473
- it 'gets searchfor' do
474
- $cfg['endpoints.searchFor'] = %(a b c/**/d/*.bob)
475
- ret = @srv.searchFor
476
- expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
477
- end
478
-
479
- it 'gets ignoring' do
480
- $cfg['endpoints.ignoring'] = %(a b c/**/d/*.bob)
481
- ret = @srv.ignoring
482
- expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
483
- end
484
- end
485
-
486
- context 'to_remote_items' do
487
- it 'reads one' do
488
- Tempfile.open('foo') do |tio|
489
- tio << %(--#ENDPOINT GET /one/two
490
- return request
491
-
492
- ).gsub(/^ +/, '')
493
- tio.close
494
-
495
- want = [
496
- {
497
- content_type: 'application/json',
498
- header: '--#ENDPOINT GET /one/two',
499
- line_beg: 1,
500
- line_end: 3,
501
- local_path: Pathname.new(tio.path),
502
- method: 'GET',
503
- path: '/one/two',
504
- script: "return request\n\n",
505
- },
506
- ]
507
- ret = @srv.to_remote_items(nil, tio.path)
508
- expect(ret.collect(&:to_h)).to eq(want)
509
- end
510
- end
511
-
512
- it 'reads many' do
513
- Tempfile.open('foo') do |tio|
514
- tio << %(--#ENDPOINT GET /one/two
515
- return request
516
- --#ENDPOINT PUT /one/two
517
- return request
518
-
519
- --#ENDPOINT DELETE /three/two
520
- return request
521
- ).gsub(/^ +/, '')
522
- tio.close
523
-
524
- want = [
525
- {
526
- content_type: 'application/json',
527
- header: '--#ENDPOINT GET /one/two',
528
- line_beg: 1,
529
- line_end: 2,
530
- local_path: Pathname.new(tio.path),
531
- method: 'GET',
532
- path: '/one/two',
533
- script: "return request\n",
534
- },
535
- {
536
- content_type: 'application/json',
537
- header: '--#ENDPOINT PUT /one/two',
538
- line_beg: 3,
539
- line_end: 5,
540
- local_path: Pathname.new(tio.path),
541
- method: 'PUT',
542
- path: '/one/two',
543
- script: "return request\n\n",
544
- },
545
- {
546
- content_type: 'application/json',
547
- header: '--#ENDPOINT DELETE /three/two',
548
- line_beg: 6,
549
- line_end: 7,
550
- local_path: Pathname.new(tio.path),
551
- method: 'DELETE',
552
- path: '/three/two',
553
- script: "return request\n",
554
- },
555
- ]
556
- ret = @srv.to_remote_items(nil, tio.path)
557
- expect(ret.collect(&:to_h)).to eq(want)
558
- end
559
- end
560
-
561
- it 'skips all when no header found' do
562
- Tempfile.open('foo') do |tio|
563
- tio << %(
564
- return request
565
-
566
- ).gsub(/^\s+/, '')
567
- tio.close
568
-
569
- ret = @srv.to_remote_items(nil, tio.path)
570
- expect(ret.collect(&:to_h)).to eq([])
571
- end
572
- end
573
-
574
- it 'skips junk at begining' do
575
- Tempfile.open('foo') do |tio|
576
- tio << %(
577
- return flex
578
- --#ENDPOINT GET /one/two
579
- return request
580
-
581
- ).gsub(/^\s+/, '')
582
- tio.close
583
-
584
- want = [
585
- {
586
- content_type: 'application/json',
587
- header: '--#ENDPOINT GET /one/two',
588
- line_beg: 2,
589
- line_end: 3,
590
- local_path: Pathname.new(tio.path),
591
- method: 'GET',
592
- path: '/one/two',
593
- script: "return request\n",
594
- },
595
- ]
596
- ret = @srv.to_remote_items(nil, tio.path)
597
- expect(ret.collect(&:to_h)).to eq(want)
598
- end
599
- end
600
- end
601
-
602
- context 'Matching' do
603
- before(:example) do
604
- @an_item = {
605
- method: 'get',
606
- path: '/api/read/stuff',
607
- local_path: Pathname.new('a/relative/path.lua'),
608
- }
609
- end
610
- context 'method' do
611
- it 'any path' do
612
- ret = @srv.match(@an_item, '#get#')
613
- expect(ret).to be true
614
- ret = @srv.match(@an_item, '#post#')
615
- expect(ret).to be false
616
- end
617
- it 'exact path' do
618
- ret = @srv.match(@an_item, '#get#/api/read/stuff')
619
- expect(ret).to be true
620
- ret = @srv.match(@an_item, '#post#/api/read/stuff')
621
- expect(ret).to be false
622
- end
623
- it 'path glob' do
624
- ret = @srv.match(@an_item, '#get#/api/*/stuff')
625
- expect(ret).to be true
626
- ret = @srv.match(@an_item, '#get#/**/stuff')
627
- expect(ret).to be true
628
- end
629
- end
630
- context 'any method' do
631
- it 'any path' do
632
- ret = @srv.match(@an_item, '##')
633
- expect(ret).to be true
634
- end
635
- it 'exact path' do
636
- ret = @srv.match(@an_item, '##/api/read/stuff')
637
- expect(ret).to be true
638
- ret = @srv.match(@an_item, '##/api/do/stuff')
639
- expect(ret).to be false
640
- end
641
- it 'path glob' do
642
- ret = @srv.match(@an_item, '##/api/*/stuff')
643
- expect(ret).to be true
644
- ret = @srv.match(@an_item, '##/**/stuff')
645
- expect(ret).to be true
646
- end
647
- end
648
- end
649
- end
650
-