wavefront-cli 4.2.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -0
  3. data/.rubocop.yml +1 -14
  4. data/.travis.yml +4 -4
  5. data/Gemfile +2 -0
  6. data/HISTORY.md +82 -60
  7. data/Rakefile +2 -0
  8. data/bin/wf +1 -0
  9. data/lib/wavefront-cli/alert.rb +13 -5
  10. data/lib/wavefront-cli/apitoken.rb +2 -0
  11. data/lib/wavefront-cli/base.rb +95 -47
  12. data/lib/wavefront-cli/cloudintegration.rb +6 -0
  13. data/lib/wavefront-cli/command_mixins/acl.rb +6 -1
  14. data/lib/wavefront-cli/command_mixins/tag.rb +2 -0
  15. data/lib/wavefront-cli/commands/.rubocop.yml +3 -4
  16. data/lib/wavefront-cli/commands/alert.rb +2 -1
  17. data/lib/wavefront-cli/commands/apitoken.rb +6 -0
  18. data/lib/wavefront-cli/commands/base.rb +30 -21
  19. data/lib/wavefront-cli/commands/cloudintegration.rb +2 -0
  20. data/lib/wavefront-cli/commands/config.rb +2 -0
  21. data/lib/wavefront-cli/commands/dashboard.rb +2 -0
  22. data/lib/wavefront-cli/commands/derivedmetric.rb +2 -0
  23. data/lib/wavefront-cli/commands/event.rb +3 -1
  24. data/lib/wavefront-cli/commands/integration.rb +2 -1
  25. data/lib/wavefront-cli/commands/link.rb +2 -0
  26. data/lib/wavefront-cli/commands/message.rb +2 -0
  27. data/lib/wavefront-cli/commands/metric.rb +2 -0
  28. data/lib/wavefront-cli/commands/notificant.rb +2 -0
  29. data/lib/wavefront-cli/commands/proxy.rb +2 -0
  30. data/lib/wavefront-cli/commands/query.rb +2 -0
  31. data/lib/wavefront-cli/commands/savedsearch.rb +2 -0
  32. data/lib/wavefront-cli/commands/serviceaccount.rb +58 -0
  33. data/lib/wavefront-cli/commands/settings.rb +2 -0
  34. data/lib/wavefront-cli/commands/source.rb +3 -1
  35. data/lib/wavefront-cli/commands/user.rb +4 -1
  36. data/lib/wavefront-cli/commands/usergroup.rb +3 -0
  37. data/lib/wavefront-cli/commands/webhook.rb +2 -0
  38. data/lib/wavefront-cli/commands/window.rb +2 -0
  39. data/lib/wavefront-cli/commands/write.rb +2 -0
  40. data/lib/wavefront-cli/config.rb +23 -12
  41. data/lib/wavefront-cli/constants.rb +10 -4
  42. data/lib/wavefront-cli/controller.rb +53 -22
  43. data/lib/wavefront-cli/dashboard.rb +3 -0
  44. data/lib/wavefront-cli/derivedmetric.rb +12 -11
  45. data/lib/wavefront-cli/display/alert.rb +7 -4
  46. data/lib/wavefront-cli/display/apitoken.rb +2 -0
  47. data/lib/wavefront-cli/display/base.rb +34 -8
  48. data/lib/wavefront-cli/display/cloudintegration.rb +4 -2
  49. data/lib/wavefront-cli/display/dashboard.rb +2 -0
  50. data/lib/wavefront-cli/display/derivedmetric.rb +2 -0
  51. data/lib/wavefront-cli/display/distribution.rb +2 -0
  52. data/lib/wavefront-cli/display/event.rb +2 -0
  53. data/lib/wavefront-cli/display/externallink.rb +2 -0
  54. data/lib/wavefront-cli/display/integration.rb +2 -0
  55. data/lib/wavefront-cli/display/maintenancewindow.rb +2 -0
  56. data/lib/wavefront-cli/display/message.rb +7 -3
  57. data/lib/wavefront-cli/display/metric.rb +3 -1
  58. data/lib/wavefront-cli/display/notificant.rb +3 -1
  59. data/lib/wavefront-cli/display/printer/long.rb +36 -11
  60. data/lib/wavefront-cli/display/printer/sparkline.rb +3 -0
  61. data/lib/wavefront-cli/display/printer/terse.rb +6 -1
  62. data/lib/wavefront-cli/display/proxy.rb +2 -0
  63. data/lib/wavefront-cli/display/query.rb +35 -24
  64. data/lib/wavefront-cli/display/savedsearch.rb +2 -0
  65. data/lib/wavefront-cli/display/serviceaccount.rb +60 -0
  66. data/lib/wavefront-cli/display/settings.rb +2 -0
  67. data/lib/wavefront-cli/display/source.rb +18 -4
  68. data/lib/wavefront-cli/display/user.rb +56 -10
  69. data/lib/wavefront-cli/display/usergroup.rb +25 -19
  70. data/lib/wavefront-cli/display/webhook.rb +2 -0
  71. data/lib/wavefront-cli/display/write.rb +6 -2
  72. data/lib/wavefront-cli/event.rb +83 -62
  73. data/lib/wavefront-cli/exception.rb +3 -0
  74. data/lib/wavefront-cli/externallink.rb +6 -4
  75. data/lib/wavefront-cli/integration.rb +2 -0
  76. data/lib/wavefront-cli/maintenancewindow.rb +28 -17
  77. data/lib/wavefront-cli/message.rb +4 -0
  78. data/lib/wavefront-cli/metric.rb +4 -1
  79. data/lib/wavefront-cli/notificant.rb +2 -0
  80. data/lib/wavefront-cli/opt_handler.rb +2 -0
  81. data/lib/wavefront-cli/output/base.rb +8 -3
  82. data/lib/wavefront-cli/output/csv.rb +2 -0
  83. data/lib/wavefront-cli/output/csv/base.rb +2 -0
  84. data/lib/wavefront-cli/output/csv/query.rb +14 -7
  85. data/lib/wavefront-cli/output/hcl.rb +2 -0
  86. data/lib/wavefront-cli/output/hcl/alert.rb +2 -0
  87. data/lib/wavefront-cli/output/hcl/base.rb +10 -4
  88. data/lib/wavefront-cli/output/hcl/dashboard.rb +17 -8
  89. data/lib/wavefront-cli/output/hcl/notificant.rb +2 -0
  90. data/lib/wavefront-cli/output/hcl/stdlib/array.rb +2 -0
  91. data/lib/wavefront-cli/output/hcl/stdlib/string.rb +2 -0
  92. data/lib/wavefront-cli/output/json.rb +2 -0
  93. data/lib/wavefront-cli/output/ruby.rb +2 -0
  94. data/lib/wavefront-cli/output/wavefront.rb +2 -0
  95. data/lib/wavefront-cli/output/wavefront/query.rb +7 -4
  96. data/lib/wavefront-cli/output/yaml.rb +2 -0
  97. data/lib/wavefront-cli/proxy.rb +15 -3
  98. data/lib/wavefront-cli/query.rb +14 -12
  99. data/lib/wavefront-cli/savedsearch.rb +2 -0
  100. data/lib/wavefront-cli/serviceaccount.rb +179 -0
  101. data/lib/wavefront-cli/settings.rb +2 -0
  102. data/lib/wavefront-cli/source.rb +2 -0
  103. data/lib/wavefront-cli/stdlib/array.rb +3 -0
  104. data/lib/wavefront-cli/stdlib/string.rb +17 -11
  105. data/lib/wavefront-cli/user.rb +10 -4
  106. data/lib/wavefront-cli/usergroup.rb +4 -2
  107. data/lib/wavefront-cli/version.rb +3 -1
  108. data/lib/wavefront-cli/webhook.rb +2 -0
  109. data/lib/wavefront-cli/write.rb +80 -46
  110. data/spec/.rubocop.yml +3 -16
  111. data/spec/constants.rb +21 -0
  112. data/spec/spec_helper.rb +8 -422
  113. data/spec/support/command_base.rb +82 -0
  114. data/spec/support/minitest_assertions.rb +262 -0
  115. data/spec/support/output_tester.rb +32 -0
  116. data/spec/support/supported_commands.rb +19 -0
  117. data/spec/test_mixins/acl.rb +169 -0
  118. data/spec/test_mixins/delete.rb +25 -0
  119. data/spec/test_mixins/deleteundelete.rb +106 -0
  120. data/spec/test_mixins/describe.rb +24 -0
  121. data/spec/test_mixins/dump.rb +43 -0
  122. data/spec/test_mixins/general.rb +11 -0
  123. data/spec/test_mixins/history.rb +35 -0
  124. data/spec/test_mixins/import.rb +65 -0
  125. data/spec/test_mixins/list.rb +29 -0
  126. data/spec/test_mixins/search.rb +98 -0
  127. data/spec/test_mixins/set.rb +47 -0
  128. data/spec/test_mixins/tag.rb +99 -0
  129. data/spec/wavefront-cli/alert_spec.rb +288 -111
  130. data/spec/wavefront-cli/apitoken_spec.rb +53 -24
  131. data/spec/wavefront-cli/base_spec.rb +9 -27
  132. data/spec/wavefront-cli/cloudintegration_spec.rb +65 -29
  133. data/spec/wavefront-cli/commands/alert_spec.rb +1 -0
  134. data/spec/wavefront-cli/commands/base_spec.rb +15 -13
  135. data/spec/wavefront-cli/commands/cloudintegration_spec.rb +1 -0
  136. data/spec/wavefront-cli/commands/config_spec.rb +3 -0
  137. data/spec/wavefront-cli/commands/dashboard_spec.rb +1 -0
  138. data/spec/wavefront-cli/commands/derivedmetric_spec.rb +1 -0
  139. data/spec/wavefront-cli/commands/event_spec.rb +1 -0
  140. data/spec/wavefront-cli/commands/link_spec.rb +1 -0
  141. data/spec/wavefront-cli/commands/message_spec.rb +1 -0
  142. data/spec/wavefront-cli/commands/metric_spec.rb +1 -0
  143. data/spec/wavefront-cli/commands/proxy_spec.rb +1 -0
  144. data/spec/wavefront-cli/commands/query_spec.rb +1 -0
  145. data/spec/wavefront-cli/commands/webhook_spec.rb +1 -0
  146. data/spec/wavefront-cli/commands/window_spec.rb +1 -0
  147. data/spec/wavefront-cli/commands/write_spec.rb +1 -0
  148. data/spec/wavefront-cli/config_spec.rb +25 -14
  149. data/spec/wavefront-cli/controller_spec.rb +13 -3
  150. data/spec/wavefront-cli/dashboard_spec.rb +125 -76
  151. data/spec/wavefront-cli/derivedmetric_spec.rb +83 -67
  152. data/spec/wavefront-cli/display/base_spec.rb +5 -7
  153. data/spec/wavefront-cli/display/printer/long_spec.rb +20 -16
  154. data/spec/wavefront-cli/display/printer/terse_spec.rb +5 -4
  155. data/spec/wavefront-cli/event_spec.rb +360 -18
  156. data/spec/wavefront-cli/externallink_spec.rb +92 -58
  157. data/spec/wavefront-cli/integration_spec.rb +129 -31
  158. data/spec/wavefront-cli/maintenancewindow_spec.rb +270 -32
  159. data/spec/wavefront-cli/message_spec.rb +73 -30
  160. data/spec/wavefront-cli/metric_spec.rb +60 -22
  161. data/spec/wavefront-cli/notificant_spec.rb +45 -32
  162. data/spec/wavefront-cli/opt_handler_spec.rb +4 -1
  163. data/spec/wavefront-cli/output/csv/query_spec.rb +21 -19
  164. data/spec/wavefront-cli/output/csv_spec.rb +5 -2
  165. data/spec/wavefront-cli/output/hcl_spec.rb +5 -2
  166. data/spec/wavefront-cli/output/helpers.rb +18 -0
  167. data/spec/wavefront-cli/output/json_spec.rb +3 -1
  168. data/spec/wavefront-cli/output/ruby_spec.rb +3 -1
  169. data/spec/wavefront-cli/output/wavefront/query_spec.rb +3 -1
  170. data/spec/wavefront-cli/output/wavefront_spec.rb +6 -4
  171. data/spec/wavefront-cli/output/yaml_spec.rb +3 -1
  172. data/spec/wavefront-cli/proxy_spec.rb +49 -27
  173. data/spec/wavefront-cli/query_spec.rb +174 -92
  174. data/spec/wavefront-cli/resources/responses/query.json +1 -0
  175. data/spec/wavefront-cli/resources/updates/alert.json +15 -0
  176. data/spec/wavefront-cli/resources/updates/dashboard.json +1 -0
  177. data/spec/wavefront-cli/savedsearch_spec.rb +35 -18
  178. data/spec/wavefront-cli/serviceaccount_spec.rb +399 -0
  179. data/spec/wavefront-cli/settings_spec.rb +42 -11
  180. data/spec/wavefront-cli/source_spec.rb +120 -23
  181. data/spec/wavefront-cli/stdlib/array_spec.rb +2 -1
  182. data/spec/wavefront-cli/stdlib/string_spec.rb +9 -6
  183. data/spec/wavefront-cli/user_spec.rb +278 -108
  184. data/spec/wavefront-cli/usergroup_spec.rb +152 -102
  185. data/spec/wavefront-cli/webhook_spec.rb +30 -15
  186. data/spec/wavefront-cli/write_spec.rb +25 -1
  187. data/wavefront-cli.gemspec +5 -3
  188. metadata +65 -21
  189. data/spec/wavefront-cli/commands/spec_helper.rb +0 -3
  190. data/spec/wavefront-cli/display/spec_helper.rb +0 -3
@@ -1,104 +1,154 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- uid1 = 'someone@somewhere.com'
4
- uid2 = 'other@elsewhere.com'
5
- name = 'testgroup'
6
- bad_id = '__BAD__'
7
- word = 'usergroup'
8
- gid1 = '2659191e-aad4-4302-a94e-9667e1517127'
9
- priv1 = 'alerts_management'
10
- priv2 = 'events_management'
11
-
12
- require_relative '../spec_helper'
13
- require_relative "../../lib/wavefront-cli/#{word}"
14
-
15
- k = WavefrontCli::UserGroup
16
-
17
- describe "#{word} command" do
18
- missing_creds(word, ['list',
19
- "describe #{gid1}",
20
- "create #{name}",
21
- "delete #{gid1}",
22
- 'import file',
23
- "set key=val #{gid1}",
24
- "users #{gid1}",
25
- "permissions #{gid1}",
26
- "add user #{gid1} #{uid1} #{uid2}",
27
- "remove user #{gid1} #{uid1} #{uid2}",
28
- "grant #{priv1} to #{gid1}",
29
- "revoke #{priv2} from #{gid1}",
30
- 'search key=value'])
31
-
32
- list_tests(word, 'usergroup', k)
33
-
34
- cmd_to_call(word, "describe #{gid1}",
35
- { path: "/api/v2/#{word}/#{gid1}" }, k)
36
-
37
- cmd_to_call(word, "create #{name}",
38
- { method: :post,
39
- path: "/api/v2/#{word}",
40
- body: { name: name, permissions: [] }.to_json }, k)
41
-
42
- cmd_to_call(word, "create -p #{priv1} -p #{priv2} #{name}",
43
- { method: :post,
44
- path: "/api/v2/#{word}",
45
- body: { name: name,
46
- permissions: [priv1, priv2] }.to_json }, k)
47
-
48
- cmd_to_call(word, "delete #{gid1}",
49
- { method: :delete, path: "/api/v2/#{word}/#{gid1}" }, k)
50
-
51
- cmd_to_call(word, "users #{gid1}",
52
- { path: "/api/v2/#{word}/#{gid1}" }, k)
53
-
54
- cmd_to_call(word, "permissions #{gid1}",
55
- { path: "/api/v2/#{word}/#{gid1}" }, k)
56
-
57
- cmd_to_call(word, "add user #{gid1} #{uid1}",
58
- { method: :post,
59
- path: "/api/v2/#{word}/#{gid1}/addUsers",
60
- body: [uid1].to_json }, k)
61
-
62
- cmd_to_call(word, "add user #{gid1} #{uid1} #{uid2}",
63
- { method: :post,
64
- path: "/api/v2/#{word}/#{gid1}/addUsers",
65
- body: [uid1, uid2].to_json }, k)
66
-
67
- cmd_to_call(word, "remove user #{gid1} #{uid1}",
68
- { method: :post,
69
- path: "/api/v2/#{word}/#{gid1}/removeUsers",
70
- body: [uid1].to_json }, k)
71
-
72
- cmd_to_call(word, "remove user #{gid1} #{uid1} #{uid2}",
73
- { method: :post,
74
- path: "/api/v2/#{word}/#{gid1}/removeUsers",
75
- body: [uid1, uid2].to_json }, k)
76
-
77
- cmd_to_call(word, "grant #{priv1} to #{gid1}",
78
- { method: :post,
79
- path: "/api/v2/#{word}/grant/#{priv1}",
80
- body: [gid1].to_json }, k)
81
-
82
- cmd_to_call(word, "revoke #{priv1} from #{gid1}",
83
- { method: :post,
84
- path: "/api/v2/#{word}/revoke/#{priv1}",
85
- body: [gid1].to_json }, k)
86
-
87
- search_tests(word, gid1, k)
88
-
89
- invalid_ids(word, ["describe #{bad_id}",
90
- "delete #{bad_id}",
91
- "set key=val #{bad_id}",
92
- "users #{bad_id}",
93
- "permissions #{bad_id}",
94
- "add user #{bad_id} #{uid1} #{uid2}",
95
- "remove user #{bad_id} #{uid1} #{uid2}",
96
- "grant #{priv1} to #{bad_id}",
97
- "revoke #{priv2} from #{bad_id}"])
98
-
99
- cmd_noop(word, 'list',
100
- ["GET https://metrics.wavefront.com/api/v2/#{word}"], k)
101
- cmd_noop(word, "describe #{gid1}",
102
- ["GET https://metrics.wavefront.com/api/v2/#{word}/#{gid1}"], k)
103
- test_list_output(word, k)
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../support/command_base'
5
+ require_relative '../../lib/wavefront-cli/usergroup'
6
+
7
+ # Ensure 'usergroup' commands produce the correct API calls.
8
+ #
9
+ class UserGroupEndToEndTest < EndToEndTest
10
+ include WavefrontCliTest::List
11
+ include WavefrontCliTest::Describe
12
+ include WavefrontCliTest::Dump
13
+ include WavefrontCliTest::Set
14
+ include WavefrontCliTest::Delete
15
+ include WavefrontCliTest::Search
16
+
17
+ def test_create
18
+ quietly do
19
+ assert_cmd_posts("create #{groupname}",
20
+ '/api/v2/usergroup',
21
+ name: groupname, permissions: [])
22
+ end
23
+
24
+ assert_abort_on_missing_creds("create #{groupname}")
25
+ assert_usage('create')
26
+ end
27
+
28
+ def test_create_with_privileges
29
+ quietly do
30
+ assert_cmd_posts("create -p #{privileges[0]} -p #{privileges[1]} " \
31
+ "#{groupname}",
32
+ '/api/v2/usergroup',
33
+ name: groupname, permissions: privileges)
34
+ end
35
+ end
36
+
37
+ def test_users
38
+ assert_repeated_output("No users in group '#{id}'.") do
39
+ assert_cmd_gets("users #{id}", "/api/v2/usergroup/#{id}")
40
+ end
41
+
42
+ assert_abort_on_missing_creds("users #{id}")
43
+ assert_invalid_id("users #{invalid_id}")
44
+ assert_usage('users')
45
+ end
46
+
47
+ def test_permissions
48
+ assert_repeated_output("Group '#{id}' has no permissions.") do
49
+ assert_cmd_gets("permissions #{id}", "/api/v2/usergroup/#{id}")
50
+ end
51
+
52
+ assert_abort_on_missing_creds("permissions #{id}")
53
+ assert_invalid_id("permissions #{invalid_id}")
54
+ assert_usage('permissions')
55
+ end
56
+
57
+ def test_add_user
58
+ assert_repeated_output("Added '#{users[0]}' to '#{id}'.") do
59
+ assert_cmd_posts("add user #{id} #{users[0]}",
60
+ "/api/v2/usergroup/#{id}/addUsers",
61
+ [users[0]].to_json)
62
+ end
63
+
64
+ assert_abort_on_missing_creds("add user #{id} #{users[0]}")
65
+ assert_invalid_id("add user #{invalid_id} #{users[0]}")
66
+ end
67
+
68
+ # assert_repeated_output can't cope with line wrapping, and suppressing it
69
+ # breaks other tests. Hence the `quietly` in the next three tests.
70
+ #
71
+ def test_add_multiple_users
72
+ quietly do
73
+ assert_cmd_posts("add user #{id} #{users[0]} #{users[1]}",
74
+ "/api/v2/usergroup/#{id}/addUsers",
75
+ users.to_json)
76
+ end
77
+ end
78
+
79
+ def test_remove_user
80
+ quietly do
81
+ assert_cmd_posts("remove user #{id} #{users[0]}",
82
+ "/api/v2/usergroup/#{id}/removeUsers",
83
+ [users[0]].to_json)
84
+ end
85
+
86
+ assert_abort_on_missing_creds("remove user #{id} #{users[0]}")
87
+ assert_invalid_id("remove user #{invalid_id} #{users[0]}")
88
+ end
89
+
90
+ def test_remove_multiple_users
91
+ quietly do
92
+ assert_cmd_posts("remove user #{id} #{users[0]} #{users[1]}",
93
+ "/api/v2/usergroup/#{id}/removeUsers",
94
+ users.to_json)
95
+ end
96
+ end
97
+
98
+ def test_grant
99
+ assert_repeated_output(
100
+ "Granted '#{privileges[1]}' permission to '#{id}'."
101
+ ) do
102
+ assert_cmd_posts("grant #{privileges[1]} to #{id}",
103
+ "/api/v2/usergroup/grant/#{privileges[1]}",
104
+ [id].to_json)
105
+ end
106
+
107
+ assert_abort_on_missing_creds("grant #{privileges[1]} to #{id}")
108
+ assert_invalid_id("grant #{privileges[1]} to #{invalid_id}")
109
+ end
110
+
111
+ def test_revoke
112
+ assert_repeated_output(
113
+ "Revoked '#{privileges[0]}' permission from '#{id}'."
114
+ ) do
115
+ assert_cmd_posts("revoke #{privileges[0]} from #{id}",
116
+ "/api/v2/usergroup/revoke/#{privileges[0]}",
117
+ [id].to_json)
118
+ end
119
+ end
120
+
121
+ private
122
+
123
+ def id
124
+ '2659191e-aad4-4302-a94e-9667e1517127'
125
+ end
126
+
127
+ def invalid_id
128
+ '__BAD__'
129
+ end
130
+
131
+ def cmd_word
132
+ 'usergroup'
133
+ end
134
+
135
+ def sdk_class_name
136
+ 'UserGroup'
137
+ end
138
+
139
+ def friendly_name
140
+ 'user group'
141
+ end
142
+
143
+ def groupname
144
+ 'testgroup'
145
+ end
146
+
147
+ def privileges
148
+ %w[alerts_management events_management]
149
+ end
150
+
151
+ def users
152
+ %w[someone@somewhere.com other@elsewhere.com]
153
+ end
104
154
  end
@@ -1,20 +1,35 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- id = '9095WaGklE8Gy3M1'
4
- bad_id = '__BAD__'
5
- word = 'webhook'
4
+ require_relative '../support/command_base'
5
+ require_relative '../../lib/wavefront-cli/webhook'
6
6
 
7
- require_relative '../spec_helper'
8
- require_relative "../../lib/wavefront-cli/#{word}"
7
+ # Ensure 'webhook' commands produce the correct API calls.
8
+ #
9
+ class WebhookEndToEndTest < EndToEndTest
10
+ include WavefrontCliTest::Delete
11
+ include WavefrontCliTest::Describe
12
+ include WavefrontCliTest::Dump
13
+ # include WavefrontCliTest::Import
14
+ include WavefrontCliTest::List
15
+ include WavefrontCliTest::Search
16
+ include WavefrontCliTest::Set
9
17
 
10
- describe "#{word} command" do
11
- missing_creds(word, ['list', "describe #{id}", "delete #{id}"])
12
- list_tests(word)
13
- noop_tests(word, id)
14
- cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
15
- cmd_to_call(word, "delete #{id}", method: :delete,
16
- path: "/api/v2/#{word}/#{id}")
17
- invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}"])
18
- search_tests(word, id)
19
- test_list_output(word)
18
+ private
19
+
20
+ def id
21
+ '9095WaGklE8Gy3M1'
22
+ end
23
+
24
+ def invalid_id
25
+ '__BAD__'
26
+ end
27
+
28
+ def cmd_word
29
+ 'webhook'
30
+ end
31
+
32
+ def set_key
33
+ 'title'
34
+ end
20
35
  end
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require_relative '../spec_helper'
4
+ require 'minitest/autorun'
4
5
  require_relative '../../lib/wavefront-cli/write'
5
6
 
6
7
  # Test base writer
@@ -101,30 +102,53 @@ class WavefrontCliWriteTest < MiniTest::Test
101
102
  %w[v mv vm tmv mtv mvT msvT tmvT].each do |str|
102
103
  assert wf.valid_format?(str)
103
104
  end
105
+ end
104
106
 
107
+ def test_invalid_format_v_and_d
105
108
  e = assert_raises('WavefrontCli::Exception::UnparseableInput') do
106
109
  wf.valid_format?('mvd')
107
110
  end
111
+
108
112
  assert_equal("'v' and 'd' are mutually exclusive", e.message)
113
+ end
109
114
 
115
+ def test_invalid_format_no_v_or_d
110
116
  e = assert_raises('WavefrontCli::Exception::UnparseableInput') do
111
117
  wf.valid_format?('mtT')
112
118
  end
119
+
113
120
  assert_equal("format string must include 'v' or 'd'", e.message)
121
+ end
114
122
 
123
+ def test_invalid_format_invalid_char
115
124
  e = assert_raises('WavefrontCli::Exception::UnparseableInput') do
116
125
  wf.valid_format?('mxvT')
117
126
  end
127
+
118
128
  assert_equal('unsupported field in format string', e.message)
129
+ end
119
130
 
131
+ def test_invalid_format_repeated_char
120
132
  e = assert_raises('WavefrontCli::Exception::UnparseableInput') do
121
133
  wf.valid_format?('mvvT')
122
134
  end
135
+
136
+ assert_equal('repeated field in format string', e.message)
137
+ end
138
+
139
+ def test_invalid_format_duplicated_char
140
+ e = assert_raises('WavefrontCli::Exception::UnparseableInput') do
141
+ wf.valid_format?('vmvTv')
142
+ end
143
+
123
144
  assert_equal('repeated field in format string', e.message)
145
+ end
124
146
 
147
+ def test_invalid_format_big_t_in_middle
125
148
  e = assert_raises('WavefrontCli::Exception::UnparseableInput') do
126
149
  wf.valid_format?('mTv')
127
150
  end
151
+
128
152
  assert_equal("if used, 'T' must come at end of format string",
129
153
  e.message)
130
154
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
  require 'date'
3
5
 
@@ -24,13 +26,13 @@ Gem::Specification.new do |gem|
24
26
 
25
27
  gem.add_runtime_dependency 'docopt', '~> 0.6.0'
26
28
  gem.add_runtime_dependency 'inifile', '~> 3.0'
27
- gem.add_runtime_dependency 'wavefront-sdk', '~> 3.3', '>= 3.3.2'
29
+ gem.add_runtime_dependency 'wavefront-sdk', '~> 3.5', '>= 3.5.0'
28
30
 
29
31
  gem.add_development_dependency 'minitest', '~> 5.11', '>= 5.11.0'
30
32
  gem.add_development_dependency 'rake', '~> 12.0'
31
- gem.add_development_dependency 'rubocop', '~> 0.54.0'
33
+ gem.add_development_dependency 'rubocop', '~> 0.74.0'
32
34
  gem.add_development_dependency 'spy', '~> 1.0.0'
33
- gem.add_development_dependency 'webmock', '~> 3.5'
35
+ gem.add_development_dependency 'webmock', '~> 3.7'
34
36
  gem.add_development_dependency 'yard', '~> 0.9.5'
35
37
 
36
38
  gem.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-26 00:00:00.000000000 Z
11
+ date: 2019-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -44,40 +44,40 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.3'
47
+ version: '3.5'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 3.3.2
50
+ version: 3.5.0
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '3.3'
57
+ version: '3.5'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 3.3.2
60
+ version: 3.5.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: minitest
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 5.11.0
68
65
  - - "~>"
69
66
  - !ruby/object:Gem::Version
70
67
  version: '5.11'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 5.11.0
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: 5.11.0
78
75
  - - "~>"
79
76
  - !ruby/object:Gem::Version
80
77
  version: '5.11'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 5.11.0
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rake
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -98,14 +98,14 @@ dependencies:
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: 0.54.0
101
+ version: 0.74.0
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: 0.54.0
108
+ version: 0.74.0
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: spy
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -126,14 +126,14 @@ dependencies:
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '3.5'
129
+ version: '3.7'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '3.5'
136
+ version: '3.7'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: yard
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -188,6 +188,7 @@ files:
188
188
  - lib/wavefront-cli/commands/proxy.rb
189
189
  - lib/wavefront-cli/commands/query.rb
190
190
  - lib/wavefront-cli/commands/savedsearch.rb
191
+ - lib/wavefront-cli/commands/serviceaccount.rb
191
192
  - lib/wavefront-cli/commands/settings.rb
192
193
  - lib/wavefront-cli/commands/source.rb
193
194
  - lib/wavefront-cli/commands/user.rb
@@ -220,6 +221,7 @@ files:
220
221
  - lib/wavefront-cli/display/proxy.rb
221
222
  - lib/wavefront-cli/display/query.rb
222
223
  - lib/wavefront-cli/display/savedsearch.rb
224
+ - lib/wavefront-cli/display/serviceaccount.rb
223
225
  - lib/wavefront-cli/display/settings.rb
224
226
  - lib/wavefront-cli/display/source.rb
225
227
  - lib/wavefront-cli/display/user.rb
@@ -254,6 +256,7 @@ files:
254
256
  - lib/wavefront-cli/proxy.rb
255
257
  - lib/wavefront-cli/query.rb
256
258
  - lib/wavefront-cli/savedsearch.rb
259
+ - lib/wavefront-cli/serviceaccount.rb
257
260
  - lib/wavefront-cli/settings.rb
258
261
  - lib/wavefront-cli/source.rb
259
262
  - lib/wavefront-cli/stdlib/array.rb
@@ -264,7 +267,24 @@ files:
264
267
  - lib/wavefront-cli/webhook.rb
265
268
  - lib/wavefront-cli/write.rb
266
269
  - spec/.rubocop.yml
270
+ - spec/constants.rb
267
271
  - spec/spec_helper.rb
272
+ - spec/support/command_base.rb
273
+ - spec/support/minitest_assertions.rb
274
+ - spec/support/output_tester.rb
275
+ - spec/support/supported_commands.rb
276
+ - spec/test_mixins/acl.rb
277
+ - spec/test_mixins/delete.rb
278
+ - spec/test_mixins/deleteundelete.rb
279
+ - spec/test_mixins/describe.rb
280
+ - spec/test_mixins/dump.rb
281
+ - spec/test_mixins/general.rb
282
+ - spec/test_mixins/history.rb
283
+ - spec/test_mixins/import.rb
284
+ - spec/test_mixins/list.rb
285
+ - spec/test_mixins/search.rb
286
+ - spec/test_mixins/set.rb
287
+ - spec/test_mixins/tag.rb
268
288
  - spec/wavefront-cli/alert_spec.rb
269
289
  - spec/wavefront-cli/apitoken_spec.rb
270
290
  - spec/wavefront-cli/base_spec.rb
@@ -281,7 +301,6 @@ files:
281
301
  - spec/wavefront-cli/commands/metric_spec.rb
282
302
  - spec/wavefront-cli/commands/proxy_spec.rb
283
303
  - spec/wavefront-cli/commands/query_spec.rb
284
- - spec/wavefront-cli/commands/spec_helper.rb
285
304
  - spec/wavefront-cli/commands/webhook_spec.rb
286
305
  - spec/wavefront-cli/commands/window_spec.rb
287
306
  - spec/wavefront-cli/commands/write_spec.rb
@@ -292,7 +311,6 @@ files:
292
311
  - spec/wavefront-cli/display/base_spec.rb
293
312
  - spec/wavefront-cli/display/printer/long_spec.rb
294
313
  - spec/wavefront-cli/display/printer/terse_spec.rb
295
- - spec/wavefront-cli/display/spec_helper.rb
296
314
  - spec/wavefront-cli/event_spec.rb
297
315
  - spec/wavefront-cli/externallink_spec.rb
298
316
  - spec/wavefront-cli/integration_spec.rb
@@ -304,6 +322,7 @@ files:
304
322
  - spec/wavefront-cli/output/csv/query_spec.rb
305
323
  - spec/wavefront-cli/output/csv_spec.rb
306
324
  - spec/wavefront-cli/output/hcl_spec.rb
325
+ - spec/wavefront-cli/output/helpers.rb
307
326
  - spec/wavefront-cli/output/json_spec.rb
308
327
  - spec/wavefront-cli/output/ruby_spec.rb
309
328
  - spec/wavefront-cli/output/wavefront/query_spec.rb
@@ -336,6 +355,7 @@ files:
336
355
  - spec/wavefront-cli/resources/responses/notificant-list.json
337
356
  - spec/wavefront-cli/resources/responses/proxy-list.json
338
357
  - spec/wavefront-cli/resources/responses/query-cpu.json
358
+ - spec/wavefront-cli/resources/responses/query.json
339
359
  - spec/wavefront-cli/resources/responses/savedsearch-list.json
340
360
  - spec/wavefront-cli/resources/responses/user-list.json
341
361
  - spec/wavefront-cli/resources/responses/usergroup-list.json
@@ -343,8 +363,11 @@ files:
343
363
  - spec/wavefront-cli/resources/responses/window-list.json
344
364
  - spec/wavefront-cli/resources/sample_query_response.json
345
365
  - spec/wavefront-cli/resources/sample_raw_query_response.json
366
+ - spec/wavefront-cli/resources/updates/alert.json
367
+ - spec/wavefront-cli/resources/updates/dashboard.json
346
368
  - spec/wavefront-cli/resources/wavefront.conf
347
369
  - spec/wavefront-cli/savedsearch_spec.rb
370
+ - spec/wavefront-cli/serviceaccount_spec.rb
348
371
  - spec/wavefront-cli/settings_spec.rb
349
372
  - spec/wavefront-cli/source_spec.rb
350
373
  - spec/wavefront-cli/stdlib/array_spec.rb
@@ -373,13 +396,31 @@ required_rubygems_version: !ruby/object:Gem::Requirement
373
396
  - !ruby/object:Gem::Version
374
397
  version: '0'
375
398
  requirements: []
376
- rubygems_version: 3.0.4
399
+ rubyforge_project:
400
+ rubygems_version: 2.7.7
377
401
  signing_key:
378
402
  specification_version: 4
379
403
  summary: CLI for Wavefront API v2
380
404
  test_files:
381
405
  - spec/.rubocop.yml
406
+ - spec/constants.rb
382
407
  - spec/spec_helper.rb
408
+ - spec/support/command_base.rb
409
+ - spec/support/minitest_assertions.rb
410
+ - spec/support/output_tester.rb
411
+ - spec/support/supported_commands.rb
412
+ - spec/test_mixins/acl.rb
413
+ - spec/test_mixins/delete.rb
414
+ - spec/test_mixins/deleteundelete.rb
415
+ - spec/test_mixins/describe.rb
416
+ - spec/test_mixins/dump.rb
417
+ - spec/test_mixins/general.rb
418
+ - spec/test_mixins/history.rb
419
+ - spec/test_mixins/import.rb
420
+ - spec/test_mixins/list.rb
421
+ - spec/test_mixins/search.rb
422
+ - spec/test_mixins/set.rb
423
+ - spec/test_mixins/tag.rb
383
424
  - spec/wavefront-cli/alert_spec.rb
384
425
  - spec/wavefront-cli/apitoken_spec.rb
385
426
  - spec/wavefront-cli/base_spec.rb
@@ -396,7 +437,6 @@ test_files:
396
437
  - spec/wavefront-cli/commands/metric_spec.rb
397
438
  - spec/wavefront-cli/commands/proxy_spec.rb
398
439
  - spec/wavefront-cli/commands/query_spec.rb
399
- - spec/wavefront-cli/commands/spec_helper.rb
400
440
  - spec/wavefront-cli/commands/webhook_spec.rb
401
441
  - spec/wavefront-cli/commands/window_spec.rb
402
442
  - spec/wavefront-cli/commands/write_spec.rb
@@ -407,7 +447,6 @@ test_files:
407
447
  - spec/wavefront-cli/display/base_spec.rb
408
448
  - spec/wavefront-cli/display/printer/long_spec.rb
409
449
  - spec/wavefront-cli/display/printer/terse_spec.rb
410
- - spec/wavefront-cli/display/spec_helper.rb
411
450
  - spec/wavefront-cli/event_spec.rb
412
451
  - spec/wavefront-cli/externallink_spec.rb
413
452
  - spec/wavefront-cli/integration_spec.rb
@@ -419,6 +458,7 @@ test_files:
419
458
  - spec/wavefront-cli/output/csv/query_spec.rb
420
459
  - spec/wavefront-cli/output/csv_spec.rb
421
460
  - spec/wavefront-cli/output/hcl_spec.rb
461
+ - spec/wavefront-cli/output/helpers.rb
422
462
  - spec/wavefront-cli/output/json_spec.rb
423
463
  - spec/wavefront-cli/output/ruby_spec.rb
424
464
  - spec/wavefront-cli/output/wavefront/query_spec.rb
@@ -451,6 +491,7 @@ test_files:
451
491
  - spec/wavefront-cli/resources/responses/notificant-list.json
452
492
  - spec/wavefront-cli/resources/responses/proxy-list.json
453
493
  - spec/wavefront-cli/resources/responses/query-cpu.json
494
+ - spec/wavefront-cli/resources/responses/query.json
454
495
  - spec/wavefront-cli/resources/responses/savedsearch-list.json
455
496
  - spec/wavefront-cli/resources/responses/user-list.json
456
497
  - spec/wavefront-cli/resources/responses/usergroup-list.json
@@ -458,8 +499,11 @@ test_files:
458
499
  - spec/wavefront-cli/resources/responses/window-list.json
459
500
  - spec/wavefront-cli/resources/sample_query_response.json
460
501
  - spec/wavefront-cli/resources/sample_raw_query_response.json
502
+ - spec/wavefront-cli/resources/updates/alert.json
503
+ - spec/wavefront-cli/resources/updates/dashboard.json
461
504
  - spec/wavefront-cli/resources/wavefront.conf
462
505
  - spec/wavefront-cli/savedsearch_spec.rb
506
+ - spec/wavefront-cli/serviceaccount_spec.rb
463
507
  - spec/wavefront-cli/settings_spec.rb
464
508
  - spec/wavefront-cli/source_spec.rb
465
509
  - spec/wavefront-cli/stdlib/array_spec.rb