wavefront-sdk 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '048989974d0868e696c8f50dc59007960e2456ca0e9ccb64d632b83d854124bf'
4
- data.tar.gz: 66bc38c3d72355594b51aa5cbe9b34ab069f158cc133f168c94ba28f25dde79d
3
+ metadata.gz: 313adfc6845c757c8ce079ac7cc44a6a4a4979fe37204d3851d837af68496466
4
+ data.tar.gz: a797317ab7e0c00c10d6231ec3c6db552f973562cc4172b620c98bf6e47af02b
5
5
  SHA512:
6
- metadata.gz: e4026c3af06d8e8d3de5a13f02cbc006072fe6852d95a04219b91383db003b97516ee56fd12abf1c2f47a34e238a38fd75dd02707e385b1e9c474c7d1acb0dca
7
- data.tar.gz: fe902524b8af12691cbe40d50ffcb2f24b3aac5b35472743c9774009a33e464e621d6879e806ac0d41c20f71c1b54d3ebfd30e089ed43b029984afb205f08125
6
+ metadata.gz: e54e07151bf094132e03effce102428d40837605accfd03156426ecca98de7244f618f5fe191783dac6792ce8cf760f43252ea8e24b25c0d7f9b4fadced4e22f
7
+ data.tar.gz: 487f7dc0c1f06be5a3b743bb97f75ac8a3e6439625d9b46caba07801aa49a279ec8d8a7c0236442496fb1312279c3d6fa263478d58293a227f2c0f8f83a88049
data/HISTORY.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Changelog
2
2
 
3
- # 3.0.0
3
+ ## 3.0.1
4
+ * User IDs do not have to be e-mail addresses.
5
+
6
+ ## 3.0.0 (23/03/2019)
4
7
  * Drop support for Ruby 2.2. (Potentially breaking change.)
5
8
  * Add `Wavefront::Settings` class to cover new `settings` API
6
9
  endpoint.
@@ -1,4 +1,4 @@
1
1
  require 'pathname'
2
2
 
3
- WF_SDK_VERSION = '3.0.0'.freeze
3
+ WF_SDK_VERSION = '3.0.1'.freeze
4
4
  WF_SDK_LOCATION = Pathname.new(__FILE__).dirname.parent.parent.parent
@@ -386,11 +386,7 @@ module Wavefront
386
386
  # @raise Wavefront::Exceptions::InvalidUserId if not valid
387
387
  #
388
388
  def wf_user_id?(user)
389
- if user.is_a?(String) &&
390
- user =~ /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
391
- return true
392
- end
393
-
389
+ return true if user.is_a?(String) && user.length < 256 && !user.empty?
394
390
  raise Wavefront::Exception::InvalidUserId
395
391
  end
396
392
 
@@ -15,11 +15,11 @@ class WavefrontUserMixinsTest < MiniTest::Test
15
15
  assert validate_user_list(%w[u1@d1.net u2@d2.org u3@d3.com])
16
16
 
17
17
  assert_raises(Wavefront::Exception::InvalidUserId) do
18
- validate_user_list(%w[u1d1.net u2@d2.org u3@d3.com])
18
+ validate_user_list(['', 'u1d1.net', 'u2@d2.org', 'u3@d3.com'])
19
19
  end
20
20
 
21
21
  assert_raises(Wavefront::Exception::InvalidUserId) do
22
- validate_user_list(%w[u1@d1.net org u3@d3.com])
22
+ validate_user_list(['u1@d1.net', '', 'bbrg', 'u3@d3.com'])
23
23
  end
24
24
 
25
25
  assert_raises(ArgumentError) { validate_user_list('u1@d1.net') }
@@ -28,7 +28,7 @@ class WavefrontUserMixinsTest < MiniTest::Test
28
28
  def validate_usergroup_list
29
29
  assert_raises(Wavefront::Exception::InvalidUserGroupId) do
30
30
  validate_user_list(%w[f8dc0c14-91a0-4ca9-8a2a-7d47f4db4672
31
- bad_id
31
+ '',
32
32
  2659191e-aad4-4302-a94e-9667e1517127])
33
33
  end
34
34
 
@@ -3,6 +3,7 @@
3
3
  require_relative '../spec_helper'
4
4
 
5
5
  USER = 'user@example.com'.freeze
6
+ BAD_USER = ('user' * 500).freeze
6
7
  PERMISSION = 'agent_management'.freeze
7
8
 
8
9
  USER_BODY = { emailAddress: USER, groups: %w[browse] }.freeze
@@ -28,20 +29,20 @@ class WavefrontUserTest < WavefrontTestBase
28
29
 
29
30
  def test_delete
30
31
  should_work(:delete, USER, USER, :delete)
31
- should_be_invalid(:delete, 'abcdefg')
32
+ should_be_invalid(:delete, BAD_USER)
32
33
  assert_raises(ArgumentError) { wf.delete }
33
34
  end
34
35
 
35
36
  def test_describe
36
37
  should_work(:describe, USER, USER)
37
- should_be_invalid(:describe, 'abcdefg')
38
+ should_be_invalid(:describe, BAD_USER)
38
39
  assert_raises(ArgumentError) { wf.describe }
39
40
  end
40
41
 
41
42
  def test_update
42
43
  should_work(:update, [USER, USER_BODY, false], USER, :put,
43
44
  JSON_POST_HEADERS, USER_BODY.to_json)
44
- should_be_invalid(:update, ['!invalid uid!', USER_BODY])
45
+ should_be_invalid(:update, [BAD_USER, USER_BODY])
45
46
  assert_raises(ArgumentError) { wf.update }
46
47
  end
47
48
 
@@ -51,7 +52,7 @@ class WavefrontUserTest < WavefrontTestBase
51
52
  JSON_POST_HEADERS, USERGROUP_LIST.to_json)
52
53
 
53
54
  assert_raises(Wavefront::Exception::InvalidUserId) do
54
- wf.add_groups_to_user('invalid address', USERGROUP_LIST)
55
+ wf.add_groups_to_user(BAD_USER, USERGROUP_LIST)
55
56
  end
56
57
  end
57
58
 
@@ -61,7 +62,7 @@ class WavefrontUserTest < WavefrontTestBase
61
62
  JSON_POST_HEADERS, USERGROUP_LIST.to_json)
62
63
 
63
64
  assert_raises(Wavefront::Exception::InvalidUserId) do
64
- wf.remove_groups_from_user('invalid address', USERGROUP_LIST)
65
+ wf.remove_groups_from_user(BAD_USER, USERGROUP_LIST)
65
66
  end
66
67
  end
67
68
 
@@ -71,7 +72,7 @@ class WavefrontUserTest < WavefrontTestBase
71
72
  'Content-Type': 'application/x-www-form-urlencoded'
72
73
  ),
73
74
  "group=#{PERMISSION}")
74
- should_be_invalid(:grant, ['abcde', PERMISSION])
75
+ should_be_invalid(:grant, [BAD_USER, PERMISSION])
75
76
  assert_raises(ArgumentError) { wf.grant }
76
77
  end
77
78
 
@@ -81,7 +82,7 @@ class WavefrontUserTest < WavefrontTestBase
81
82
  'Content-Type': 'application/x-www-form-urlencoded'
82
83
  ),
83
84
  "group=#{PERMISSION}")
84
- should_be_invalid(:revoke, ['abcde', PERMISSION])
85
+ should_be_invalid(:revoke, [BAD_USER, PERMISSION])
85
86
  assert_raises(ArgumentError) { wf.revoke }
86
87
  end
87
88
 
@@ -91,7 +92,7 @@ class WavefrontUserTest < WavefrontTestBase
91
92
  [USER, 'other@example.com'].to_json)
92
93
 
93
94
  assert_raises(Wavefront::Exception::InvalidUserId) do
94
- wf.delete_users(['invalid address'])
95
+ wf.delete_users([BAD_USER])
95
96
  end
96
97
 
97
98
  assert_raises(ArgumentError) { wf.delete_users('a@b.com') }
@@ -101,7 +102,7 @@ class WavefrontUserTest < WavefrontTestBase
101
102
  should_work(:grant_permission, [PERMISSION, USER_LIST],
102
103
  [:grant, PERMISSION].uri_concat, :post,
103
104
  JSON_POST_HEADERS, USER_LIST.to_json)
104
- should_be_invalid(:grant, ['abcde', PERMISSION])
105
+ should_be_invalid(:grant, [BAD_USER, PERMISSION])
105
106
  assert_raises(ArgumentError) { wf.grant }
106
107
  end
107
108
 
@@ -109,7 +110,7 @@ class WavefrontUserTest < WavefrontTestBase
109
110
  should_work(:revoke_permission, [PERMISSION, USER_LIST],
110
111
  [:revoke, PERMISSION].uri_concat, :post,
111
112
  JSON_POST_HEADERS, USER_LIST.to_json)
112
- should_be_invalid(:revoke, ['abcde', PERMISSION])
113
+ should_be_invalid(:revoke, [BAD_USER, PERMISSION])
113
114
  assert_raises(ArgumentError) { wf.grant }
114
115
  end
115
116
 
@@ -11,7 +11,7 @@ USERGROUP_BODY = { name: 'test group',
11
11
  events_management] }.freeze
12
12
 
13
13
  USER_LIST = %w[someone@somewhere.com other@elsewhere.net].freeze
14
- BAD_USER_LIST = %w[badusername very!bad!username].freeze
14
+ BAD_USER_LIST = ['bad' * 500, ''].freeze
15
15
 
16
16
  PERMISSION = 'alerts_management'.freeze
17
17
 
@@ -202,8 +202,8 @@ class WavefrontValidatorsTest < MiniTest::Test
202
202
 
203
203
  def test_wf_user_id?
204
204
  good = %w[Some.User@example.com general99+specific@somewhere.net
205
- someone@somewhere.com]
206
- bad = %w[word Name]
205
+ someone@somewhere.com a user user-name]
206
+ bad = ['', [], {}, 'a' * 1000]
207
207
  good_and_bad('wf_user_id?', 'InvalidUserId', good, bad)
208
208
  end
209
209
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
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-03-23 00:00:00.000000000 Z
11
+ date: 2019-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable