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
data/spec/Account_spec.rb DELETED
@@ -1,256 +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 'highline/import'
9
- require 'webmock'
10
-
11
- require 'MrMurano/version'
12
- require 'MrMurano/Account'
13
- require 'MrMurano/Config'
14
- require 'MrMurano/HttpAuthed'
15
- require 'MrMurano/ProjectFile'
16
- require '_workspace'
17
- require 'HttpAuthed_spec'
18
-
19
- RSpec.describe MrMurano::Account, 'token' do
20
- include_context 'WORKSPACE'
21
-
22
- before(:example) do
23
- $cfg = MrMurano::Config.new
24
- $cfg.load
25
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
26
- $cfg['business.id'] = 'XYZxyz'
27
- $cfg['product.id'] = 'XYZ'
28
- $cfg['user.name'] = 'BoB@place.net'
29
-
30
- # Trickery: Copy tool.curl* settings from :env into :user.
31
- $cfg['tool.curldebug'] = $cfg['tool.curldebug']
32
- $cfg['tool.curlfile'] = $cfg['tool.curlfile']
33
- # Unload the MURANO_CONFIGFILE :env scoped config, so
34
- # its keys do not mess with our tests, e.g., to avoid
35
- # using user.name from test runner's ~/.murano/config.
36
- $cfg.unload(:env)
37
-
38
- # Reset the Net::HTTP object, which was configured with the old net.host, etc.
39
- MrMurano::HttpAuthed.instance.http_reset
40
-
41
- # (lb): 2018-08-09: With the new snapshot infrastructure, the token gets saved
42
- # to the snapshot after the example runs. However, for examples that expect to
43
- # start with no token, running the snapshot loads the token even though it should
44
- # not be loaded. To work around that, delete the token here. (I have a feeling
45
- # there's a better way to handle this, but I'm not sure offhand; this works for
46
- # now, so going with it!)
47
- ENV.delete('MURANO_TOKEN')
48
-
49
- stub_request_email_password
50
-
51
- $project = MrMurano::ProjectFile.new
52
- $project.load
53
-
54
- @acc = MrMurano::Account.new
55
- end
56
-
57
- after(:example) do
58
- @acc.token_reset
59
- WebMock.reset!
60
- end
61
-
62
- context 'Get login info' do
63
- before(:example) do
64
- @pswd = create_instance_double_passwords
65
- end
66
-
67
- it 'Asks for nothing' do
68
- @acc.credentials_reset
69
- $cfg['user.name'] = 'bob'
70
- expect(@pswd).to receive(:get).once.and_return('built')
71
-
72
- ret = @acc.login_info
73
- expect(ret).to eq(email: 'bob', password: 'built')
74
- end
75
-
76
- it 'Asks for user name' do
77
- @acc.credentials_reset
78
- $cfg['user.name'] = nil
79
- expect($terminal).to receive(:ask).once.and_return('bob')
80
- expect(@acc).to receive(:error).once
81
- expect($cfg).to receive(:set).with(
82
- 'user.name', 'bob', :user,
83
- ).once.and_call_original
84
- expect(@pswd).to receive(:get).once.and_return('built')
85
-
86
- ret = @acc.login_info
87
- expect(ret).to eq(email: 'bob', password: 'built')
88
- end
89
-
90
- it 'Asks for password' do
91
- @acc.credentials_reset
92
- $cfg['user.name'] = 'bob'
93
- expect(@pswd).to receive(:get).with(
94
- 'bizapi.hosted.exosite.io', 'bob',
95
- ).once.and_return(nil)
96
- expect(@acc).to receive(:error).once
97
- expect($terminal).to receive(:ask).once.and_return('dog')
98
- $cfg['auth.persist-basic'] = true
99
- expect(@pswd).to receive(:set).once.with('bizapi.hosted.exosite.io', 'bob', 'dog')
100
- # 2017-07-31: login_info may exit unless the command okays prompting for the password.
101
- # (If we don't set this, login_info exits, which we'd want to
102
- # catch with
103
- # expect {@acc.login_info }.to raise_error(SystemExit).and output('...')
104
- expect($cfg).to receive(:prompt_if_logged_off).and_return(true)
105
-
106
- ret = @acc.login_info
107
- expect(ret).to eq(email: 'bob', password: 'dog')
108
- end
109
- end
110
-
111
- context 'token' do
112
- before(:example) do
113
- @acc.credentials_reset
114
- allow(@acc).to receive(:login_info).and_return(email: 'bob', password: 'v')
115
- http_authed = MrMurano::HttpAuthed.instance
116
- http_authed.instance_variable_set(:@login_info, email: 'bob', password: 'v')
117
- end
118
-
119
- it 'gets a token' do
120
- stub_request(:post, 'https://bizapi.hosted.exosite.io/api:1/token/')
121
- .with(body: { email: 'bob', password: 'v' }.to_json)
122
- .to_return(body: { token: 'ABCDEFGHIJKLMNOP' }.to_json)
123
-
124
- ret = @acc.token
125
- expect(ret).to eq('ABCDEFGHIJKLMNOP')
126
-
127
- # Remove all stub_request mocks.
128
- WebMock.reset!
129
- end
130
-
131
- it 'gets an error' do
132
- stub_request(:post, 'https://bizapi.hosted.exosite.io/api:1/token/')
133
- .with(body: { email: 'bob', password: 'v' }.to_json)
134
- .to_return(status: 401, body: {}.to_json)
135
-
136
- # Note that we stub out error and warning so nothing gets output.
137
- expect(
138
- MrMurano::HttpAuthed.instance
139
- ).to receive(:error).exactly(3).times.and_return(nil)
140
- # The warning is about ENV['MURANO_PASSWORD'] specifying the password.
141
- expect(MrMurano::HttpAuthed.instance).to receive(:warning).once.and_return(nil)
142
- expect { @acc.token }.to raise_error(SystemExit).and output(//).to_stderr
143
-
144
- WebMock.reset!
145
- end
146
-
147
- it 'uses existing token' do
148
- @acc.token_reset('XXX')
149
- ret = @acc.token
150
- expect(ret).to eq('XXX')
151
- end
152
-
153
- it 'uses existing token, even with new instance' do
154
- @acc.token_reset('XXX')
155
- acc = MrMurano::Account.new
156
- ret = acc.token
157
- expect(ret).to eq('XXX')
158
- end
159
- end
160
- end
161
-
162
- RSpec.describe MrMurano::Account do
163
- include_context 'WORKSPACE'
164
-
165
- before(:example) do
166
- @saved_cfg = ENV['MURANO_CONFIGFILE']
167
- ENV['MURANO_CONFIGFILE'] = nil
168
- $cfg = MrMurano::Config.new
169
- $cfg.load
170
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
171
- $cfg['business.id'] = 'XYZxyz'
172
- $cfg['product.id'] = 'XYZ'
173
- $cfg['user.name'] = 'BoB@place.net'
174
-
175
- # Reset the Net::HTTP object, which was configured with the old net.host, etc.
176
- MrMurano::HttpAuthed.instance.http_reset
177
-
178
- # Reset the Http mocks (probably not necessary).
179
- WebMock.reset!
180
- stub_request_email_password
181
-
182
- @acc = MrMurano::Account.new
183
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
184
- end
185
-
186
- after(:example) do
187
- ENV['MURANO_CONFIGFILE'] = @saved_cfg
188
- WebMock.reset!
189
- end
190
-
191
- it 'initializes' do
192
- uri = @acc.endpoint('')
193
- expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/')
194
- end
195
-
196
- context 'lists business' do
197
- it 'for user.name' do
198
- # http.rb::json_opts() sets :symbolize_names=>true, so use symbols, not strings.
199
- bizlist = [
200
- { bizid: 'YYY',
201
- role: 'admin',
202
- name: 'MAE', },
203
- { bizid: 'XXX',
204
- role: 'admin',
205
- name: 'MPS', },
206
- ]
207
- stub_request(
208
- :get,
209
- 'https://bizapi.hosted.exosite.io/api:1/user/BoB@place.net/membership/',
210
- ).to_return(body: bizlist)
211
-
212
- buslist = []
213
- buslist << MrMurano::Business.new(bizlist[0])
214
- buslist << MrMurano::Business.new(bizlist[1])
215
-
216
- $cfg['user.name'] = 'BoB@place.net'
217
- stub_request_email_password
218
-
219
- ret = @acc.businesses
220
- expect(ret).to eq(buslist)
221
-
222
- WebMock.reset!
223
- end
224
-
225
- it 'asks for account when missing' do
226
- bizlist = [
227
- { bizid: 'YYY',
228
- role: 'admin',
229
- name: 'MAE', },
230
- { bizid: 'XXX',
231
- role: 'admin',
232
- name: 'MPS', },
233
- ]
234
- stub_request(
235
- :get,
236
- 'https://bizapi.hosted.exosite.io/api:1/user/BoB@place.net/membership/',
237
- ).to_return(body: bizlist)
238
-
239
- buslist = []
240
- buslist << MrMurano::Business.new(bizlist[0])
241
- buslist << MrMurano::Business.new(bizlist[1])
242
-
243
- $cfg['user.name'] = nil
244
- expect(@acc).to receive(:login_info) do |_arg|
245
- $cfg['user.name'] = 'BoB@place.net'
246
- end
247
- stub_request_email_password
248
-
249
- ret = @acc.businesses
250
- expect(ret).to eq(buslist)
251
-
252
- WebMock.reset!
253
- end
254
- end
255
- end
256
-
@@ -1,307 +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 'highline/import'
9
- require 'MrMurano/version'
10
- require 'MrMurano/Account'
11
- require 'MrMurano/Config'
12
- require 'MrMurano/HttpAuthed'
13
- require '_workspace'
14
- require 'HttpAuthed_spec'
15
-
16
- MISSING_BIZ_ID_MSG = MrMurano::Business.missing_business_id_msg
17
-
18
- RSpec.describe MrMurano::Business do
19
- include_context 'WORKSPACE'
20
- before(:example) do
21
- $cfg = MrMurano::Config.new
22
- $cfg.load
23
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
24
- $cfg['business.id'] = 'XYZxyz'
25
- $cfg['product.id'] = 'XYZ'
26
- $cfg['user.name'] = 'BoB@place.net'
27
- stub_request_email_password
28
-
29
- @biz = MrMurano::Business.new
30
-
31
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
32
- end
33
-
34
- it 'lists products' do
35
- prodlist = [
36
- { bizid: 'XYZxyz',
37
- type: 'product',
38
- pid: 'ABC',
39
- modelId: 'cde',
40
- label: 'fts',
41
- api_id: 'XYZ',
42
- sid: 'XYZ',
43
- name: 'XYZ', },
44
- { bizid: 'XYZxyz',
45
- type: 'product',
46
- pid: 'fgh',
47
- modelId: 'ijk',
48
- label: 'lua-test',
49
- api_id: 'XYZ',
50
- sid: 'XYZ',
51
- name: 'XYZ', },
52
- ]
53
- stub_request(
54
- :get, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
55
- ).to_return(body: prodlist)
56
-
57
- solz = []
58
- solz << MrMurano::Product.new(prodlist[0])
59
- solz << MrMurano::Product.new(prodlist[1])
60
-
61
- ret = @biz.products
62
- expect(ret).to eq(solz)
63
- end
64
-
65
- it 'lists products; without biz.id' do
66
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
67
- expect(@biz).to receive(:debug).with('Getting all solutions of type product')
68
- expect { @biz.products }.to raise_error(MISSING_BIZ_ID_MSG)
69
- end
70
-
71
- it 'creates product' do
72
- # LATER: Re-enable using 'ONe' instead of 'one' after upcase fixed in pegasus_registry.
73
- stub_request(
74
- :post, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
75
- ).with(
76
- body: { label: 'one', type: 'product' }
77
- ).to_return(body: '{"id": "abc123def456ghi78", "name": "one"}')
78
-
79
- prod = @biz.new_product('one')
80
- expect(prod.valid?).to be true
81
- end
82
-
83
- it 'creates product; without biz.id' do
84
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
85
- # LATER: Re-enable using 'ONe' instead of 'one' after upcase fixed in pegasus_registry.
86
- expect { @biz.new_product('one') }.to raise_error(MISSING_BIZ_ID_MSG)
87
- end
88
-
89
- it 'deletes product' do
90
- # LATER: Re-enable using 'ONe' instead of 'one' after upcase fixed in pegasus_registry.
91
- stub_request(
92
- :delete, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/one'
93
- ).to_return(body: '')
94
-
95
- ret = @biz.delete_product('one')
96
- expect(ret).to eq({})
97
- end
98
-
99
- it 'deletes product; without biz.id' do
100
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
101
- # LATER: Re-enable using 'ONe' instead of 'one' after upcase fixed in pegasus_registry.
102
- expect { @biz.delete_product('one') }.to raise_error(MISSING_BIZ_ID_MSG)
103
- end
104
-
105
- # *** :applications type solutions
106
-
107
- it 'lists applications' do
108
- # NOTE: Need to use symbols, not strings, for keys, because
109
- # http.rb::json_opts() specifies :symbolize_names => true.
110
- appllist = [
111
- { bizid: 'XYZxyz',
112
- type: 'application',
113
- domain: 'XYZxyz.apps.exosite.io',
114
- api_id: 'ACBabc',
115
- sid: 'ACBabc',
116
- name: 'ijk', },
117
- { bizid: 'XYZxyz',
118
- type: 'application',
119
- domain: 'XYZxyz.apps.exosite.io',
120
- api_id: 'DEFdef',
121
- sid: 'DEFdef',
122
- name: 'lmn', },
123
- ]
124
- solnlist = [
125
- { bizid: 'XYZxyz',
126
- type: 'product',
127
- pid: 'ABC',
128
- modelId: 'cde',
129
- label: 'fts',
130
- name: 'fgh', },
131
- ]
132
- solnlist.concat appllist
133
- stub_request(
134
- :get, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
135
- ).to_return(body: solnlist)
136
-
137
- solz = []
138
- #solz << MrMurano::Product.new(solnlist[0])
139
- solz << MrMurano::Application.new(appllist[0])
140
- solz << MrMurano::Application.new(appllist[1])
141
-
142
- ret = @biz.applications
143
- expect(ret).to eq(solz)
144
- end
145
-
146
- it 'lists applications; without biz.id' do
147
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
148
- expect(@biz).to receive(:debug).with('Getting all solutions of type application')
149
- expect { @biz.applications }.to raise_error(MISSING_BIZ_ID_MSG)
150
- end
151
-
152
- it 'creates application' do
153
- # LATER: Re-enable using 'ONe' instead of 'one' after upcase fixed in pegasus_registry.
154
- stub_request(
155
- :post, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
156
- ).with(
157
- body: { label: 'one', type: 'application' }
158
- ).to_return(body: '{"id": "abc123def456ghi78", "name": "one"}')
159
-
160
- appl = @biz.new_application('one')
161
- expect(appl.valid?).to be true
162
- end
163
-
164
- it 'creates application; without biz.id' do
165
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
166
- # LATER: Re-enable using 'ONe' instead of 'one' after upcase fixed in pegasus_registry.
167
- expect { @biz.new_application('one') }.to raise_error(MISSING_BIZ_ID_MSG)
168
- end
169
-
170
- it 'deletes application' do
171
- stub_request(
172
- :delete, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/ONe'
173
- ).to_return(body: '')
174
-
175
- ret = @biz.delete_application('ONe')
176
- expect(ret).to eq({})
177
- end
178
-
179
- it 'deletes application; without biz.id' do
180
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
181
- expect { @biz.delete_application('ONe') }.to raise_error(MISSING_BIZ_ID_MSG)
182
- end
183
-
184
- # *** :all type solutions
185
-
186
- it 'lists solutions' do
187
- # http.rb::json_opts() sets :symbolize_names=>true, so use symbols, not strings.
188
- prodlist = [
189
- { bizid: 'XYZxyz',
190
- type: 'product',
191
- domain: 'ABCabc.m2.exosite.io',
192
- api_id: 'ABCabc',
193
- sid: 'ABCabc',
194
- name: 'XXX', },
195
- ]
196
- appllist = [
197
- { bizid: 'XYZxyz',
198
- type: 'application',
199
- domain: 'XYZxyz.apps.exosite.io',
200
- api_id: 'DEFdef',
201
- sid: 'DEFdef',
202
- name: 'XXX', },
203
- ]
204
- solnlist = prodlist + appllist
205
- stub_request(
206
- :get, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
207
- ).to_return(body: solnlist)
208
-
209
- solz = []
210
- solz << MrMurano::Product.new(prodlist[0])
211
- solz << MrMurano::Application.new(appllist[0])
212
-
213
- solz = @biz.solutions
214
- expect(solz).to eq(solz)
215
- end
216
-
217
- it 'lists solutions; without biz.id' do
218
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
219
- expect(@biz).to receive(:debug).with('Getting all solutions of type all')
220
- expect { @biz.solutions }.to raise_error(MISSING_BIZ_ID_MSG)
221
- end
222
-
223
- it 'creates solution' do
224
- stub_request(
225
- :post, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
226
- ).with(
227
- body: { label: 'one', type: 'product' }
228
- ).to_return(
229
- body: '{"id": "abc123def456ghi78", "name": "one"}'
230
- )
231
-
232
- sol = @biz.new_solution!('one', :product)
233
- expect(sol.valid?).to be true
234
- expect(sol.api_id).to eq('abc123def456ghi78')
235
- end
236
-
237
- still_broken = true
238
- if still_broken
239
- # LATER: Re-enable after upcase fixed in pegasus_registry.
240
- it 'creates solution; with upper case' do
241
- # 2017-07-03: Murano appears to return the id nowadays, so added body.
242
- stub_request(
243
- :post, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
244
- ).with(body: { label: 'ONe', type: 'product' })
245
- .to_return(body: '{"id": "abc123def456ghi78", "name": "ONe"}')
246
-
247
- expect { @biz.new_solution!('ONe', :product) }.to_not raise_error
248
- end
249
- else
250
- it 'creates solution; with uppercase' do
251
- expect { @biz.new_solution!('oNeTWO', :product) }.to raise_error(
252
- MrMurano::Product.new.name_validate_help
253
- )
254
- end
255
- end
256
-
257
- it 'creates solution; with numbers and dashes' do
258
- stub_request(
259
- :post, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/'
260
- ).with(body: { label: 'ONe-8796-gkl', type: 'product' })
261
- .to_return(body: '{"id": "abc123def456ghi78", "name": "ONe-8796-gkl"}')
262
-
263
- # 2017-05-26: Dashes forbidden! MUR-1994
264
- #expect { @biz.new_solution!('ONe-8796-gkl', :product) }.to_not raise_error
265
- expect { @biz.new_solution!('ONe-8796-gkl', :product) }.to raise_error(
266
- MrMurano::Product.new.name_validate_help
267
- )
268
- end
269
-
270
- it 'creates solution; that is too long' do
271
- expect { @biz.new_solution!('o' * 70, :product) }.to raise_error(
272
- MrMurano::Product.new.name_validate_help
273
- )
274
- end
275
-
276
- it 'creates solution; with underscore' do
277
- expect { @biz.new_solution!('one_two', :product) }.to raise_error(
278
- MrMurano::Product.new.name_validate_help
279
- )
280
- end
281
-
282
- it 'creates solution; with digit first' do
283
- expect { @biz.new_solution!('1two', :product) }.to raise_error(
284
- MrMurano::Product.new.name_validate_help
285
- )
286
- end
287
-
288
- it 'creates solution; without biz.id' do
289
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
290
- expect { @biz.new_solution!('one', :product) }.to raise_error(MISSING_BIZ_ID_MSG)
291
- end
292
-
293
- it 'deletes solution' do
294
- stub_request(
295
- :delete, 'https://bizapi.hosted.exosite.io/api:1/business/XYZxyz/solution/one'
296
- ).to_return(body: '')
297
-
298
- ret = @biz.delete_solution('one')
299
- expect(ret).to eq({})
300
- end
301
-
302
- it 'deletes solution; without biz.id' do
303
- allow($cfg).to receive(:get).with('business.id').and_return(nil)
304
- expect { @biz.delete_solution('one') }.to raise_error(MISSING_BIZ_ID_MSG)
305
- end
306
- end
307
-