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,282 +0,0 @@
1
- # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
- # License: PROPRIETARY. See LICENSE.txt.
3
- # frozen_string_literal: true
4
-
5
- # vim:tw=0:ts=2:sw=2:et:ai
6
- # Unauthorized copying of this file is strictly prohibited.
7
-
8
- require 'pathname'
9
- require 'MrMurano/version'
10
- require 'MrMurano/HttpAuthed'
11
- require 'MrMurano/ProjectFile'
12
- require 'MrMurano/Webservice-File'
13
- require '_workspace'
14
- require 'HttpAuthed_spec'
15
-
16
- RSpec.describe MrMurano::Webservice::File do
17
- include_context 'WORKSPACE'
18
- before(:example) do
19
- $cfg = MrMurano::Config.new
20
- $cfg.load
21
- $project = MrMurano::ProjectFile.new
22
- $project.load
23
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
24
- $cfg['product.id'] = 'XYZ'
25
- $cfg['application.id'] = 'XYZ'
26
- stub_request_email_password
27
-
28
- @srv = MrMurano::Webservice::File.new
29
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
30
-
31
- @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/file'
32
- @fileupload_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/fileupload'
33
- end
34
-
35
- it 'initializes' do
36
- uri = @srv.endpoint('/')
37
- expect(uri.to_s).to eq("#{@base_uri}/")
38
- end
39
-
40
- it 'lists' do
41
- body = [
42
- {
43
- path: '/',
44
- mime_type: 'text/html',
45
- checksum: 'f535dad52b2877a49717a034b4eee5ff1cdb8a18',
46
- },
47
- {
48
- path: '/batteryMeter.svg',
49
- mime_type: 'image/svg+xml',
50
- checksum: '06a1aab86ba8cb9b3f2913c673d4aa243c553494',
51
- },
52
- {
53
- path: '/meter.html',
54
- mime_type: 'text/html',
55
- checksum: '82e12125c2f1324bbf7bd64bf187f3334416117e',
56
- },
57
- ]
58
- stub_request(:get, @base_uri)
59
- .with(
60
- headers: {
61
- 'Authorization' => 'token TTTTTTTTTT',
62
- 'Content-Type' => 'application/json',
63
- }
64
- )
65
- .to_return(body: body.to_json)
66
- ret = @srv.list
67
- expect(ret).to eq(body)
68
- end
69
-
70
- it 'removes' do
71
- stub_request(:delete, "#{@base_uri}/index.html")
72
- .with(
73
- headers: {
74
- 'Authorization' => 'token TTTTTTTTTT',
75
- 'Content-Type' => 'application/json',
76
- }
77
- )
78
- .to_return(status: 200)
79
- ret = @srv.remove('index.html')
80
- expect(ret).to eq({})
81
- end
82
-
83
- context 'fetches' do
84
- it 'gets an error' do
85
- stub_request(:get, "#{@base_uri}/bob")
86
- .with(
87
- headers: {
88
- 'Authorization' => 'token TTTTTTTTTT',
89
- 'Content-Type' => 'application/json',
90
- }
91
- )
92
- .to_return(status: 404, body: 'nope')
93
- saved = $stderr
94
- $stderr = StringIO.new
95
- ret = @srv.fetch('/bob')
96
- expect(ret).to be_nil
97
- expect($stderr.string).to eq("\e[31mRequest Failed: 404: nope\e[0m\n")
98
- $stderr = saved
99
- end
100
-
101
- it 'gets $stdout' do
102
- stub_request(:get, "#{@base_uri}/bob")
103
- .with(
104
- headers: {
105
- 'Authorization' => 'token TTTTTTTTTT',
106
- 'Content-Type' => 'application/json',
107
- }
108
- )
109
- .to_return(status: 200, body: 'nope')
110
- # The progress bar clears itself, e.g., spaces to cover old message, than \r.
111
- $cfg['tool.no-progress'] = true
112
- saved = $stdout
113
- $stdout = StringIO.new
114
- ret = @srv.fetch('/bob')
115
- expect(ret).to be_nil
116
- expect($stdout.string).to eq('nope')
117
- $stdout = saved
118
- end
119
-
120
- it 'gets to block' do
121
- stub_request(:get, "#{@base_uri}/bob")
122
- .with(
123
- headers: {
124
- 'Authorization' => 'token TTTTTTTTTT',
125
- 'Content-Type' => 'application/json',
126
- }
127
- )
128
- .to_return(status: 200, body: 'nope')
129
- got = ''
130
- ret = @srv.fetch('/bob') { |chunk| got += chunk }
131
- expect(ret).to be_nil
132
- expect(got).to eq('nope')
133
- end
134
- end
135
-
136
- context 'uploads' do
137
- before(:example) do
138
- FileUtils.mkpath(@project_dir + '/files')
139
- @lp = Pathname.new(@project_dir + '/files/one.text')
140
- @lp.open('w') { |io| io << %(Just some text) }
141
- @lp = @lp.realpath
142
- end
143
-
144
- it 'an item' do
145
- stub_request(:put, "#{@base_uri}upload/one.text")
146
- .with(
147
- headers: {
148
- 'Authorization' => 'token TTTTTTTTTT',
149
- 'Content-Type' => %r{multipart/form-data; boundary=.*},
150
- },
151
- )
152
-
153
- @srv.upload(@lp, { path: '/one.text' }, false)
154
- end
155
-
156
- it 'gets an error' do
157
- stub_request(:put, "#{@base_uri}upload/one.text")
158
- .with(
159
- headers: {
160
- 'Authorization' => 'token TTTTTTTTTT',
161
- 'Content-Type' => %r{multipart/form-data; boundary=.*},
162
- },
163
- ).to_return(status: 401, body: 'nope')
164
-
165
- saved = $stderr
166
- $stderr = StringIO.new
167
- @srv.upload(@lp, { path: '/one.text' }, false)
168
- expect($stderr.string).to eq("\e[31mRequest Failed: 401: nope\e[0m\n")
169
- $stderr = saved
170
- end
171
-
172
- it 'an item with curl debug' do
173
- stub_request(:put, "#{@base_uri}upload/one.text")
174
- .with(
175
- headers: {
176
- 'Authorization' => 'token TTTTTTTTTT',
177
- 'Content-Type' => %r{multipart/form-data; boundary=.*},
178
- },
179
- )
180
- $cfg['tool.no-progress'] = true
181
- $cfg['tool.curldebug'] = true
182
- $cfg['tool.curlfancy'] = false
183
- $cfg.curlfile_f = nil
184
- saved = $stdout
185
- $stdout = StringIO.new
186
- @srv.upload(@lp, { path: '/one.text' }, false)
187
- expect($stdout.string.lines).to match_array(
188
- [
189
- %r{^curl -s -H 'Authorization: token TTTTTTTTTT'.*-X PUT '#{@fileupload_uri}/one.text' -F file=@.*$},
190
- ]
191
- )
192
- $stdout = saved
193
- end
194
- end
195
-
196
- context 'compares' do
197
- before(:example) do
198
- @i_a = {
199
- path: '/api/v1/bar',
200
- mime_type: 'application/json',
201
- checksum: '12',
202
- }
203
- @i_b = {
204
- path: '/api/v1/bar',
205
- mime_type: 'application/json',
206
- checksum: '12',
207
- }
208
- end
209
- it 'equal' do
210
- ret = @srv.docmp(@i_a, @i_b)
211
- expect(ret).to be false
212
- end
213
- it 'different mime' do
214
- i_a = @i_a.merge(mime_type: 'text/plain')
215
- ret = @srv.docmp(i_a, @i_b)
216
- expect(ret).to be true
217
- end
218
- it 'different checksum' do
219
- i_a = @i_a.merge(checksum: '4352')
220
- ret = @srv.docmp(i_a, @i_b)
221
- expect(ret).to be true
222
- end
223
- end
224
-
225
- context 'Lookup functions' do
226
- it 'gets local name' do
227
- ret = @srv.tolocalname({ path: '/one/two/three.html' }, :path)
228
- expect(ret).to eq('/one/two/three.html')
229
- end
230
-
231
- it 'gets default_page local name' do
232
- ret = @srv.tolocalname({ path: '/' }, :path)
233
- expect(ret).to eq('index.html')
234
- end
235
-
236
- it 'gets synckey' do
237
- ret = @srv.synckey(path: '/one/two/three')
238
- expect(ret).to eq('/one/two/three')
239
- end
240
-
241
- it 'gets searchfor' do
242
- $cfg['files.searchFor'] = %(a b c/**/d/*.bob)
243
- ret = @srv.searchFor
244
- expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
245
- end
246
-
247
- it 'gets ignoring' do
248
- $cfg['files.ignoring'] = %(a b c/**/d/*.bob)
249
- ret = @srv.ignoring
250
- expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
251
- end
252
- end
253
-
254
- context 'to_remote_items' do
255
- before(:example) do
256
- FileUtils.mkpath(@project_dir + '/files')
257
- @lp = Pathname.new(@project_dir + '/files/one.text')
258
- @lp.open('w') { |io| io << %(Just some text) }
259
- @lp = @lp.realpath
260
- end
261
-
262
- it 'gets item' do
263
- prj = Pathname.new(@project_dir).realpath
264
- just_some_text = %(Just some text)
265
- want = [
266
- MrMurano::Webservice::File::FileItem.new(
267
- path: '/files/one.text',
268
- mime_type: 'text/plain',
269
- # 2018-04-16: Did backend change from SHA1 to MD5 hash function?
270
- # You can calculate this with `sha1sum one.text`
271
- #checksum: 'd1af3dadf08479a1d43b282f95d61dda8efda5e7'
272
- # You can calculate this with `md5sum one.text`
273
- checksum: 'e9ea4a5be73a09f541ad0b611083f0df',
274
- size: just_some_text.length,
275
- ),
276
- ]
277
- ret = @srv.to_remote_items(prj, @lp)
278
- expect(ret).to eq(want)
279
- end
280
- end
281
- end
282
-
@@ -1,105 +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 'tempfile'
9
- require 'webmock'
10
- require 'yaml'
11
-
12
- require 'MrMurano/version'
13
- require 'MrMurano/HttpAuthed'
14
- require 'MrMurano/ProjectFile'
15
- require 'MrMurano/SyncRoot'
16
- require 'MrMurano/Webservice-Cors'
17
- require '_workspace'
18
- require 'HttpAuthed_spec'
19
-
20
- RSpec.describe MrMurano::Webservice::Settings do
21
- include_context 'WORKSPACE'
22
-
23
- before(:example) do
24
- $cfg = MrMurano::Config.new
25
- $cfg.load
26
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
27
- $cfg['application.id'] = 'XYZ'
28
- stub_request_email_password
29
-
30
- @srv = MrMurano::Webservice::Settings.new
31
-
32
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
33
-
34
- @base_uri = "#{$cfg['net.protocol']}://#{$cfg['net.host']}/api:1/solution/XYZ/cors"
35
- end
36
-
37
- after(:example) do
38
- WebMock.reset!
39
- end
40
-
41
- it 'initializes' do
42
- uri = @srv.endpoint('/')
43
- expect(uri.to_s).to eq("#{@base_uri}/")
44
- end
45
-
46
- context 'when server gives string' do
47
- context 'fetches' do
48
- it 'as a hash' do
49
- cors = { origin: true,
50
- methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
51
- headers: ['Content-Type', 'Cookie', 'Authorization'],
52
- credentials: true, }
53
- body = cors
54
- stub_request(:get, @base_uri.to_s)
55
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
56
- 'Content-Type' => 'application/json', })
57
- .to_return(body: body.to_json)
58
-
59
- ret = @srv.cors
60
- expect(ret).to eq(cors)
61
- end
62
- end
63
- end
64
-
65
- context 'when server gives object' do
66
- context 'fetches' do
67
- it 'as a hash' do
68
- cors = { origin: true,
69
- methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
70
- headers: ['Content-Type', 'Cookie', 'Authorization'],
71
- credentials: true, }
72
- body = cors
73
- stub_request(:get, @base_uri.to_s)
74
- .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
75
- 'Content-Type' => 'application/json', })
76
- .to_return(body: body.to_json)
77
-
78
- ret = @srv.cors
79
- expect(ret).to eq(cors)
80
- end
81
- end
82
- end
83
-
84
- context 'uploads' do
85
- before(:example) do
86
- $project = MrMurano::ProjectFile.new
87
- $project.load
88
- @cors = { origin: true,
89
- methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
90
- headers: ['Content-Type', 'Cookie', 'Authorization'],
91
- credentials: true, }
92
- end
93
- it 'sets' do
94
- stub_request(:put, @base_uri.to_s)
95
- .with(body: @cors.to_json,
96
- headers: { 'Authorization' => 'token TTTTTTTTTT',
97
- 'Content-Type' => 'application/json', })
98
- .to_return(body: '')
99
-
100
- ret = @srv.cors = (@cors)
101
- expect(ret).to eq(@cors)
102
- end
103
- end
104
- end
105
-
data/spec/_workspace.rb DELETED
@@ -1,43 +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 'tmpdir'
11
-
12
- RSpec.shared_context 'WORKSPACE' do
13
- before(:context) do
14
- @timeit_time0 = Time.now
15
- end
16
-
17
- after(:context) do
18
- elapsed_secs = Time.now - @timeit_time0
19
- puts "\n .. elapsed: #{elapsed_secs.round(2)} secs."
20
- end
21
-
22
- around(:example) do |ex|
23
- @testdir = Pathname.new(Dir.pwd).realpath
24
- $exited_abnormally = true
25
- Dir.mktmpdir do |hdir|
26
- @tmpdir = hdir
27
- saved_home = ENV['HOME']
28
- # Set ENV to override output of Dir.home
29
- ENV['HOME'] = File.join(hdir, 'home')
30
- FileUtils.mkpath(ENV['HOME'])
31
- Dir.chdir(hdir) do
32
- @project_dir = File.join(ENV['HOME'], 'work', 'project')
33
- FileUtils.mkpath(@project_dir)
34
- Dir.chdir(@project_dir) do
35
- ex.run
36
- end
37
- end
38
- ENV['HOME'] = saved_home
39
- end
40
- $exited_abnormally = false
41
- end
42
- end
43
-
@@ -1,64 +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 business', :cmd, :needs_password do
13
- include_context 'CI_CMD'
14
-
15
- context 'without project' do
16
- it 'help' do
17
- cmd_verify_help('business')
18
- end
19
- end
20
-
21
- context 'list' do
22
- it 'as table' do
23
- out, err = murano_command_run('business list')
24
- expect(err).to eq('')
25
- olines = out.lines
26
- expect(olines[0]).to match(/^(\+-+){3}\+$/)
27
- expect(olines[1]).to match(/^\| bizid\s+\| name\s+\| role\s+\|$/)
28
- expect(olines[2]).to match(/^(\+-+){3}\+$/)
29
- expect(olines[-1]).to match(/^(\+-+){3}\+$/)
30
- end
31
-
32
- it 'as json' do
33
- out, err = murano_command_run('business list', '-c', 'outformat=json')
34
- expect(err).to eq('')
35
- expect { JSON.parse(out) }.to_not raise_error
36
- end
37
-
38
- it 'only ids' do
39
- out, err = murano_command_run('business list', '--idonly')
40
- expect(err).to eq('')
41
- expect(out).to match(/^(\S+\s)*\S+$/)
42
- end
43
-
44
- it 'output to file' do
45
- out, err = murano_command_run('business list', '--idonly', '-o', 'bob')
46
- expect(err).to eq('')
47
- expect(out).to eq('')
48
- expect(File.exist?('bob')).to be true
49
- data = IO.read('bob')
50
- expect(data).to match(/^(\S+\s)*\S+$/)
51
- end
52
-
53
- it 'fewer fields' do
54
- out, err = murano_command_run('business list', '--brief')
55
- expect(err).to eq('')
56
- olines = out.lines
57
- expect(olines[0]).to match(/^(\+-+)+\+$/)
58
- expect(olines[1]).to match(/^(\| \S+\s+)+\|$/)
59
- expect(olines[2]).to match(/^(\+-+)+\+$/)
60
- expect(olines[-1]).to match(/^(\+-+)+\+$/)
61
- end
62
- end
63
- end
64
-