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,403 +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 'webmock'
10
-
11
- require 'MrMurano/version'
12
- require 'MrMurano/HttpAuthed'
13
- require 'MrMurano/Gateway'
14
- require 'MrMurano/SyncRoot'
15
- require '_workspace'
16
- require 'HttpAuthed_spec'
17
-
18
- RSpec.describe MrMurano::Gateway::Device do
19
- include_context 'WORKSPACE'
20
-
21
- before(:example) do
22
- $cfg = MrMurano::Config.new
23
- $cfg.load
24
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
25
- $cfg['product.id'] = 'XYZ'
26
- stub_request_email_password
27
-
28
- @gw = MrMurano::Gateway::Device.new
29
- allow(@gw).to receive(:token).and_return('TTTTTTTTTT')
30
- end
31
-
32
- it 'initializes' do
33
- uri = @gw.endpoint('/')
34
- expect(uri.to_s).to eq(
35
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/'
36
- )
37
- WebMock.reset!
38
- end
39
-
40
- context 'listing' do
41
- it 'lists' do
42
- body = {
43
- mayLoadMore: false,
44
- devices:
45
- [{ identity: '58',
46
- auth: { type: 'cik' },
47
- state: {},
48
- locked: false,
49
- reprovision: false,
50
- devmode: false,
51
- lastip: '',
52
- lastseen: 1_487_021_743_864_000,
53
- status: 'provisioned',
54
- online: false, },
55
- { identity: '56',
56
- auth: { type: 'cik' },
57
- state: {},
58
- locked: false,
59
- reprovision: false,
60
- devmode: false,
61
- lastip: '',
62
- lastseen: 1_487_021_650_584_000,
63
- status: 'provisioned',
64
- online: false, },],
65
- }
66
- stub_request(
67
- :get,
68
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/'
69
- ).to_return(body: body.to_json)
70
-
71
- ret = @gw.list
72
- expect(ret).to eq(body)
73
-
74
- WebMock.reset!
75
- end
76
-
77
- it 'lists with limit' do
78
- body = {
79
- mayLoadMore: false,
80
- devices:
81
- [{ identity: '58',
82
- auth: { type: 'cik' },
83
- state: {},
84
- locked: false,
85
- reprovision: false,
86
- devmode: false,
87
- lastip: '',
88
- lastseen: 1_487_021_743_864_000,
89
- status: 'provisioned',
90
- online: false, },],
91
- }
92
- stub_request(
93
- :get,
94
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/'
95
- ).with(query: { limit: '1' }).to_return(body: body.to_json)
96
-
97
- ret = @gw.list(1)
98
- expect(ret).to eq(body)
99
-
100
- WebMock.reset!
101
- end
102
-
103
- it 'lists with before' do
104
- body = {
105
- mayLoadMore: false,
106
- devices:
107
- [{ identity: '58',
108
- auth: { type: 'cik' },
109
- state: {},
110
- locked: false,
111
- reprovision: false,
112
- devmode: false,
113
- lastip: '',
114
- lastseen: 1_487_021_743_864_000,
115
- status: 'provisioned',
116
- online: false, },],
117
- }
118
- stub_request(
119
- :get,
120
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/'
121
- ).with(query: { limit: '1', before: '1487021743864000' }).to_return(body: body.to_json)
122
-
123
- ret = @gw.list(1, 1_487_021_743_864_000)
124
- expect(ret).to eq(body)
125
- end
126
- end
127
-
128
- it 'fetches one' do
129
- body = {
130
- identity: '58',
131
- auth: { type: 'cik' },
132
- state: {},
133
- locked: false,
134
- reprovision: false,
135
- devmode: false,
136
- lastip: '',
137
- lastseen: 1_487_021_743_864_000,
138
- status: 'provisioned',
139
- online: false,
140
- }
141
- stub_request(
142
- :get,
143
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
144
- ).to_return(body: body.to_json)
145
-
146
- ret = @gw.fetch(58)
147
- expect(ret).to eq(body)
148
-
149
- WebMock.reset!
150
- end
151
-
152
- it 'enables one' do
153
- body = {
154
- identity: '58',
155
- auth: { type: 'cik' },
156
- state: {},
157
- locked: false,
158
- reprovision: false,
159
- devmode: false,
160
- lastip: '',
161
- lastseen: 1_487_021_743_864_000,
162
- status: 'provisioned',
163
- online: false,
164
- }
165
- stub_request(
166
- :put,
167
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
168
- ).to_return(body: body.to_json)
169
-
170
- ret = @gw.enable(58)
171
- expect(ret).to eq(body)
172
-
173
- WebMock.reset!
174
- end
175
-
176
- it 'enables with options' do
177
- body = {
178
- identity: '58',
179
- auth: { type: 'cik' },
180
- state: {},
181
- locked: false,
182
- reprovision: false,
183
- devmode: false,
184
- lastip: '',
185
- lastseen: 1_487_021_743_864_000,
186
- status: 'provisioned',
187
- online: false,
188
- }
189
- stub_request(
190
- :put,
191
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
192
- ). with(body: { auth: { expire: 123_456, type: :certificate }, locked: false }.to_json).to_return(body: body.to_json)
193
-
194
- ret = @gw.enable(58, type: :certificate, expire: '123456')
195
- expect(ret).to eq(body)
196
-
197
- WebMock.reset!
198
- end
199
-
200
- it 'enables with extra options' do
201
- body = {
202
- identity: '58',
203
- auth: { type: 'cik' },
204
- state: {},
205
- locked: false,
206
- reprovision: false,
207
- devmode: false,
208
- lastip: '',
209
- lastseen: 1_487_021_743_864_000,
210
- status: 'provisioned',
211
- online: false,
212
- }
213
- stub_request(
214
- :put,
215
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
216
- ).with(body: { auth: { expire: 123_456, type: :certificate }, locked: false }.to_json).to_return(body: body.to_json)
217
-
218
- ret = @gw.enable(58, go: :blueteam, type: :certificate, expire: 123_456, bob: :built)
219
- expect(ret).to eq(body)
220
-
221
- WebMock.reset!
222
- end
223
-
224
- it 'removes one' do
225
- body = {
226
- identity: '58',
227
- auth: { type: 'cik' },
228
- state: {},
229
- locked: false,
230
- reprovision: false,
231
- devmode: false,
232
- lastip: '',
233
- lastseen: 1_487_021_743_864_000,
234
- status: 'provisioned',
235
- online: false,
236
- }
237
- stub_request(
238
- :delete,
239
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
240
- ).to_return(body: body.to_json)
241
-
242
- ret = @gw.remove(58)
243
- expect(ret).to eq(body)
244
-
245
- WebMock.reset!
246
- end
247
-
248
- context 'activates' do
249
- before(:example) do
250
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
251
- @bgw = MrMurano::Gateway::GweBase.new
252
- expect(MrMurano::Gateway::GweBase).to receive(:new).and_return(@bgw)
253
- stub_request(
254
- :get,
255
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2'
256
- ).to_return(body: { fqdn: 'xxxxx.m2.exosite-staging.io' }.to_json)
257
- end
258
-
259
- after(:example) do
260
- WebMock.reset!
261
- end
262
-
263
- it 'succeeds' do
264
- stub_request(
265
- :post,
266
- 'https://xxxxx.m2.exosite-staging.io/provision/activate'
267
- ).to_return(body: 'XXXXXXXX')
268
-
269
- ret = @gw.activate(58)
270
- expect(ret).to eq('XXXXXXXX')
271
- end
272
-
273
- it 'was already activated' do
274
- stub_request(
275
- :post,
276
- 'https://xxxxx.m2.exosite-staging.io/provision/activate'
277
- ).to_return(status: 409)
278
-
279
- saved = $stderr
280
- $stderr = StringIO.new
281
-
282
- expect do
283
- @gw.activate(58)
284
- end.to raise_error(SystemExit).and output(
285
- "\e[31mThe specified device is already activated.\e[0m\n"
286
- ).to_stderr
287
- $stderr = saved
288
- end
289
-
290
- it "wasn't enabled" do
291
- stub_request(
292
- :post,
293
- 'https://xxxxx.m2.exosite-staging.io/provision/activate'
294
- ).to_return(status: 404)
295
-
296
- saved = $stderr
297
- $stderr = StringIO.new
298
-
299
- @gw.activate(58)
300
- expect($stderr.string).to eq("\e[31mRequest Failed: 404: nil\e[0m\n")
301
- $stderr = saved
302
- end
303
- end
304
-
305
- context 'enables batch' do
306
- it 'enables from cvs' do
307
- File.open('ids.csv', 'w') { |io| io << "ID\n1\n2\n3\n4\n5" }
308
- stub_request(
309
- :post,
310
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identities'
311
- ).with(headers: { 'Content-Type' => %r{^multipart/form-data.*} }) do |request|
312
- request.body.to_s =~ %r{Content-Type: text/csv\r\n\r\nID\r?\n1\r?\n2\r?\n3\r?\n4\r?\n5}
313
- end
314
- @gw.enable_batch('ids.csv')
315
- WebMock.reset!
316
- end
317
-
318
- it 'but file is missing' do
319
- expect { @gw.enable_batch('ids.csv') }.to raise_error(Errno::ENOENT)
320
- end
321
-
322
- it 'but file is not text' do
323
- File.open('ids.csv', 'wb') { |io| io << "\0\0\0\0" }
324
- stub_request(
325
- :post,
326
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identities'
327
- ).to_return(status: 400, body: 'CSV file format invalid')
328
- saved = $stderr
329
- $stderr = StringIO.new
330
- @gw.enable_batch('ids.csv')
331
- expect($stderr.string).to eq(
332
- %(\e[31mRequest Failed: 400: CSV file format invalid\e[0m\n)
333
- )
334
- $stderr = saved
335
- WebMock.reset!
336
- end
337
-
338
- it 'but file is missing header' do
339
- File.open('ids.csv', 'w') { |io| io << "1\n2\n3\n4\n5" }
340
- stub_request(
341
- :post,
342
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identities'
343
- ).with(headers: { 'Content-Type' => %r{^multipart/form-data.*} }) do |request|
344
- request.body.to_s =~ %r{Content-Type: text/csv\r\n\r\n1\r?\n2\r?\n3\r?\n4\r?\n5}
345
- end.to_return(status: 400, body: 'CSV file format invalid')
346
- saved = $stderr
347
- $stderr = StringIO.new
348
- @gw.enable_batch('ids.csv')
349
- expect($stderr.string).to eq(
350
- %(\e[31mRequest Failed: 400: CSV file format invalid\e[0m\n)
351
- )
352
- $stderr = saved
353
- WebMock.reset!
354
- end
355
- end
356
-
357
- it 'reads state' do
358
- body = { bob: { reported: '9', set: '9', timestamp: 1_487_021_046_160_363 } }
359
- stub_request(
360
- :get,
361
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/56/state'
362
- ).to_return(body: body.to_json)
363
-
364
- ret = @gw.read(56)
365
- expect(ret).to eq(body)
366
-
367
- WebMock.reset!
368
- end
369
-
370
- context 'writes state' do
371
- it 'succeeds' do
372
- body = { bob: 'fuzz' }
373
- stub_request(
374
- :patch,
375
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/56/state'
376
- ).with(body: body.to_json)
377
-
378
- @gw.write(56, bob: 'fuzz')
379
-
380
- WebMock.reset!
381
- end
382
-
383
- it 'fails' do
384
- body = { bob: 'fuzz' }
385
- stub_request(
386
- :patch,
387
- 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/56/state'
388
- ).with(body: body.to_json).to_return(status: 400, body: 'Value is not settable')
389
-
390
- saved = $stderr
391
- $stderr = StringIO.new
392
-
393
- @gw.write(56, bob: 'fuzz')
394
- expect($stderr.string).to eq(
395
- "\e[31mRequest Failed: 400: Value is not settable\e[0m\n"
396
- )
397
- $stderr = saved
398
-
399
- WebMock.reset!
400
- end
401
- end
402
- end
403
-
@@ -1,283 +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 'pathname'
10
- require 'MrMurano/version'
11
- require 'MrMurano/Gateway'
12
- require 'MrMurano/HttpAuthed'
13
- require 'MrMurano/ProjectFile'
14
- require 'MrMurano/SyncRoot'
15
- require '_workspace'
16
- require 'HttpAuthed_spec'
17
-
18
- RSpec.describe MrMurano::Gateway::Resources do
19
- include_context 'WORKSPACE'
20
-
21
- before(:example) do
22
- $cfg = MrMurano::Config.new
23
- $cfg.load
24
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
25
- $cfg['product.id'] = 'XYZ'
26
- $project = MrMurano::ProjectFile.new
27
- $project.load
28
- stub_request_email_password
29
-
30
- @gw = MrMurano::Gateway::Resources.new
31
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
32
- end
33
-
34
- it 'initializes' do
35
- uri = @gw.endpoint('/')
36
- expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/')
37
- end
38
-
39
- it 'lists' do
40
- resources = [
41
- { format: 'string', unit: 'c', settable: true, alias: 'bob' },
42
- { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
43
- { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
44
- ]
45
- body = { resources: {
46
- bob: { format: 'string', unit: 'c', settable: true },
47
- fuzz: { format: 'string', unit: 'c', settable: true },
48
- gruble: { format: 'string', unit: 'bits', settable: true },
49
- }, }
50
- stub_request(:get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
51
- .to_return(body: body.to_json)
52
-
53
- ret = @gw.list
54
- expect(ret).to eq(resources)
55
- end
56
-
57
- it 'uploads all' do
58
- res_before = [
59
- { format: 'string', unit: 'c', settable: true, alias: 'bob' },
60
- { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
61
- { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
62
- ]
63
- res_after = {
64
- bob: { format: 'string', unit: 'c', settable: true },
65
- fuzz: { format: 'string', unit: 'c', settable: true },
66
- gruble: { format: 'string', unit: 'bits', settable: true },
67
- }
68
- stub_request(:patch, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2')
69
- .with(body: { resources: res_after }.to_json)
70
-
71
- ret = @gw.upload_all(res_before)
72
- expect(ret).to eq({})
73
- end
74
-
75
- context 'compares' do
76
- before(:example) do
77
- @i_a = { format: 'string', unit: 'c', settable: true, alias: 'bob' }
78
- @i_b = { format: 'string', unit: 'c', settable: true, alias: 'bob' }
79
- end
80
- it 'Are equal' do
81
- ret = @gw.docmp(@i_a, @i_b)
82
- expect(ret).to eq(false)
83
- end
84
- end
85
-
86
- context 'Lookup functions' do
87
- it 'local path is into' do
88
- ret = @gw.tolocalpath('bob', 'rich')
89
- expect(ret).to eq('bob')
90
- end
91
-
92
- it 'gets synckey' do
93
- ret = @gw.synckey(alias: 'bob')
94
- expect(ret).to eq('bob')
95
- end
96
- end
97
-
98
- context 'local items' do
99
- it 'succeeds' do
100
- resfile = Pathname.new('resources.yaml')
101
- src = File.join(@testdir, 'spec', 'fixtures', 'gateway_resource_files', 'resources.yaml')
102
- FileUtils.copy(src, resfile.to_path)
103
- ret = @gw.localitems(resfile)
104
- expect(ret).to eq(
105
- [
106
- { format: 'string', unit: 'c', settable: true, alias: 'bob' },
107
- { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
108
- { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
109
- ]
110
- )
111
- end
112
-
113
- it 'missing file' do
114
- resfile = Pathname.new('resources.yaml')
115
- saved = $stderr
116
- $stderr = StringIO.new
117
- ret = @gw.localitems(resfile)
118
- expect(ret).to eq([])
119
- expect($stderr.string).to eq("\e[33mSkipping missing resources.yaml\e[0m\n")
120
- $stderr = saved
121
- end
122
-
123
- it "isn't a file" do
124
- resfile = Pathname.new('resources.yaml')
125
- FileUtils.mkpath('resources.yaml')
126
- saved = $stderr
127
- $stderr = StringIO.new
128
- ret = @gw.localitems(resfile)
129
- expect(ret).to eq([])
130
- expect($stderr.string).to eq("\e[33mCannot read from resources.yaml\e[0m\n")
131
- $stderr = saved
132
- end
133
-
134
- it "isn't yaml" do
135
- resfile = Pathname.new('resources.yaml')
136
- src = File.join(@testdir, 'spec', 'fixtures', 'gateway_resource_files', 'resources.notyaml')
137
- FileUtils.copy(src, resfile.to_path)
138
- #expect{ @gw.localitems(resfile) }.to raise_error(JSON::Schema::ValidationError)
139
- expect do
140
- @gw.localitems(resfile)
141
- end.to raise_error(SystemExit).and output("\e[31mThere is an error in the config file, resources.yaml\e[0m\n\e[31m\"The property '#/' of type Array did not match the following type: object\"\e[0m\n").to_stderr
142
- end
143
-
144
- it "isn't valid" do
145
- resfile = Pathname.new('resources.yaml')
146
- src = File.join(@testdir, 'spec', 'fixtures', 'gateway_resource_files', 'resources.notyaml')
147
- FileUtils.copy(src, resfile.to_path)
148
- #expect{ @gw.localitems(resfile) }.to raise_error(JSON::Schema::ValidationError)
149
- expect do
150
- @gw.localitems(resfile)
151
- end.to raise_error(SystemExit).and output("\e[31mThere is an error in the config file, resources.yaml\e[0m\n\e[31m\"The property '#/' of type Array did not match the following type: object\"\e[0m\n").to_stderr
152
- end
153
- end
154
-
155
- context 'syncup' do
156
- before(:example) do
157
- expect(@gw).to receive(:list).once.and_return(
158
- [
159
- { format: 'string', unit: 'c', settable: true, alias: 'bob' },
160
- { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
161
- { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
162
- ]
163
- )
164
- end
165
- it 'removes keys' do
166
- expect(@gw).to receive(:upload_all).with(
167
- [
168
- { format: 'string', unit: 'c', settable: true, alias: 'bob' },
169
- { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
170
- ]
171
- )
172
- @gw.syncup_before
173
- @gw.remove('fuzz')
174
- @gw.syncup_after
175
- end
176
-
177
- it 'adds keys' do
178
- expect(@gw).to receive(:upload_all).with(
179
- [
180
- { format: 'string', unit: 'c', settable: true, alias: 'bob' },
181
- { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
182
- { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
183
- { format: 'number', unit: 'bibs', settable: false, alias: 'greeble' },
184
- ]
185
- )
186
- @gw.syncup_before
187
- @gw.upload(nil, { format: 'number', unit: 'bibs', settable: false, alias: 'greeble' }, nil)
188
- @gw.syncup_after
189
- end
190
-
191
- it 'replaces keys' do
192
- expect(@gw).to receive(:upload_all).with(
193
- [
194
- { format: 'string', unit: 'c', settable: true, alias: 'bob' },
195
- { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
196
- { format: 'number', unit: 'bibs', settable: false, alias: 'fuzz' },
197
- ]
198
- )
199
- @gw.syncup_before
200
- @gw.upload(nil, { format: 'number', unit: 'bibs', settable: false, alias: 'fuzz' }, nil)
201
- @gw.syncup_after
202
- end
203
- end
204
-
205
- context 'syncdown' do
206
- before(:example) do
207
- # 2017-07-05: [lb] not sure what I had to add this just now;
208
- # this test had been working fine... I added a check for
209
- # duplicate local resource in locallist(), but this smells
210
- # really funny. I cannot explain how this test used to work,
211
- # nor why it started failing; but I had to add a mkpath on
212
- # 'specs', and I changed the copy to go into the specs/
213
- # directory, and I removed the extra empty array in the
214
- # and_return check.
215
- FileUtils.mkpath('specs')
216
- resfile = Pathname.new(File.join('specs', 'resources.yaml'))
217
- src = File.join(@testdir, 'spec', 'fixtures', 'gateway_resource_files', 'resources.yaml')
218
- FileUtils.copy(src, resfile.to_path)
219
-
220
- expect(@gw).to receive(:locallist).once.and_return(
221
- [
222
- { format: 'string', unit: 'c', settable: true, alias: 'bob' },
223
- { format: 'string', unit: 'c', settable: true, alias: 'fuzz' },
224
- { format: 'string', unit: 'bits', settable: true, alias: 'gruble' },
225
- ],
226
- # 2017-07-05: [lb] also had to remove this check.
227
- # locallist returns a single array, not two of them!
228
- #[],
229
- )
230
-
231
- @io = instance_double('IO')
232
- @p = instance_double('Pathname')
233
- expect(@p).to receive(:dirname).and_return(resfile.dirname)
234
- expect(@p).to receive(:extname).and_return(resfile.extname)
235
- expect(@p).to receive(:open).and_yield(@io)
236
- end
237
- it 'removes keys' do
238
- expect(@io).to receive(:write) do |args|
239
- fy = YAML.load(args)
240
- expect(fy).to eq(
241
- 'bob' => { 'format' => 'string', 'unit' => 'c', 'settable' => true },
242
- 'gruble' => { 'format' => 'string', 'unit' => 'bits', 'settable' => true }
243
- )
244
- end
245
-
246
- @gw.syncdown_before
247
- @gw.removelocal(@p, alias: 'fuzz')
248
- @gw.syncdown_after(@p)
249
- end
250
-
251
- it 'adds keys' do
252
- expect(@io).to receive(:write) do |args|
253
- fy = YAML.load(args)
254
- expect(fy).to eq(
255
- 'bob' => { 'format' => 'string', 'unit' => 'c', 'settable' => true },
256
- 'gruble' => { 'format' => 'string', 'unit' => 'bits', 'settable' => true },
257
- 'fuzz' => { 'format' => 'string', 'unit' => 'c', 'settable' => true },
258
- 'greeble' => { 'format' => 'number', 'unit' => 'bibs', 'settable' => false }
259
- )
260
- end
261
-
262
- @gw.syncdown_before
263
- @gw.download(@p, format: 'number', unit: 'bibs', settable: false, alias: 'greeble')
264
- @gw.syncdown_after(@p)
265
- end
266
-
267
- it 'replaces keys' do
268
- expect(@io).to receive(:write) do |args|
269
- fy = YAML.load(args)
270
- expect(fy).to eq(
271
- 'bob' => { 'format' => 'string', 'unit' => 'c', 'settable' => true },
272
- 'gruble' => { 'format' => 'string', 'unit' => 'bits', 'settable' => true },
273
- 'fuzz' => { 'format' => 'number', 'unit' => 'bibs', 'settable' => false }
274
- )
275
- end
276
-
277
- @gw.syncdown_before
278
- @gw.download(@p, format: 'number', unit: 'bibs', settable: false, alias: 'fuzz')
279
- @gw.syncdown_after(@p)
280
- end
281
- end
282
- end
283
-