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,128 +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 'open3'
10
- require 'cmd_common'
11
-
12
- # NOTE: This file is a copy of, and subset of, cmd_syncdown_both_spec.rb.
13
-
14
- RSpec.describe 'murano single sync', :cmd, :needs_password do
15
- include_context 'CI_CMD'
16
-
17
- before(:example) do
18
- murano_solutions_expunge_yes
19
-
20
- @applctn_name = @snapshotter.resolve_var(
21
- 'application.name', rname('syncdownTestApp')
22
- )
23
- out, err = murano_command_run(
24
- 'solution create', '--type', 'application', @applctn_name, '--save',
25
- )
26
- expect(err).to eq('')
27
- soln_id = out
28
- expect(soln_id.chomp).to match(/^[a-zA-Z0-9]+$/)
29
- end
30
-
31
- after(:example) do
32
- out, err = murano_command_run(
33
- 'solution delete', '-y', @applctn_name,
34
- )
35
- expect(out).to eq('')
36
- expect(err).to eq('')
37
- end
38
-
39
- context 'without ProjectFile' do
40
- before(:example) do
41
- FileUtils.cp_r(File.join(@testdir, 'spec/fixtures/syncable_content/.'), '.')
42
- FileUtils.move('assets', 'files')
43
- FileUtils.cp_r(File.join(@testdir, 'spec/fixtures/syncable_conflict/.'), '.')
44
- end
45
-
46
- it 'syncdown', :club_30s, :club_20s, :club_10s do
47
- out, err = murano_command_run('syncup')
48
- out_lines = out.lines.map { |line| strip_fancy(line) }
49
- expect(out_lines).to match_array(
50
- [
51
- "Adding item table_util\n",
52
- # WATCH/2018-07-19: user_account present on staging Solution by default,
53
- # and has an example script comment as its script.
54
- # Note also that config_service and config_status exist by default, but
55
- # their scripts are the empty string, and they are undeletable, so they
56
- # will not be synced.
57
- "Clearing item user_account\n",
58
- # WATCH/2018-07-19: timer_timer not added by default on staging, but is on dev.
59
- "Adding item timer_timer\n",
60
- "Adding item POST_/api/fire\n",
61
- "Adding item PUT_/api/fire/{code}\n",
62
- "Adding item DELETE_/api/fire/{code}\n",
63
- "Adding item GET_/api/onfire\n",
64
- "Adding item /icon.png\n",
65
- "Adding item /\n",
66
- "Adding item /js/script.js\n",
67
- ]
68
- )
69
-
70
- expect(err).to eq('')
71
-
72
- FileUtils.rm_r(%w[files modules routes services])
73
- expect(Dir['**/*']).to eq([])
74
-
75
- out, err = murano_command_run('syncdown')
76
- out_lines = out.lines.map { |line| strip_fancy(line) }
77
- # MAYBE/2018-04-13: (lb): I see the order here change sometimes.
78
- # We might want to use expect().to include() instead of match_array().
79
- expect(out_lines).to match_array(
80
- [
81
- "Adding item table_util\n",
82
- "Adding item timer_timer\n",
83
- "Adding item POST_/api/fire\n",
84
- "Adding item DELETE_/api/fire/{code}\n",
85
- "Adding item PUT_/api/fire/{code}\n",
86
- "Adding item GET_/api/onfire\n",
87
- "Adding item /icon.png\n",
88
- "Adding item /\n",
89
- "Adding item /js/script.js\n",
90
- ]
91
- )
92
- expect(err).to eq('')
93
-
94
- after = Dir['**/*'].sort
95
- expect(after).to include(
96
- 'assets',
97
- 'assets/icon.png',
98
- 'assets/index.html',
99
- 'assets/js',
100
- 'assets/js/script.js',
101
- 'modules',
102
- 'modules/table_util.lua',
103
- 'endpoints',
104
- 'endpoints/api-fire-{code}.delete.lua',
105
- 'endpoints/api-fire-{code}.put.lua',
106
- 'endpoints/api-fire.post.lua',
107
- 'endpoints/api-onfire.get.lua',
108
- 'services',
109
- 'services/timer_timer.lua',
110
- )
111
-
112
- # A status should show no differences.
113
- out, err = murano_command_run('status')
114
- expect(err).to eq('')
115
- expect(out.lines).to match(
116
- [
117
- "Nothing new locally\n",
118
- "Nothing new remotely\n",
119
- "Nothing that differs\n",
120
- ]
121
- )
122
- out, err = murano_command_run('status', '--diff', '--no-grouped')
123
- expect(err).to eq('')
124
- expect(out.lines).to match([])
125
- end
126
- end
127
- end
128
-
@@ -1,178 +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 'open3'
10
- require 'cmd_common'
11
-
12
- RSpec.describe 'murano syncdown', :cmd, :needs_password do
13
- include_context 'CI_CMD'
14
-
15
- before(:example) do
16
- murano_solutions_expunge_yes
17
-
18
- @product_name = @snapshotter.resolve_var(
19
- 'product.name', rname('syncdownTestPrd')
20
- )
21
- out, err = murano_command_run(
22
- 'solution create', '--type', 'product', @product_name, '--save',
23
- )
24
- expect(err).to eq('')
25
- expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
26
-
27
- @applctn_name = @snapshotter.resolve_var(
28
- 'application.name', rname('syncdownTestApp')
29
- )
30
- out, err = murano_command_run(
31
- 'solution create', '--type', 'application', @applctn_name, '--save',
32
- )
33
- expect(err).to eq('')
34
- expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
35
-
36
- out, err = murano_command_run('assign set')
37
- #expect(out).to a_string_starting_with("Linked product #{@product_name}")
38
- olines = out.lines
39
- expect(strip_fancy(olines[0])).to eq(
40
- "Linked '#{@product_name}' to '#{@applctn_name}'\n"
41
- )
42
- expect(olines[1]).to eq("Created default event handler\n")
43
- expect(err).to eq('')
44
-
45
- # (lb): The default project directory names for routes and assets were changed,
46
- # from routes and files, to endpoints and assets, respectively, expect we did
47
- # not change the text fixtures, so wire the config and project config accordingly.
48
- $cfg = MrMurano::Config.new
49
- $cfg.load
50
- $cfg['tool.no-progress'] = true
51
- $cfg['eventhandler.searchFor'] = '*.lua */*.lua ../routes/*.lua ../routes/*/*.lua'
52
- $project = MrMurano::ProjectFile.new
53
- $project.load
54
- $project['routes.location'] = 'routes'
55
- $project['assets.location'] = 'files'
56
- end
57
-
58
- after(:example) do
59
- # VERIFY/2017-07-03: Skipping assign unset. Murano will clean up, right?
60
-
61
- out, err = murano_command_run(
62
- 'solution delete', '-y', @applctn_name,
63
- )
64
- expect(out).to eq('')
65
- expect(err).to eq('')
66
-
67
- out, err = murano_command_run(
68
- 'solution delete', '--yes', @product_name,
69
- )
70
- expect(out).to eq('')
71
- expect(err).to eq('')
72
- end
73
-
74
- context 'without ProjectFile' do
75
- before(:example) do
76
- FileUtils.cp_r(File.join(@testdir, 'spec/fixtures/syncable_content/.'), '.')
77
- FileUtils.move('assets', 'files')
78
- # Copy the services/ directory, which includes 2 LUA files.
79
- # 2017-07-03: So long as this command does not syncdown first, the two
80
- # files -- that conflict in name with what's on the platform -- won't be
81
- # a problem (but would be if we synceddown first).
82
- FileUtils.cp_r(File.join(@testdir, 'spec/fixtures/syncable_conflict/.'), '.')
83
- end
84
-
85
- it 'syncdown', :club_20s, :club_10s do
86
- out, err = murano_command_run_gentle('syncup')
87
- out_lines = out.lines.map { |line| strip_fancy(line) }
88
- expect(out_lines).to match_array(
89
- [
90
- "Adding item table_util\n",
91
- #"Clearing item user_account\n",
92
- #"Clearing item y4y6bjfslmio00000_event\n",
93
- a_string_starting_with('Clearing item '),
94
- a_string_starting_with('Clearing item '),
95
- "Adding item timer_timer\n",
96
- #"Adding item device2_event\n",
97
- #"Adding item POST_/api/fire\n",
98
- #"Adding item PUT_/api/fire/{code}\n",
99
- #"Adding item DELETE_/api/fire/{code}\n",
100
- #"Adding item GET_/api/onfire\n",
101
- #"Adding item /icon.png\n",
102
- #"Adding item /\n",
103
- #"Adding item /js/script.js\n",
104
- a_string_starting_with('Adding item '),
105
- a_string_starting_with('Adding item '),
106
- a_string_starting_with('Adding item '),
107
- a_string_starting_with('Adding item '),
108
- a_string_starting_with('Adding item '),
109
- a_string_starting_with('Adding item '),
110
- a_string_starting_with('Adding item '),
111
- a_string_starting_with('Adding item '),
112
- ]
113
- )
114
- expect(strip_fancy(err)).to start_with("Skipping missing location '")
115
-
116
- FileUtils.rm_r(%w[files modules routes services])
117
- expect(Dir['**/*']).to eq([])
118
-
119
- out, err = murano_command_run_gentle('syncdown')
120
- out_lines = out.lines.map { |line| strip_fancy(line) }
121
- expect(out_lines).to match_array(
122
- [
123
- "Updating local product resources\n",
124
- "Adding item table_util\n",
125
- "Adding item timer_timer\n",
126
- "Adding item POST_/api/fire\n",
127
- "Adding item DELETE_/api/fire/{code}\n",
128
- "Adding item PUT_/api/fire/{code}\n",
129
- "Adding item GET_/api/onfire\n",
130
- "Adding item /icon.png\n",
131
- "Adding item /\n",
132
- "Adding item /js/script.js\n",
133
- ]
134
- )
135
- expect(strip_fancy(err)).to start_with("Skipping missing location '")
136
-
137
- after = Dir['**/*'].sort
138
- expect(after).to include(
139
- 'files',
140
- 'files/icon.png',
141
- 'files/index.html',
142
- 'files/js',
143
- 'files/js/script.js',
144
- 'modules',
145
- 'modules/table_util.lua',
146
- 'routes',
147
- 'routes/api-fire-{code}.delete.lua',
148
- 'routes/api-fire-{code}.put.lua',
149
- 'routes/api-fire.post.lua',
150
- 'routes/api-onfire.get.lua',
151
- 'services',
152
- 'services/timer_timer.lua',
153
- 'specs',
154
- 'specs/resources.yaml',
155
- )
156
-
157
- # A status should show no differences.
158
- out, err = murano_command_run_gentle('status')
159
- expect(err).to eq('')
160
- expect(out.lines).to match(
161
- [
162
- "Nothing new locally\n",
163
- "Nothing new remotely\n",
164
- "Nothing that differs\n",
165
- ]
166
- )
167
-
168
- out, err = murano_command_run_gentle('status', '--diff', '--no-grouped')
169
- expect(err).to eq('')
170
- expect(out).to eq('')
171
- end
172
- end
173
-
174
- # TODO: With ProjectFile
175
- # TODO: With Solutionfile 0.2.0
176
- # TODO: With Solutionfile 0.3.0
177
- end
178
-
@@ -1,861 +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
- # FIXME/2018-08-08: (lb): The new webmock_snapshot.rb may
9
- # have made this particular file very deletably trash-worthy.
10
-
11
- # NOTE: (lb): This test mimics the sync integration test,
12
- # cmd_syncdown_both_spec.rb, implemented as a unit test
13
- # (by stubbing all the HTTP calls).
14
- #
15
- # You'll see that this is really a Big Chore.
16
- #
17
- # So what are the tradeoffs?
18
- #
19
- # - The integration test is easier to write and to maintain,
20
- # but it takes longer to run (over 1 minute).
21
- #
22
- # - The unit test, on the other hand, runs almost instantaneously,
23
- # but it's much more work to maintain, and it'll break easily if
24
- # we make changes to any of the API calls (whereas the integration
25
- # test doesn't have to change if the API calls change, because
26
- # the underlying code with just handle it, and the test won't see
27
- # any difference).
28
- #
29
- # Ideally, we'd use unit tests, so that tests run expediently
30
- # (and also to enable offline development and testing). But
31
- # because of the cost, we might just want to stick with the
32
- # using integration tests.
33
- #
34
- # Although, another option might be to avoid stubbing out the
35
- # HTTP calls in a unit test by mocking the methods that make
36
- # those HTTP calls. But that also seems like a chore, especially
37
- # because we'd still have to mock the various items that the
38
- # platform returns (and which can be quite complex).
39
- #
40
- # So really, I don't know what the best option is. Currently,
41
- # it's to have integration tests, and to be super annoyed that
42
- # it takes a half hour for all tests to run; but to not be
43
- # frustrated with maintaining a large collection of HTTP stubs.
44
- #
45
- # There's also the possibility of using HTTP stubs more wisely,
46
- # e.g., we could maybe use regex to simplify them (i.e., perhaps
47
- # we could combine all the individual eventhandler/ stubs in this
48
- # file into a single generic stub to handle all different item types).
49
- #
50
- # Unfortunately, it would take time and effort to figure that out,
51
- # and because tests already run (albeit slowly), the easiest path
52
- # forward is the path we're already on, which is to build integration
53
- # tests, sometimes adding another minute to the total test time,
54
- # and not to mess around with trying to turn everything into pure,
55
- # fast-running unit tests. (<sigh> I wish I had a better answer!)
56
-
57
- require 'fileutils'
58
- require 'highline'
59
- # Set HighLine's $terminal global.
60
- require 'highline/import'
61
- require 'open3'
62
- require 'webmock'
63
-
64
- require 'cmd_common'
65
- require 'HttpAuthed_spec.rb'
66
-
67
- require 'MrMurano/commands/sync'
68
-
69
- # *** Syncup mocks.
70
-
71
- unless defined? stub_request_syncup_get_service_device2
72
- def stub_request_syncup_get_service_device2
73
- stub_request(
74
- :get,
75
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/service/#{$cfg['product.id']}/device2"
76
- ).to_return(
77
- status: 200,
78
- body: {
79
- "fqdn":"#{$cfg['product.id']}.m2.exosite-staging.io","protocol":{"name":"onep","devmode":false,"port":443},"provisioning":{"auth_type":"token","enabled":true,"generate_identity":false,"presenter_identity":true,"ip_whitelisting":{"enabled":false,"allowed":[]}},"identity_format":{"prefix":"","type":"opaque","options":{"casing":"mixed","length":0}},"resources":{}
80
- }.to_json,
81
- headers: {}
82
- )
83
- end
84
- end
85
-
86
- unless defined? stub_request_syncup_get_application_module
87
- def stub_request_syncup_get_application_module
88
- stub_request(
89
- :get,
90
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/module"
91
- ).to_return(
92
- status: 200,
93
- body: {
94
- "items":[],"total":0,"next":"/api/v1/module?query={\"solution_id\":\"#{$cfg['application.id']}\"}&limit=100&offset=100"
95
- }.to_json,
96
- headers: {}
97
- )
98
- end
99
- end
100
-
101
- unless defined? stub_request_syncup_put_solution_module_table_util
102
- def stub_request_syncup_put_solution_module_table_util
103
- stub_request(
104
- :put,
105
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/module/#{$cfg['application.id']}_table_util"
106
- ).with(
107
- body: {
108
- "name":"table_util","solution_id":"#{$cfg['application.id']}","script":"-- luacheck: ignore 122/table (This is all about modifying the table)\n\n---\n-- Dump a table as a string; recursively\n-- \\returns string\nfunction table.dump(o)\n\tif type(o) == 'table' then\n\t\tlocal s = '{ '\n\t\tfor k,v in pairs(o) do\n\t\t\tif type(k) ~= 'number' then k = '\"'..k..'\"' end\n\t\t\ts = s .. '['..k..'] = ' .. table.dump(v) .. ','\n\t\tend\n\t\treturn s .. '} '\n\telse\n\t\treturn tostring(o)\n\tend\nend\n\n---\n-- Does table have item?\nfunction table.contains(table, element)\n\tfor _, value in pairs(table) do\n\t\tif value == element then\n\t\t\treturn true\n\t\tend\n\tend\n\treturn false\nend\n\n\n---\n-- Find a table in a list of tables.\n-- \\returns idx, table found; nil if not found\nfunction table.find(tbl, key, value)\n\tif type(key) == 'nil' then return nil, nil end\n\tfor i,v in ipairs(tbl) do\n\t\tif type(v) == 'table' then\n\t\t\tif v[key] == value then\n\t\t\t\treturn i, v\n\t\t\tend\n\t\tend\n\tend\n\treturn nil, nil\nend\n\n---\n-- Replace a table\nfunction table.replacingAdd(tbl, key, newitem)\n\tlocal idx, _ = table.find(tbl, key, newitem[key])\n\tif idx == nil then\n\t\ttable.insert(tbl, newitem)\n\telse\n\t\ttable.remove(tbl, idx)\n\t\ttable.insert(tbl, idx, newitem)\n\tend\nend\n\n-- vim: set ai sw=2 ts=2 :\n","alias":"#{$cfg['application.id']}_table_util"
109
- }.to_json
110
- ).to_return(
111
- status: 200,
112
- body: {
113
- "id":"7324f4e0-8f69-11e8-8ed7-f51bce8b98d1","source_map":{},"name":"table_util","solution_id":"#{$cfg['application.id']}","script":"-- luacheck: ignore 122/table (This is all about modifying the table)\n\n---\n-- Dump a table as a string; recursively\n-- \\returns string\nfunction table.dump(o)\n\tif type(o) == 'table' then\n\t\tlocal s = '{ '\n\t\tfor k,v in pairs(o) do\n\t\t\tif type(k) ~= 'number' then k = '\"'..k..'\"' end\n\t\t\ts = s .. '['..k..'] = ' .. table.dump(v) .. ','\n\t\tend\n\t\treturn s .. '} '\n\telse\n\t\treturn tostring(o)\n\tend\nend\n\n---\n-- Does table have item?\nfunction table.contains(table, element)\n\tfor _, value in pairs(table) do\n\t\tif value == element then\n\t\t\treturn true\n\t\tend\n\tend\n\treturn false\nend\n\n\n---\n-- Find a table in a list of tables.\n-- \\returns idx, table found; nil if not found\nfunction table.find(tbl, key, value)\n\tif type(key) == 'nil' then return nil, nil end\n\tfor i,v in ipairs(tbl) do\n\t\tif type(v) == 'table' then\n\t\t\tif v[key] == value then\n\t\t\t\treturn i, v\n\t\t\tend\n\t\tend\n\tend\n\treturn nil, nil\nend\n\n---\n-- Replace a table\nfunction table.replacingAdd(tbl, key, newitem)\n\tlocal idx, _ = table.find(tbl, key, newitem[key])\n\tif idx == nil then\n\t\ttable.insert(tbl, newitem)\n\telse\n\t\ttable.remove(tbl, idx)\n\t\ttable.insert(tbl, idx, newitem)\n\tend\nend\n\n-- vim: set ai sw=2 ts=2 :\n","alias":"#{$cfg['application.id']}_table_util","updated_at":"2018-07-24T17:46:10.094Z","created_at":"2018-07-24T17:46:10.094Z"
114
- }.to_json,
115
- headers: {}
116
- )
117
- end
118
- end
119
-
120
- unless defined? stub_request_syncup_get_application_eventhandler_link_event
121
- def stub_request_syncup_get_application_eventhandler_link_event
122
- stub_request(
123
- :get,
124
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_#{$cfg['product.id']}_event"
125
- ).to_return(
126
- status: 200,
127
- body: {
128
- "id":"4abb3140-8f69-11e8-8ed7-f51bce8b98d1","name":"#{$cfg['product.id']}_event","alias":"#{$cfg['application.id']}_#{$cfg['product.id']}_event","service":"#{$cfg['product.id']}","event":"event","solution_id":"#{$cfg['application.id']}","script":"print(event)","source_map":{},"created_at":"2018-07-24T17:45:02.292Z","updated_at":"2018-07-24T17:45:02.292Z"
129
- }.to_json,
130
- headers: {}
131
- )
132
- end
133
- end
134
-
135
- unless defined? stub_request_syncup_get_application_eventhandler_apiId_user_account
136
- def stub_request_syncup_get_application_eventhandler_apiId_user_account
137
- stub_request(
138
- :get,
139
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_user_account"
140
- ).to_return(
141
- {
142
- status: 200,
143
- body: {
144
- "id":"47680ea0-8f69-11e8-8ed7-f51bce8b98d1","name":"user_account","alias":"#{$cfg['application.id']}_user_account","service":"user","event":"account","solution_id":"#{$cfg['application.id']}","script":"-- event\n-- .type 'CREATE' | 'DELETE' | 'UPDATE'\n-- .id User ID\n-- .email User email address\n\nif (event.type == 'CREATE') then\n -- handle user create\nend\n\nif (event.type == 'DELETE') then\n -- handle user delete\nend\n\nif (event.type == 'UPDATE') then\n -- handle user update\nend","source_map":{},"created_at":"2018-07-24T17:44:56.716Z","updated_at":"2018-07-24T17:44:56.716Z"
145
- }.to_json,
146
- headers: {}
147
- },
148
- # FIXME/2018-07-25: (lb): I disabled the syncdown code temporarily, because
149
- # this test broke, but I want to get a release out.
150
- #
151
- # # Second request: After PUT <app_id>_user_account [part of syncdown]
152
- # {
153
- # status: 200,
154
- # body: {
155
- ## #"id":"9fa89af0-86c0-11e8-af9f-b1462469a93d","name":"user_account","alias":"#{$cfg['application.id']}_user_account","service":"user","event":"account","solution_id":"#{$cfg['application.id']}","script":"","source_map":{},"created_at":"2018-07-13T17:17:30.530Z","updated_at":"2018-07-13T17:18:15.129Z"
156
- # "id":"67705400-8f5f-11e8-8ed7-f51bce8b98d1","name":"user_account","alias":"i4leq8zdz3my00000_user_account","service":"user","event":"account","solution_id":"i4leq8zdz3my00000","script":"","source_map":{},"created_at":"2018-07-24T16:34:15.490Z","updated_at":"2018-07-24T16:34:54.905Z"
157
- # }.to_json,
158
- # headers: {}
159
- # }
160
- )
161
- end
162
- end
163
-
164
- unless defined? stub_request_syncup_put_application_eventhandler_user_account
165
- def stub_request_syncup_put_application_eventhandler_user_account
166
- stub_request(
167
- :put,
168
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_user_account"
169
- ).with(
170
- body: {
171
- "alias":"#{$cfg['application.id']}_user_account","event":"account","name":"user_account","script":"","service":"user","solution_id":"#{$cfg['application.id']}"
172
- }.to_json
173
- ).to_return(
174
- status: 204,
175
- )
176
- end
177
- end
178
-
179
- unless defined? stub_request_syncup_get_application_eventhandler_base_user_account
180
- def stub_request_syncup_get_application_eventhandler_base_user_account
181
- stub_request(
182
- :get,
183
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/user_account"
184
- ).to_return(
185
- status: 200,
186
- body: {
187
- "id":"47680ea0-8f69-11e8-8ed7-f51bce8b98d1","name":"user_account","alias":"#{$cfg['application.id']}_user_account","service":"user","event":"account","solution_id":"#{$cfg['application.id']}","script":"","source_map":{},"created_at":"2018-07-24T17:44:56.716Z","updated_at":"2018-07-24T17:46:11.015Z"
188
- }.to_json,
189
- headers: {}
190
- )
191
- end
192
- end
193
-
194
- unless defined? stub_request_syncup_put_application_eventhandler_link_event
195
- def stub_request_syncup_put_application_eventhandler_link_event
196
- stub_request(
197
- :put,
198
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_#{$cfg['product.id']}_event"
199
- ).with(
200
- body: {
201
- "alias":"#{$cfg['application.id']}_#{$cfg['product.id']}_event","event":"event","name":"#{$cfg['product.id']}_event","script":"","service":"#{$cfg['product.id']}","solution_id":"#{$cfg['application.id']}"
202
- }.to_json
203
- ).to_return(
204
- status: 204,
205
- )
206
- end
207
- end
208
-
209
- unless defined? stub_request_syncup_get_application_eventhandler_product_event
210
- def stub_request_syncup_get_application_eventhandler_product_event
211
- stub_request(
212
- :get,
213
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['product.id']}_event"
214
- ).to_return(
215
- status: 200,
216
- body: {
217
- "id":"4abb3140-8f69-11e8-8ed7-f51bce8b98d1","name":"#{$cfg['product.id']}_event","alias":"#{$cfg['application.id']}_#{$cfg['product.id']}_event","service":"#{$cfg['product.id']}","event":"event","solution_id":"#{$cfg['application.id']}","script":"","source_map":{},"created_at":"2018-07-24T17:45:02.292Z","updated_at":"2018-07-24T17:46:11.308Z"
218
- }.to_json,
219
- headers: {}
220
- )
221
- end
222
- end
223
-
224
- unless defined? stub_request_syncup_put_application_eventhandler_timer_timer
225
- def stub_request_syncup_put_application_eventhandler_timer_timer
226
- stub_request(
227
- :put,
228
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_timer_timer"
229
- ).with(
230
- body: {
231
- "event":"timer","script":"--#EVENT timer timer\n-- Nothing here.\n\n-- vim: set ai sw=2 ts=2 :\n","service":"timer","solution_id":"#{$cfg['application.id']}","alias":"#{$cfg['application.id']}_timer_timer","name":"timer_timer"
232
- }.to_json
233
- ).to_return(
234
- #? WAS?: status: 204,
235
- status: 200,
236
- body: {
237
- "id":"73ff7660-8f69-11e8-9add-9b37ad51f7b7","source_map":{},"event":"timer","script":"--#EVENT timer timer\n-- Nothing here.\n\n-- vim: set ai sw=2 ts=2 :\n","service":"timer","solution_id":"#{$cfg['application.id']}","name":"timer_timer","alias":"#{$cfg['application.id']}_timer_timer","updated_at":"2018-07-24T17:46:11.526Z","created_at":"2018-07-24T17:46:11.526Z"
238
- }.to_json,
239
- headers: {}
240
- )
241
- end
242
- end
243
-
244
- unless defined? stub_request_syncup_get_product_eventhandler
245
- def stub_request_syncup_get_product_eventhandler
246
- stub_request(
247
- :get,
248
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['product.id']}/eventhandler"
249
- ).to_return(
250
- status: 200,
251
- body: {
252
- "items":[
253
- {"id":"456fc119-8f69-11e8-9add-9b37ad51f7b7","name":"interface_updateGatewaySettings","alias":"#{$cfg['product.id']}_interface_updateGatewaySettings","solution_id":"#{$cfg['product.id']}","service":"interface","event":"updateGatewaySettings","created_at":"2018-07-24T17:44:53.415Z","updated_at":"2018-07-24T17:44:53.415Z"},
254
- {"id":"456fc117-8f69-11e8-9add-9b37ad51f7b7","name":"interface_setIdentityState","alias":"#{$cfg['product.id']}_interface_setIdentityState","solution_id":"#{$cfg['product.id']}","service":"interface","event":"setIdentityState","created_at":"2018-07-24T17:44:53.415Z","updated_at":"2018-07-24T17:44:53.415Z"},
255
- {"id":"456fc11a-8f69-11e8-9add-9b37ad51f7b7","name":"interface_updateIdentity","alias":"#{$cfg['product.id']}_interface_updateIdentity","solution_id":"#{$cfg['product.id']}","service":"interface","event":"updateIdentity","created_at":"2018-07-24T17:44:53.415Z","updated_at":"2018-07-24T17:44:53.415Z"},
256
- {"id":"456fc11b-8f69-11e8-9add-9b37ad51f7b7","name":"interface_uploadContent","alias":"#{$cfg['product.id']}_interface_uploadContent","solution_id":"#{$cfg['product.id']}","service":"interface","event":"uploadContent","created_at":"2018-07-24T17:44:53.415Z","updated_at":"2018-07-24T17:44:53.415Z"},
257
- {"id":"456fc118-8f69-11e8-9add-9b37ad51f7b7","name":"interface_updateGatewayResource","alias":"#{$cfg['product.id']}_interface_updateGatewayResource","solution_id":"#{$cfg['product.id']}","service":"interface","event":"updateGatewayResource","created_at":"2018-07-24T17:44:53.415Z","updated_at":"2018-07-24T17:44:53.415Z"},
258
- {"id":"456f72f2-8f69-11e8-9add-9b37ad51f7b7","name":"interface_addIdentity","alias":"#{$cfg['product.id']}_interface_addIdentity","solution_id":"#{$cfg['product.id']}","service":"interface","event":"addIdentity","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
259
- {"id":"456f72f0-8f69-11e8-9add-9b37ad51f7b7","name":"device2_event","alias":"#{$cfg['product.id']}_device2_event","solution_id":"#{$cfg['product.id']}","service":"device2","event":"event","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
260
- {"id":"456f9a00-8f69-11e8-9add-9b37ad51f7b7","name":"interface_downloadContent","alias":"#{$cfg['product.id']}_interface_downloadContent","solution_id":"#{$cfg['product.id']}","service":"interface","event":"downloadContent","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
261
- {"id":"456f72f1-8f69-11e8-9add-9b37ad51f7b7","name":"interface_addGatewayResource","alias":"#{$cfg['product.id']}_interface_addGatewayResource","solution_id":"#{$cfg['product.id']}","service":"interface","event":"addGatewayResource","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
262
- {"id":"456fc112-8f69-11e8-9add-9b37ad51f7b7","name":"interface_listContent","alias":"#{$cfg['product.id']}_interface_listContent","solution_id":"#{$cfg['product.id']}","service":"interface","event":"listContent","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
263
- {"id":"456fc115-8f69-11e8-9add-9b37ad51f7b7","name":"interface_removeGatewayResource","alias":"#{$cfg['product.id']}_interface_removeGatewayResource","solution_id":"#{$cfg['product.id']}","service":"interface","event":"removeGatewayResource","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
264
- {"id":"456f72f4-8f69-11e8-9add-9b37ad51f7b7","name":"interface_deleteContent","alias":"#{$cfg['product.id']}_interface_deleteContent","solution_id":"#{$cfg['product.id']}","service":"interface","event":"deleteContent","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
265
- {"id":"456f9a03-8f69-11e8-9add-9b37ad51f7b7","name":"interface_getIdentity","alias":"#{$cfg['product.id']}_interface_getIdentity","solution_id":"#{$cfg['product.id']}","service":"interface","event":"getIdentity","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
266
- {"id":"456fc111-8f69-11e8-9add-9b37ad51f7b7","name":"interface_infoContent","alias":"#{$cfg['product.id']}_interface_infoContent","solution_id":"#{$cfg['product.id']}","service":"interface","event":"infoContent","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
267
- {"id":"456fc116-8f69-11e8-9add-9b37ad51f7b7","name":"interface_removeIdentity","alias":"#{$cfg['product.id']}_interface_removeIdentity","solution_id":"#{$cfg['product.id']}","service":"interface","event":"removeIdentity","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
268
- {"id":"456fc114-8f69-11e8-9add-9b37ad51f7b7","name":"interface_makeIdentity","alias":"#{$cfg['product.id']}_interface_makeIdentity","solution_id":"#{$cfg['product.id']}","service":"interface","event":"makeIdentity","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
269
- {"id":"456f9a02-8f69-11e8-9add-9b37ad51f7b7","name":"interface_getGatewaySettings","alias":"#{$cfg['product.id']}_interface_getGatewaySettings","solution_id":"#{$cfg['product.id']}","service":"interface","event":"getGatewaySettings","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
270
- {"id":"456f72f3-8f69-11e8-9add-9b37ad51f7b7","name":"interface_clearContent","alias":"#{$cfg['product.id']}_interface_clearContent","solution_id":"#{$cfg['product.id']}","service":"interface","event":"clearContent","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
271
- {"id":"456f9a01-8f69-11e8-9add-9b37ad51f7b7","name":"interface_getGatewayResource","alias":"#{$cfg['product.id']}_interface_getGatewayResource","solution_id":"#{$cfg['product.id']}","service":"interface","event":"getGatewayResource","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
272
- {"id":"456fc110-8f69-11e8-9add-9b37ad51f7b7","name":"interface_getIdentityState","alias":"#{$cfg['product.id']}_interface_getIdentityState","solution_id":"#{$cfg['product.id']}","service":"interface","event":"getIdentityState","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"},
273
- {"id":"456fc113-8f69-11e8-9add-9b37ad51f7b7","name":"interface_listIdentities","alias":"#{$cfg['product.id']}_interface_listIdentities","solution_id":"#{$cfg['product.id']}","service":"interface","event":"listIdentities","created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:44:53.414Z"}],"total":21,"next":"/api/v1/eventhandler?query={\"solution_id\":\"#{$cfg['product.id']}\"}&limit=100&offset=100"
274
- }.to_json,
275
- headers: {}
276
- )
277
- end
278
- end
279
-
280
- unless defined? stub_request_syncup_put_product_eventhandler_apiId_device2_event
281
- def stub_request_syncup_put_product_eventhandler_apiId_device2_event
282
- stub_request(
283
- :put,
284
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['product.id']}/eventhandler/#{$cfg['product.id']}_device2_event"
285
- ).with(
286
- body: {
287
- "event":"event","script":"--#EVENT device2 data_in\n-- luacheck: globals data (magic variable from Murano)\n\n-- Get the timestamp for this data if a record action.\n-- Otherwise use default (now)\nlocal stamped = nil\nif data.api == \"record\" then\n stamped = tostring(data.value[1]) .. 's'\nend\n\n-- Save it to timeseries database.\nTsdb.write{\n\ttags = {sn=data.device_sn},\n\tmetrics = {[data.alias] = tonumber(data.value[2])},\n\tts = stamped\n}\n\n-- vim: set et ai sw=2 ts=2 :\n","service":"device2","type":"data_in","solution_id":"#{$cfg['product.id']}","alias":"#{$cfg['product.id']}_device2_event","name":"device2_event"
288
- }.to_json
289
- ).to_return(
290
- status: 204,
291
- )
292
- end
293
- end
294
-
295
- unless defined? stub_request_syncup_get_product_eventhandler_apiId_device2_event
296
- def stub_request_syncup_get_product_eventhandler_apiId_device2_event
297
- stub_request(
298
- :get,
299
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['product.id']}/eventhandler/device2_event"
300
- ).to_return(
301
- status: 200,
302
- body: {
303
- "id":"456f72f0-8f69-11e8-9add-9b37ad51f7b7","name":"device2_event","alias":"#{$cfg['product.id']}_device2_event","service":"device2","event":"event","solution_id":"#{$cfg['product.id']}","script":"--#EVENT device2 data_in\n-- luacheck: globals data (magic variable from Murano)\n\n-- Get the timestamp for this data if a record action.\n-- Otherwise use default (now)\nlocal stamped = nil\nif data.api == \"record\" then\n stamped = tostring(data.value[1]) .. 's'\nend\n\n-- Save it to timeseries database.\nTsdb.write{\n\ttags = {sn=data.device_sn},\n\tmetrics = {[data.alias] = tonumber(data.value[2])},\n\tts = stamped\n}\n\n-- vim: set et ai sw=2 ts=2 :\n","source_map":{},"created_at":"2018-07-24T17:44:53.414Z","updated_at":"2018-07-24T17:46:11.995Z"
304
- }.to_json,
305
- headers: {}
306
- )
307
- end
308
- end
309
-
310
- unless defined? stub_request_syncup_get_application_endpoint
311
- def stub_request_syncup_get_application_endpoint
312
- stub_request(
313
- :get,
314
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/endpoint"
315
- ).to_return(
316
- status: 200,
317
- body: [].to_json,
318
- headers: {}
319
- )
320
- end
321
- end
322
-
323
- unless defined? stub_request_syncup_post_POST_application_endpoint__api_fire
324
- def stub_request_syncup_post_POST_application_endpoint__api_fire
325
- stub_request(
326
- :post,
327
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/endpoint"
328
- ).with(
329
- body: {
330
- "content_type":"application/json","method":"POST","path":"/api/fire","script":"-- luacheck: globals request response (magic variables from Murano)\nresponse.code = 403\n\n"
331
- }.to_json
332
- ).to_return(
333
- status: 200,
334
- body: {
335
- "id":"aM1H7Wr3Np"
336
- }.to_json,
337
- headers: {}
338
- )
339
- end
340
- end
341
-
342
- unless defined? stub_request_syncup_post_PUT_application_endpoint__api_fire_code
343
- def stub_request_syncup_post_PUT_application_endpoint__api_fire_code
344
- stub_request(
345
- :post,
346
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/endpoint"
347
- ).with(
348
- body: {
349
- "content_type":"application/json","method":"PUT","path":"/api/fire/{code}","script":"response.code = 500\n\n"
350
- }.to_json
351
- ).to_return(
352
- status: 200,
353
- body: {
354
- "id":"XSfnyTpMgu"
355
- }.to_json,
356
- headers: {}
357
- )
358
- end
359
- end
360
-
361
- unless defined? stub_request_syncup_post_DELETE_application_endpoint__api_fire_code
362
- def stub_request_syncup_post_DELETE_application_endpoint__api_fire_code
363
- stub_request(
364
- :post,
365
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/endpoint"
366
- ).with(
367
- body: {
368
- "content_type":"application/json","method":"DELETE","path":"/api/fire/{code}","script":"return 'ok'\n\n-- vim: set ai sw=2 ts=2 :\n"
369
- }.to_json
370
- ).to_return(
371
- status: 200,
372
- body: {
373
- "id":"RqpwtvYOVM"
374
- }.to_json,
375
- headers: {}
376
- )
377
- end
378
- end
379
-
380
- unless defined? stub_request_syncup_post_GET_application_endpoint__api_fire
381
- def stub_request_syncup_post_GET_application_endpoint__api_fire
382
- stub_request(
383
- :post,
384
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/endpoint"
385
- ).with(
386
- body: {
387
- "content_type":"application/json","method":"GET","path":"/api/onfire","script":"-- luacheck: globals request response (magic variables from Murano)\n\nreturn 'no'\n-- vim: set ai sw=2 ts=2 :\n"
388
- }.to_json
389
- ).to_return(
390
- status: 200,
391
- body: {
392
- "id":"WWblIzv3DN"
393
- }.to_json,
394
- headers: {}
395
- )
396
- end
397
- end
398
-
399
- unless defined? stub_request_syncup_get_application_file
400
- def stub_request_syncup_get_application_file
401
- stub_request(
402
- :get,
403
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/file"
404
- ).to_return(
405
- status: 200,
406
- body: [].to_json,
407
- headers: {}
408
- )
409
- end
410
- end
411
-
412
- unless defined? stub_request_syncup_put_product_fileupload_icon_png
413
- def stub_request_syncup_put_product_fileupload_icon_png
414
- stub_request(
415
- :put,
416
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/fileupload/icon.png"
417
- ).to_return(
418
- status: 204,
419
- )
420
- end
421
- end
422
-
423
- unless defined? stub_request_syncup_put_product_fileupload_index_html
424
- def stub_request_syncup_put_product_fileupload_index_html
425
- stub_request(
426
- :put,
427
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/fileupload/"
428
- ).to_return(
429
- status: 204,
430
- )
431
- end
432
- end
433
-
434
- unless defined? stub_request_syncup_put_product_fileupload_js_script_js
435
- def stub_request_syncup_put_product_fileupload_js_script_js
436
- stub_request(
437
- :put,
438
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/fileupload/js%2Fscript.js"
439
- ).to_return(
440
- status: 204,
441
- )
442
- end
443
- end
444
-
445
- unless defined? stub_request_syncup_get_application_eventhandler
446
- def stub_request_syncup_get_application_eventhandler
447
- stub_request(
448
- :get,
449
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler"
450
- ).to_return(
451
- status: 200,
452
- # FIXME/2018-07-24 10:11: (lb): What happened to this very long response?
453
- body: "",
454
- headers: {}
455
- )
456
- end
457
- end
458
-
459
- # *** Syncdown mocks.
460
-
461
- # ##########################################################
462
- # # #
463
- # # FIXME/2018-07-25: (lb): Fix the following, eventually. #
464
- # # (What's above is syncup; What's below is syncdown.) #
465
- # # #
466
- # ##########################################################
467
-
468
- unless defined? stub_request_syncup_get_application_eventhandler_base_user_account
469
- def stub_request_syncup_get_application_eventhandler_base_user_account
470
- stub_request(
471
- :get,
472
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_user_account"
473
- ).with(
474
- body: {
475
- "id":"5ff5e1c0-8f52-11e8-8ed7-f51bce8b98d1","name":"user_account","alias":"h1q4sci7fk1xc0000_user_account","service":"user","event":"account","solution_id":"h1q4sci7fk1xc0000","script":"-- event\n-- .type 'CREATE' | 'DELETE' | 'UPDATE'\n-- .id User ID\n-- .email User email address\n\nif (event.type == 'CREATE') then\n -- handle user create\nend\n\nif (event.type == 'DELETE') then\n -- handle user delete\nend\n\nif (event.type == 'UPDATE') then\n -- handle user update\nend","source_map":{},"created_at":"2018-07-24T15:00:59.487Z","updated_at":"2018-07-24T15:00:59.487Z"
476
- }.to_json
477
- ).to_return(
478
- status: 204,
479
- )
480
- end
481
- end
482
-
483
- unless defined? stub_request_syncup_get_application_eventhandler_timer_timer
484
- def stub_request_syncup_get_application_eventhandler_timer_timer
485
- stub_request(
486
- :get,
487
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_timer_timer"
488
- ).to_return(
489
- status: 200,
490
- body: {
491
- "id":"9fa89af3-86c0-11e8-af9f-b1462469a93d","name":"timer_timer","alias":"#{$cfg['application.id']}_timer_timer","service":"timer","event":"timer","solution_id":"#{$cfg['application.id']}","script":"","source_map":{},"created_at":"2018-07-13T17:17:30.530Z","updated_at":"2018-07-13T17:17:30.530Z"
492
- }.to_json,
493
- headers: {}
494
- )
495
- end
496
- end
497
-
498
- unless defined? stub_request_syncup_get_application_eventhandler_tsdb_exportJob
499
- def stub_request_syncup_get_application_eventhandler_tsdb_exportJob
500
- stub_request(
501
- :get,
502
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_tsdb_exportJob"
503
- ).to_return(
504
- status: 200,
505
- body: {
506
- "id":"9fa89af6-86c0-11e8-af9f-b1462469a93d","name":"tsdb_exportJob","alias":"#{$cfg['application.id']}_tsdb_exportJob","service":"tsdb","event":"exportJob","solution_id":"#{$cfg['application.id']}","script":"","source_map":{},"created_at":"2018-07-13T17:17:30.530Z","updated_at":"2018-07-13T17:17:30.530Z"
507
- }.to_json,
508
- headers: {}
509
- )
510
- end
511
- end
512
-
513
- unless defined? stub_request_syncup_put_application_eventhandler_apiId_config_service
514
- def stub_request_syncup_put_application_eventhandler_apiId_config_service
515
- stub_request(
516
- :put,
517
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_config_service"
518
- ).with(
519
- body: {
520
- "alias": "#{$cfg['application.id']}_config_service",
521
- "created_at": "2018-07-13T17:17:30.530Z",
522
- "event": "service",
523
- "id": "9fa89af5-86c0-11e8-af9f-b1462469a93d",
524
- "name": "config_service",
525
- "script": "",
526
- "service": "config",
527
- "solution_id": "#{$cfg['application.id']}",
528
- "synckey": "config_service",
529
- "synctype": "Service",
530
- "updated_at": "2018-07-13T17:17:30.530Z"
531
- }.to_json
532
- ).to_return(
533
- status: 204,
534
- )
535
- end
536
- end
537
-
538
- unless defined? stub_request_syncup_get_application_eventhandler_config_service
539
- def stub_request_syncup_get_application_eventhandler_config_service
540
- stub_request(
541
- :get,
542
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/config_service"
543
-
544
- ).to_return(
545
- status: 200,
546
- body: {
547
- "id":"9fa89af5-86c0-11e8-af9f-b1462469a93d","name":"config_service","alias":"#{$cfg['application.id']}_config_service","service":"config","event":"service","solution_id":"#{$cfg['application.id']}","script":"","source_map":{},"created_at":"2018-07-13T17:17:30.530Z","updated_at":"2018-07-13T17:18:13.558Z"
548
- }.to_json,
549
- headers: {}
550
- )
551
- end
552
- end
553
-
554
- unless defined? stub_request_syncup_put_application_eventhandler_apiId_config_status
555
- def stub_request_syncup_put_application_eventhandler_apiId_config_status
556
- stub_request(
557
- :put,
558
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/#{$cfg['application.id']}_config_status"
559
- ).with(
560
- body: {
561
- "alias": "#{$cfg['application.id']}_config_status",
562
- "created_at": "2018-07-13T17:17:30.530Z",
563
- "event": "status",
564
- "id": "9fa89af4-86c0-11e8-af9f-b1462469a93d",
565
- "name": "config_status",
566
- "script": "",
567
- "service": "config",
568
- "solution_id": "#{$cfg['application.id']}",
569
- "synckey": "config_status",
570
- "synctype": "Service",
571
- "updated_at": "2018-07-13T17:17:30.530Z"
572
- }.to_json
573
- ).to_return(
574
- status: 204,
575
- )
576
- end
577
- end
578
-
579
- unless defined? stub_request_syncup_get_application_eventhandler_config_status
580
- def stub_request_syncup_get_application_eventhandler_config_status
581
- stub_request(
582
- :get,
583
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/config_status"
584
- ).to_return(
585
- status: 200,
586
- body: {
587
- "id":"9fa89af4-86c0-11e8-af9f-b1462469a93d","name":"config_status","alias":"#{$cfg['application.id']}_config_status","service":"config","event":"status","solution_id":"#{$cfg['application.id']}","script":"","source_map":{},"created_at":"2018-07-13T17:17:30.530Z","updated_at":"2018-07-13T17:18:14.218Z"
588
- }.to_json,
589
- headers: {}
590
- )
591
- end
592
- end
593
-
594
- unless defined? stub_request_syncup_get_application_eventhandler_base_timer_timer
595
- def stub_request_syncup_get_application_eventhandler_base_timer_timer
596
- stub_request(
597
- :get,
598
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/eventhandler/timer_timer"
599
- ).to_return(
600
- status: 200,
601
- body: {
602
- "id":"9fa89af3-86c0-11e8-af9f-b1462469a93d","name":"timer_timer","alias":"#{$cfg['application.id']}_timer_timer","service":"timer","event":"timer","solution_id":"#{$cfg['application.id']}","script":"--#EVENT timer timer\n-- Nothing here.\n\n-- vim: set ai sw=2 ts=2 :\n","source_map":{},"created_at":"2018-07-13T17:17:30.530Z","updated_at":"2018-07-13T17:18:17.771Z"
603
- }.to_json,
604
- headers: {}
605
- )
606
- end
607
- end
608
-
609
- unless defined? stub_request_syncup_put_product_eventhandler_apiId_config_service
610
- def stub_request_syncup_put_product_eventhandler_apiId_config_service
611
- stub_request(
612
- :put,
613
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['product.id']}/eventhandler/#{$cfg['product.id']}_config_service"
614
- ).with(
615
- body: {
616
- "alias":"#{$cfg['product.id']}_config_service","created_at":"2018-07-13T17:17:25.570Z","event":"service","id":"9cb376d1-86c0-11e8-bdf5-0747b0df3eb6","name":"config_service","script":"","service":"config","solution_id":"#{$cfg['product.id']}","synckey":"config_service","synctype":"Interface","updated_at":"2018-07-13T17:17:25.570Z"
617
- }.to_json
618
- ).to_return(
619
- status: 204,
620
- )
621
- end
622
- end
623
-
624
- unless defined? stub_request_syncup_put_product_eventhandler_apiId_config_status
625
- def stub_request_syncup_put_product_eventhandler_apiId_config_status
626
- stub_request(
627
- :put,
628
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['product.id']}/eventhandler/#{$cfg['product.id']}_config_status"
629
- ).with(
630
- body: {
631
- "alias":"#{$cfg['product.id']}_config_status","created_at":"2018-07-13T17:17:25.570Z","event":"status","id":"9cb376d0-86c0-11e8-bdf5-0747b0df3eb6","name":"config_status","script":"","service":"config","solution_id":"#{$cfg['product.id']}","synckey":"config_status","synctype":"Interface","updated_at":"2018-07-13T17:17:25.570Z"
632
- }.to_json
633
- ).to_return(
634
- status: 204,
635
- )
636
- end
637
- end
638
-
639
- unless defined? stub_request_syncup_get_product_eventhandler_config_service
640
- def stub_request_syncup_get_product_eventhandler_config_service
641
- stub_request(
642
- :get,
643
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['product.id']}/eventhandler/config_service"
644
- ).to_return(
645
- status: 200,
646
- body: {
647
- "id":"9cb376d1-86c0-11e8-bdf5-0747b0df3eb6","name":"config_service","alias":"#{$cfg['product.id']}_config_service","service":"config","event":"service","solution_id":"#{$cfg['product.id']}","script":"","source_map":{},"created_at":"2018-07-13T17:17:25.570Z","updated_at":"2018-07-13T17:18:19.109Z"
648
- }.to_json,
649
- headers: {}
650
- )
651
- end
652
- end
653
-
654
- unless defined? stub_request_syncup_get_product_eventhandler_config_status
655
- def stub_request_syncup_get_product_eventhandler_config_status
656
- stub_request(
657
- :get,
658
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['product.id']}/eventhandler/config_status"
659
- ).to_return(
660
- status: 200,
661
- body: {
662
- "id":"9cb376d0-86c0-11e8-bdf5-0747b0df3eb6","name":"config_status","alias":"#{$cfg['product.id']}_config_status","service":"config","event":"status","solution_id":"#{$cfg['product.id']}","script":"","source_map":{},"created_at":"2018-07-13T17:17:25.570Z","updated_at":"2018-07-13T17:18:19.705Z"
663
- }.to_json,
664
- headers: {}
665
- )
666
- end
667
- end
668
-
669
- unless defined? stub_request_syncup_post_PUT_application_endpoint__api_fire
670
- def stub_request_syncup_post_PUT_application_endpoint__api_fire
671
- stub_request(
672
- :post,
673
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/endpoint"
674
- ).with(
675
- body: {
676
- "content_type":"application/json","method":"POST","path":"/api/fire","script":"-- luacheck: globals request response (magic variables from Murano)\nresponse.code = 403\n\n"
677
- }.to_json
678
- ).to_return(
679
- status: 200,
680
- body: {
681
- "id":"iWy4ayrPFT"
682
- }.to_json,
683
- headers: {}
684
- )
685
- end
686
- end
687
-
688
- unless defined? stub_request_syncup_put_product_fileupload_root
689
- def stub_request_syncup_put_product_fileupload_root
690
- stub_request(
691
- :put,
692
- "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/#{$cfg['application.id']}/fileupload/"
693
- ).to_return(
694
- status: 204,
695
- )
696
- end
697
- end
698
-
699
- # *** WebMock Setup
700
-
701
- unless defined? stub_request_content_conflict_syncup
702
- def stub_request_content_conflict_syncup
703
- WebMock.disable_net_connect!
704
-
705
- stub_request_syncup_get_service_device2
706
- stub_request_syncup_get_application_module
707
- stub_request_syncup_put_solution_module_table_util
708
- stub_request_syncup_get_application_eventhandler_link_event
709
- stub_request_syncup_get_application_eventhandler_apiId_user_account
710
- stub_request_syncup_put_application_eventhandler_user_account
711
- stub_request_syncup_get_application_eventhandler_base_user_account
712
- stub_request_syncup_put_application_eventhandler_link_event
713
- stub_request_syncup_get_application_eventhandler_product_event
714
- stub_request_syncup_put_application_eventhandler_timer_timer
715
- stub_request_syncup_get_product_eventhandler
716
- stub_request_syncup_put_product_eventhandler_apiId_device2_event
717
- stub_request_syncup_get_product_eventhandler_apiId_device2_event
718
- stub_request_syncup_get_application_endpoint
719
- stub_request_syncup_post_POST_application_endpoint__api_fire
720
- stub_request_syncup_post_PUT_application_endpoint__api_fire_code
721
- stub_request_syncup_post_DELETE_application_endpoint__api_fire_code
722
- stub_request_syncup_post_GET_application_endpoint__api_fire
723
- stub_request_syncup_get_application_file
724
- stub_request_syncup_put_product_fileupload_icon_png
725
- stub_request_syncup_put_product_fileupload_index_html
726
- stub_request_syncup_put_product_fileupload_js_script_js
727
-
728
- stub_request_syncup_get_application_eventhandler
729
-
730
- # FIXME/2018-07-25: (lb): In the interest of time, I disabled the
731
- # syncdown part of this test, so currently this tests just runs
732
- # syncup. (See cmd_syncdown_both_spec.rb, which runs the sequence:
733
- # syncup; remove local files; syncdown; status & diff.
734
- if false
735
- stub_request_syncup_get_application_eventhandler_timer_timer
736
- stub_request_syncup_get_application_eventhandler_tsdb_exportJob
737
- stub_request_syncup_put_application_eventhandler_apiId_config_service
738
- stub_request_syncup_get_application_eventhandler_config_service
739
- stub_request_syncup_put_application_eventhandler_apiId_config_status
740
- stub_request_syncup_get_application_eventhandler_config_status
741
- stub_request_syncup_get_application_eventhandler_base_timer_timer
742
- stub_request_syncup_put_product_eventhandler_apiId_config_service
743
- stub_request_syncup_put_product_eventhandler_apiId_config_status
744
-
745
- stub_request_syncup_get_product_eventhandler_config_service
746
- stub_request_syncup_get_product_eventhandler_config_status
747
-
748
- stub_request_syncup_post_PUT_application_endpoint__api_fire
749
-
750
- stub_request_syncup_put_product_fileupload_root
751
- end
752
- end
753
- end
754
-
755
- RSpec.describe 'murano syncdown stubbed', :cmd, :needs_password do
756
- include_context 'CI_CMD'
757
-
758
- before(:example) do
759
- $cfg = MrMurano::Config.new
760
- $cfg.load
761
-
762
- $cfg['user.name'] = 'BoB@place.net'
763
- # Skipping: net.protocol, net.host
764
- $cfg['business.id'] = 'BBBBBBBB'
765
- $cfg['product.id'] = 'PPPPPPPP'
766
- $cfg['application.id'] = 'AAAAAAAA'
767
-
768
- # So that progress gets reported as succinct strings on stdout.
769
- $cfg['tool.no-progress'] = true
770
-
771
- # (lb): The default project directory names for routes and assets were changed,
772
- # from routes and files, to endpoints and assets, respectively, expect we did
773
- # not change the text fixtures, so wire the config and project config accordingly.
774
- $cfg['eventhandler.searchFor'] = "*.lua */*.lua ../routes/*.lua ../routes/*/*.lua"
775
- $project = MrMurano::ProjectFile.new
776
- $project.load
777
- $project['routes.location'] = 'routes'
778
- $project['assets.location'] = 'files'
779
-
780
- # Stub the multitude of API calls that get made.
781
- WebMock.reset!
782
- stub_request_email_password
783
- stub_request_content_conflict_syncup
784
- end
785
-
786
- after(:example) do
787
- WebMock.reset!
788
- end
789
-
790
- context 'without ProjectFile' do
791
- before(:example) do
792
- FileUtils.cp_r(File.join(@testdir, 'spec/fixtures/syncable_content/.'), '.')
793
- FileUtils.move('assets', 'files')
794
- FileUtils.cp_r(File.join(@testdir, 'spec/fixtures/syncable_conflict/.'), '.')
795
- end
796
-
797
- def stdio_capture
798
- tmpout = StringIO.new
799
- tmperr = StringIO.new
800
-
801
- # Commander's `say` calls HighLine's $terminal.say, so redirect that, too.
802
- hline = HighLine.new($stdin, tmpout)
803
- $terminal = hline
804
-
805
- @murcli_wasout = $stdout
806
- @murcli_waserr = $stderr
807
- $stdout = tmpout
808
- $stderr = tmperr
809
- end
810
-
811
- def stdio_release
812
- out = $stdout.string
813
- err = $stderr.string
814
-
815
- $stdout = @murcli_wasout
816
- $stderr = @murcli_waserr
817
-
818
- return out, err
819
- end
820
-
821
- it 'syncdown', :club_20s, :club_10s do
822
- stdio_capture
823
-
824
- # (lb): Here's what cmd_syncdown_both_spec calls:
825
- # out, err, status = Open3.capture3(capcmd('murano', 'syncup'))
826
- # Here, we skip the wrapper, and just call syncup_files directly.
827
- options = { delete: true, create: true, update: true }
828
-
829
- syncup_files(options, [])
830
-
831
- out, err = stdio_release
832
-
833
- out_lines = out.lines.map { |line| strip_fancy(line) }
834
- expect(out_lines).to match_array(
835
- [
836
- "Adding item table_util\n",
837
- "Adding item timer_timer\n",
838
- "Adding item device2_event\n",
839
- "Adding item POST_/api/fire\n",
840
- "Adding item PUT_/api/fire/{code}\n",
841
- "Adding item DELETE_/api/fire/{code}\n",
842
- "Adding item GET_/api/onfire\n",
843
- "Adding item /icon.png\n",
844
- "Adding item /\n",
845
- "Adding item /js/script.js\n",
846
- ]
847
- )
848
-
849
- expect(strip_fancy(err)).to start_with("\e[33mSkipping missing location '")
850
-
851
- # (lb): The integration test on which this unit test is based [originally
852
- # copied from], cmd_syncdown_both_spec.rb, does additional work, like
853
- # removing all local files and running syncdown again, but I'm stopping
854
- # here. Maintaining this file -- stubbing all the HTTP requests -- is
855
- # really a pain, and does not seem like a worthwhile endeavour. (Unless
856
- # we come up with a shortcut, such as making more generic stubs to replace
857
- # all the specific stubs, e.g., using regex in the stub_request calls.)
858
- end
859
- end
860
- end
861
-