wavefront-sdk 3.7.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +43 -2
  3. data/.travis.yml +0 -1
  4. data/HISTORY.md +33 -0
  5. data/README.md +4 -3
  6. data/lib/wavefront-sdk/account.rb +104 -3
  7. data/lib/wavefront-sdk/api_mixins/user.rb +10 -0
  8. data/lib/wavefront-sdk/cloudintegration.rb +27 -0
  9. data/lib/wavefront-sdk/core/api_caller.rb +50 -7
  10. data/lib/wavefront-sdk/core/exception.rb +6 -0
  11. data/lib/wavefront-sdk/credentials.rb +28 -9
  12. data/lib/wavefront-sdk/defs/version.rb +1 -3
  13. data/lib/wavefront-sdk/paginator/base.rb +21 -15
  14. data/lib/wavefront-sdk/query.rb +0 -1
  15. data/lib/wavefront-sdk/role.rb +128 -0
  16. data/lib/wavefront-sdk/spy.rb +126 -0
  17. data/lib/wavefront-sdk/stdlib/array.rb +1 -1
  18. data/lib/wavefront-sdk/stdlib/time.rb +13 -0
  19. data/lib/wavefront-sdk/unstable/README.md +4 -0
  20. data/lib/wavefront-sdk/unstable/chart.rb +90 -0
  21. data/lib/wavefront-sdk/unstable/unstable.rb +9 -0
  22. data/lib/wavefront-sdk/user.rb +31 -0
  23. data/lib/wavefront-sdk/usergroup.rb +17 -16
  24. data/lib/wavefront-sdk/validators.rb +52 -7
  25. data/lib/wavefront-sdk/write.rb +9 -9
  26. data/spec/.rubocop.yml +41 -0
  27. data/spec/spec_helper.rb +4 -0
  28. data/spec/support/minitest_assertions.rb +4 -4
  29. data/spec/wavefront-sdk/account_spec.rb +107 -1
  30. data/spec/wavefront-sdk/cloudintegration_spec.rb +38 -0
  31. data/spec/wavefront-sdk/core/api_caller_spec.rb +43 -0
  32. data/spec/wavefront-sdk/credentials_spec.rb +3 -4
  33. data/spec/wavefront-sdk/metric_helper_spec.rb +1 -1
  34. data/spec/wavefront-sdk/role_spec.rb +96 -0
  35. data/spec/wavefront-sdk/spy_spec.rb +113 -0
  36. data/spec/wavefront-sdk/unstable/chart_spec.rb +39 -0
  37. data/spec/wavefront-sdk/user_spec.rb +8 -0
  38. data/spec/wavefront-sdk/usergroup_spec.rb +21 -11
  39. data/spec/wavefront-sdk/validators_spec.rb +31 -0
  40. data/wavefront-sdk.gemspec +8 -8
  41. metadata +32 -21
@@ -4,16 +4,33 @@ require_relative 'core/api'
4
4
  require_relative 'api_mixins/user'
5
5
 
6
6
  module Wavefront
7
+ #
8
+ # In line with the API changes in the 2020-06 release of Wavefront, this
9
+ # class has been deprecated.
10
+ #
11
+ # Please use Wavefront::Account to manage users.
12
+ #
13
+ # https://docs.wavefront.com/2020.06.x_release_notes.html
7
14
  #
8
15
  # Manage and query Wavefront users
9
16
  #
10
17
  class User < CoreApi
11
18
  include Wavefront::Mixin::User
12
19
 
20
+ def deprecation_warning
21
+ logger.log('Wavefront::User is deprecated and will be removed from the ' \
22
+ 'next major release. Please use Wavefront::Account.', :warn)
23
+ end
24
+
25
+ def post_initialize(_creds, _opts)
26
+ deprecation_warning
27
+ end
28
+
13
29
  # GET /api/v2/user
14
30
  # Get all users.
15
31
  #
16
32
  def list
33
+ deprecation_warning
17
34
  api.get('')
18
35
  end
19
36
 
@@ -26,6 +43,7 @@ module Wavefront
26
43
  # @return [Wavefront::Response]
27
44
  #
28
45
  def create(body, send_email = false)
46
+ deprecation_warning
29
47
  raise ArgumentError unless body.is_a?(Hash)
30
48
 
31
49
  api.post("?sendEmail=#{send_email}", body, 'application/json')
@@ -38,6 +56,7 @@ module Wavefront
38
56
  # @return [Wavefront::Response]
39
57
  #
40
58
  def delete(id)
59
+ deprecation_warning
41
60
  wf_user_id?(id)
42
61
  api.delete(id)
43
62
  end
@@ -49,6 +68,7 @@ module Wavefront
49
68
  # @return [Wavefront::Response]
50
69
  #
51
70
  def describe(id)
71
+ deprecation_warning
52
72
  wf_user_id?(id)
53
73
  api.get(id)
54
74
  end
@@ -65,6 +85,7 @@ module Wavefront
65
85
  # @return [Wavefront::Response]
66
86
 
67
87
  def update(id, body, modify = true)
88
+ deprecation_warning
68
89
  wf_user_id?(id)
69
90
  raise ArgumentError unless body.is_a?(Hash)
70
91
 
@@ -82,6 +103,7 @@ module Wavefront
82
103
  # @return [Wavefront::Response]
83
104
  #
84
105
  def add_groups_to_user(id, group_list = [])
106
+ deprecation_warning
85
107
  wf_user_id?(id)
86
108
  validate_usergroup_list(group_list)
87
109
  api.post([id, 'addUserGroups'].uri_concat, group_list,
@@ -95,6 +117,7 @@ module Wavefront
95
117
  # @return [Wavefront::Response]
96
118
  #
97
119
  def remove_groups_from_user(id, group_list = [])
120
+ deprecation_warning
98
121
  wf_user_id?(id)
99
122
  validate_usergroup_list(group_list)
100
123
  api.post([id, 'removeUserGroups'].uri_concat, group_list,
@@ -116,6 +139,7 @@ module Wavefront
116
139
  # @return [Wavefront::Response]
117
140
  #
118
141
  def grant(id, pgroup)
142
+ deprecation_warning
119
143
  wf_user_id?(id)
120
144
  raise ArgumentError unless pgroup.is_a?(String)
121
145
 
@@ -133,6 +157,7 @@ module Wavefront
133
157
  # @return [Wavefront::Response]
134
158
  #
135
159
  def revoke(id, pgroup)
160
+ deprecation_warning
136
161
  wf_user_id?(id)
137
162
  raise ArgumentError unless pgroup.is_a?(String)
138
163
 
@@ -149,6 +174,7 @@ module Wavefront
149
174
  # @return [Wavefront::Response]
150
175
  #
151
176
  def delete_users(user_list)
177
+ deprecation_warning
152
178
  raise ArgumentError unless user_list.is_a?(Array)
153
179
 
154
180
  validate_user_list(user_list)
@@ -165,6 +191,7 @@ module Wavefront
165
191
  # @return [Wavefront::Response]
166
192
  #
167
193
  def grant_permission(permission, user_list)
194
+ deprecation_warning
168
195
  raise ArgumentError unless user_list.is_a?(Array)
169
196
 
170
197
  validate_user_list(user_list)
@@ -182,6 +209,7 @@ module Wavefront
182
209
  # @return [Wavefront::Response]
183
210
  #
184
211
  def revoke_permission(permission, user_list)
212
+ deprecation_warning
185
213
  raise ArgumentError unless user_list.is_a?(Array)
186
214
 
187
215
  validate_user_list(user_list)
@@ -196,6 +224,7 @@ module Wavefront
196
224
  # @return [Wavefront::Response]
197
225
  #
198
226
  def invite(body)
227
+ deprecation_warning
199
228
  raise ArgumentError unless body.is_a?(Array)
200
229
  raise ArgumentError unless body.first.is_a?(Hash)
201
230
 
@@ -208,6 +237,7 @@ module Wavefront
208
237
  # @return [Wavefront::Response]
209
238
  #
210
239
  def business_functions(id)
240
+ deprecation_warning
211
241
  wf_user_id?(id)
212
242
  api.get([id, 'businessFunctions'].uri_concat)
213
243
  end
@@ -219,6 +249,7 @@ module Wavefront
219
249
  # @return [Wavefront::Response]
220
250
  #
221
251
  def validate_users(id_list)
252
+ deprecation_warning
222
253
  api.post('validateUsers', id_list, 'application/json')
223
254
  end
224
255
 
@@ -108,30 +108,31 @@ module Wavefront
108
108
  'application/json')
109
109
  end
110
110
 
111
- # POST /api/v2/usergroup/grant/{permission}
112
- # Grants a single permission to user group(s)
111
+ # POST /api/v2/usergroup/{id}/addRoles
112
+ # Add multiple roles to a specific user group
113
113
  #
114
- # @param perm [String] permission to grant
115
- # @param group_list [Array[String]] list of groups who should
116
- # receive permission
114
+ # @param id [String] ID of the user group
115
+ # @param role_list [Array[String]] list of roles to add
117
116
  # @return [Wavefront::Response]
118
117
  #
119
- def grant(perm, group_list = [])
120
- validate_usergroup_list(group_list)
121
- api.post(['grant', perm].uri_concat, group_list, 'application/json')
118
+ def add_roles_to_group(id, role_list = [])
119
+ wf_usergroup_id?(id)
120
+ validate_role_list(role_list)
121
+ api.post([id, 'addRoles'].uri_concat, role_list, 'application/json')
122
122
  end
123
123
 
124
- # POST /api/v2/usergroup/revoke/{permission}
125
- # Revokes a single permission from user group(s)
124
+ # POST /api/v2/usergroup/{id}/removeRoles
125
+ # Remove multiple roles from a specific user group
126
126
  #
127
- # @param perm [String] permission to revoke
128
- # @param group_list [Array[String]] list of groups who should
129
- # lose permission
127
+ # @param id [String] ID of the user group
128
+ # @param user_list [Array[String]] list of roles to remove
130
129
  # @return [Wavefront::Response]
131
130
  #
132
- def revoke(perm, group_list = [])
133
- validate_usergroup_list(group_list)
134
- api.post(['revoke', perm].uri_concat, group_list, 'application/json')
131
+ def remove_roles_from_group(id, role_list = [])
132
+ wf_usergroup_id?(id)
133
+ validate_role_list(role_list)
134
+ api.post([id, 'removeRoles'].uri_concat, role_list,
135
+ 'application/json')
135
136
  end
136
137
  end
137
138
  end
@@ -48,8 +48,8 @@ module Wavefront
48
48
  #
49
49
  def wf_metric_name?(metric)
50
50
  if metric.is_a?(String) && metric.size < 1024 &&
51
- (metric.match(/^#{DELTA}?[\w\-\.]+$/) ||
52
- metric.match(%r{^\"#{DELTA}?[\w\-\.\/,]+\"$}))
51
+ (metric.match(/^#{DELTA}?[\w\-.]+$/) ||
52
+ metric.match(%r{^"#{DELTA}?[\w\-./,]+"$}))
53
53
  return true
54
54
  end
55
55
 
@@ -81,7 +81,7 @@ module Wavefront
81
81
  # commas in tags and descriptions. This might be too restrictive,
82
82
  # but if it is, this is the only place we need to change it.
83
83
  #
84
- if str.is_a?(String) && str.size < 1024 && str =~ /^[\-\w \.,]*$/
84
+ if str.is_a?(String) && str.size < 1024 && str =~ /^[\-\w .,]*$/
85
85
  return true
86
86
  end
87
87
 
@@ -139,7 +139,7 @@ module Wavefront
139
139
  #
140
140
  def wf_tag?(*tags)
141
141
  Array(*tags).each do |tag|
142
- unless tag.is_a?(String) && tag.size < 255 && tag =~ /^[\w:\-\.]+$/
142
+ unless tag.is_a?(String) && tag.size < 255 && tag =~ /^[\w:\-.]+$/
143
143
  raise Wavefront::Exception::InvalidTag, tag
144
144
  end
145
145
  end
@@ -196,7 +196,7 @@ module Wavefront
196
196
  #
197
197
  def wf_point_tag?(key, val)
198
198
  if key && val && (key.size + val.size < 254) &&
199
- key =~ /^[\w\-\.:]+$/ && val !~ /\\$/
199
+ key =~ /^[\w\-.:]+$/ && val !~ /\\$/
200
200
  return
201
201
  end
202
202
 
@@ -391,7 +391,7 @@ module Wavefront
391
391
  # is not valid
392
392
  #
393
393
  def wf_source_id?(source)
394
- if source.is_a?(String) && source.match(/^[\w\.\-]+$/) &&
394
+ if source.is_a?(String) && source.match(/^[\w.\-]+$/) &&
395
395
  source.size < 1024
396
396
  return true
397
397
  end
@@ -566,7 +566,7 @@ module Wavefront
566
566
  return true
567
567
  end
568
568
 
569
- raise Wavefront::Exception::InvalidPermission, id, id
569
+ raise Wavefront::Exception::InvalidPermission, id
570
570
  end
571
571
 
572
572
  # Ensure the given argument is a valid ingestion policy ID
@@ -594,6 +594,51 @@ module Wavefront
594
594
  raise Wavefront::Exception::InvalidAccountId, id
595
595
  end
596
596
  end
597
+
598
+ # Ensure the given argument is a valid monitored cluster ID
599
+ # @param id [String]
600
+ # @raise Wavefront::Exception::InvalidMonitoredClusterId if the ID is not
601
+ # valid
602
+ #
603
+ def wf_monitoredcluster_id?(id)
604
+ return true if id.is_a?(String) && id.size < 256 && id =~ /^[a-z0-9\-_]+$/
605
+
606
+ raise Wavefront::Exception::InvalidMonitoredClusterId, id
607
+ end
608
+
609
+ # Ensure the given value is a valid sampling rate.
610
+ # @param rate [Float]
611
+ # @raise Wavefront::Exception::InvalidSamplingValue
612
+ #
613
+ def wf_sampling_value?(value)
614
+ return true if value.is_a?(Numeric) && value.between?(0, 0.05)
615
+
616
+ raise Wavefront::Exception::InvalidSamplingValue, value
617
+ end
618
+
619
+ # Ensure the given argument is a valid Wavefront role ID
620
+ # @param id [String] the role ID to validate
621
+ # @return true if the role ID is valid
622
+ # @raise Wavefront::Exception::InvalidRoleId if the role ID is not valid
623
+ #
624
+ def wf_role_id?(id)
625
+ return true if uuid?(id)
626
+
627
+ raise Wavefront::Exception::InvalidRoleId, id
628
+ end
629
+
630
+ # Ensure the given argument is a valid AWS external ID, used in the AWS
631
+ # cloud integration.
632
+ # @param id [String] the external ID to validate
633
+ # @return true if the external ID is valid
634
+ # @raise Wavefront::Exception::InvalidAwsExternalId if the external ID is
635
+ # not valid
636
+ #
637
+ def wf_aws_external_id?(id)
638
+ return true if id.is_a?(String) && id =~ /^[a-z0-9A-Z]{16}$/
639
+
640
+ raise Wavefront::Exception::InvalidAwsExternalId, id
641
+ end
597
642
  end
598
643
  # rubocop:enable Metrics/ModuleLength
599
644
  end
@@ -113,7 +113,7 @@ module Wavefront
113
113
  # @return Wavefront::Response
114
114
  #
115
115
  def composite_response(responses)
116
- result, code = response_codes(responses)
116
+ result, code = response_results(responses)
117
117
 
118
118
  summary = { sent: 0, rejected: 0, unsent: 0 }
119
119
 
@@ -127,6 +127,14 @@ module Wavefront
127
127
  )
128
128
  end
129
129
 
130
+ def response_results(responses)
131
+ if responses.all?(&:ok?)
132
+ ['OK', 200]
133
+ else
134
+ ['ERROR', 400]
135
+ end
136
+ end
137
+
130
138
  def manage_conn
131
139
  opts[:noauto] ? false : true
132
140
  end
@@ -248,13 +256,5 @@ module Wavefront
248
256
  rescue LoadError
249
257
  raise(Wavefront::Exception::UnsupportedWriter, writer)
250
258
  end
251
-
252
- def response_codes(responses)
253
- if responses.all?(&:ok?)
254
- ['OK', 200]
255
- else
256
- ['ERROR', 400]
257
- end
258
- end
259
259
  end
260
260
  end
@@ -11,3 +11,44 @@ Metrics/ClassLength:
11
11
  # Configuration parameters: CountComments, ExcludedMethods.
12
12
  Metrics/MethodLength:
13
13
  Max: 39
14
+
15
+ # New cops
16
+ #
17
+ Lint/RaiseException:
18
+ Enabled: true
19
+ Lint/StructNewOverride:
20
+ Enabled: true
21
+ Style/ExponentialNotation:
22
+ Enabled: true
23
+ Style/HashEachMethods:
24
+ Enabled: true
25
+ Style/HashTransformKeys:
26
+ Enabled: true
27
+ Style/HashTransformValues:
28
+ Enabled: true
29
+ Layout/EmptyLinesAroundAttributeAccessor:
30
+ Enabled: true
31
+ Layout/SpaceAroundMethodCallOperator:
32
+ Enabled: true
33
+ Style/SlicingWithRange:
34
+ Enabled: true
35
+ Lint/DeprecatedOpenSSLConstant:
36
+ Enabled: true
37
+ Lint/MixedRegexpCaptureTypes:
38
+ Enabled: true
39
+ Style/RedundantRegexpCharacterClass:
40
+ Enabled: true
41
+ Style/RedundantRegexpEscape:
42
+ Enabled: true
43
+ Style/AccessorGrouping:
44
+ Enabled: true
45
+ Style/BisectedAttrAccessor:
46
+ Enabled: true
47
+ Style/RedundantAssignment:
48
+ Enabled: true
49
+ Style/RedundantFetchBlock:
50
+ Enabled: true
51
+
52
+ # Is nothing sacred?
53
+ Layout/LineLength:
54
+ Max: 80
@@ -23,6 +23,10 @@ class WavefrontTestBase < MiniTest::Test
23
23
  "../lib/wavefront-sdk/#{class_basename.downcase}"
24
24
  end
25
25
 
26
+ def dummy_response
27
+ DUMMY_RESPONSE
28
+ end
29
+
26
30
  private
27
31
 
28
32
  def setup
@@ -20,7 +20,7 @@ module Minitest
20
20
  headers = DEFAULT_HEADERS
21
21
  stub_request(:get, uri(api_path))
22
22
  .with(headers: headers)
23
- .to_return(body: DUMMY_RESPONSE, status: 200)
23
+ .to_return(body: dummy_response, status: 200)
24
24
  yield block
25
25
  assert_requested(:get, uri(api_path), headers: headers)
26
26
  WebMock.reset!
@@ -39,7 +39,7 @@ module Minitest
39
39
  payload = 'null' if payload.nil?
40
40
  stub_request(:post, uri(api_path))
41
41
  .with(body: payload, headers: headers)
42
- .to_return(body: DUMMY_RESPONSE, status: 200)
42
+ .to_return(body: dummy_response, status: 200)
43
43
  yield block
44
44
  assert_requested(:post, uri(api_path), headers: headers)
45
45
  WebMock.reset!
@@ -58,7 +58,7 @@ module Minitest
58
58
  payload = 'null' if payload.nil?
59
59
  stub_request(:put, uri(api_path))
60
60
  .with(body: payload, headers: headers)
61
- .to_return(body: DUMMY_RESPONSE, status: 200)
61
+ .to_return(body: dummy_response, status: 200)
62
62
  yield block
63
63
  assert_requested(:put, uri(api_path), headers: headers)
64
64
  WebMock.reset!
@@ -72,7 +72,7 @@ module Minitest
72
72
  headers = DEFAULT_HEADERS
73
73
  stub_request(:delete, uri(api_path))
74
74
  .with(headers: headers)
75
- .to_return(body: DUMMY_RESPONSE, status: 200)
75
+ .to_return(body: dummy_response, status: 200)
76
76
  yield block
77
77
  assert_requested(:delete, uri(api_path), headers: headers)
78
78
  WebMock.reset!
@@ -11,6 +11,18 @@ class WavefrontAccountTest < WavefrontTestBase
11
11
  include WavefrontTest::Delete
12
12
  include WavefrontTest::Describe
13
13
 
14
+ def test_add_roles
15
+ assert_posts("/api/v2/account/#{id}/addRoles", roles.to_json) do
16
+ wf.add_roles(id, roles)
17
+ end
18
+
19
+ assert_invalid_id { wf.add_roles(invalid_id, roles) }
20
+
21
+ assert_raises(Wavefront::Exception::InvalidRoleId) do
22
+ wf.add_roles(id, invalid_role)
23
+ end
24
+ end
25
+
14
26
  def test_add_user_groups
15
27
  assert_posts("/api/v2/account/#{id}/addUserGroups", groups.to_json) do
16
28
  wf.add_user_groups(id, groups)
@@ -37,6 +49,22 @@ class WavefrontAccountTest < WavefrontTestBase
37
49
  assert_posts("/api/v2/account/grant/#{permission}", id_list.to_json) do
38
50
  wf.grant(id_list, permission)
39
51
  end
52
+
53
+ assert_raises(Wavefront::Exception::InvalidRoleId) do
54
+ wf.remove_roles(id, invalid_role)
55
+ end
56
+ end
57
+
58
+ def test_remove_roles
59
+ assert_posts("/api/v2/account/#{id}/removeRoles", roles.to_json) do
60
+ wf.remove_roles(id, roles)
61
+ end
62
+
63
+ assert_invalid_id { wf.remove_roles(invalid_id, roles) }
64
+
65
+ assert_raises(Wavefront::Exception::InvalidRoleId) do
66
+ wf.remove_roles(id, invalid_role)
67
+ end
40
68
  end
41
69
 
42
70
  def test_remove_user_groups
@@ -45,12 +73,22 @@ class WavefrontAccountTest < WavefrontTestBase
45
73
  end
46
74
 
47
75
  assert_invalid_id { wf.remove_user_groups(invalid_id, groups) }
76
+
77
+ assert_raises(Wavefront::Exception::InvalidUserGroupId) do
78
+ wf.remove_user_groups(id, invalid_group)
79
+ end
48
80
  end
49
81
 
50
82
  def test_revoke_from_single_user
51
83
  assert_posts("/api/v2/account/#{id}/revoke/#{permission}") do
52
84
  wf.revoke(id, permission)
53
85
  end
86
+
87
+ assert_invalid_id { wf.revoke(invalid_id, permission) }
88
+
89
+ assert_raises(Wavefront::Exception::InvalidPermission) do
90
+ wf.revoke(id, invalid_permission)
91
+ end
54
92
  end
55
93
 
56
94
  def test_revoke_from_multiple_users
@@ -82,7 +120,7 @@ class WavefrontAccountTest < WavefrontTestBase
82
120
  end
83
121
 
84
122
  def test_remove_ingestion_policy
85
- assert_posts('/api/v2/account/removeingestionpolicy',
123
+ assert_posts('/api/v2/account/removeingestionpolicies',
86
124
  { ingestionPolicyId: policy_id,
87
125
  accounts: id_list }.to_json) do
88
126
  wf.remove_ingestion_policy(policy_id, id_list)
@@ -95,6 +133,52 @@ class WavefrontAccountTest < WavefrontTestBase
95
133
  assert_invalid_id { wf.add_ingestion_policy(policy_id, [invalid_id]) }
96
134
  end
97
135
 
136
+ def test_user_list
137
+ assert_gets('/api/v2/account/user?offset=0&limit=100') do
138
+ wf.user_list
139
+ end
140
+
141
+ assert_gets('/api/v2/account/user?offset=10&limit=50') do
142
+ wf.user_list(10, 50)
143
+ end
144
+ end
145
+
146
+ def test_user_describe
147
+ assert_gets("/api/v2/account/user/#{id}") { wf.user_describe(id) }
148
+
149
+ assert_raises(Wavefront::Exception::InvalidUserId) do
150
+ wf.user_describe(invalid_id)
151
+ end
152
+
153
+ assert_raises(ArgumentError) { wf.user_describe }
154
+ end
155
+
156
+ def test_user_create
157
+ assert_posts('/api/v2/account/user', payload.to_json) do
158
+ wf.user_create(payload)
159
+ end
160
+
161
+ assert_raises(ArgumentError) { wf.user_create }
162
+ assert_raises(ArgumentError) { wf.user_create('test') }
163
+ end
164
+
165
+ def test_user_invite
166
+ assert_posts('/api/v2/account/user/invite', [payload].to_json) do
167
+ wf.user_invite([payload])
168
+ end
169
+
170
+ assert_raises(ArgumentError) { wf.user_invite }
171
+ assert_raises(ArgumentError) { wf.user_invite('test') }
172
+ end
173
+
174
+ def test_validate_accounts
175
+ assert_posts('/api/v2/account/validateAccounts', id_list.to_json) do
176
+ wf.validate_accounts(id_list)
177
+ end
178
+
179
+ assert_raises(ArgumentError) { wf.validate_accounts }
180
+ end
181
+
98
182
  private
99
183
 
100
184
  def api_class
@@ -114,10 +198,27 @@ class WavefrontAccountTest < WavefrontTestBase
114
198
  2659191e-aad4-4302-a94e-9667e1517127]
115
199
  end
116
200
 
201
+ def roles
202
+ %w[f8dc0c14-91a0-4ca9-8a2a-7d47f4db1234
203
+ 2659191e-aad4-4302-a94e-9667e1515678]
204
+ end
205
+
206
+ def invalid_role
207
+ %w[bad_role]
208
+ end
209
+
210
+ def invalid_group
211
+ %w[bad_group]
212
+ end
213
+
117
214
  def id_list
118
215
  %w[sa:test user@example.com]
119
216
  end
120
217
 
218
+ def invalid_permission
219
+ 'some_nonsense_permission_i_made_up'
220
+ end
221
+
121
222
  def permission
122
223
  'agent_management'
123
224
  end
@@ -129,4 +230,9 @@ class WavefrontAccountTest < WavefrontTestBase
129
230
  def invalid_policy_id
130
231
  'badpolicy'
131
232
  end
233
+
234
+ def payload
235
+ { emailAddress: id,
236
+ groups: %w[browse] }
237
+ end
132
238
  end