wavefront-sdk 3.0.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +12 -1
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/lib/wavefront-sdk/alert.rb +36 -49
- data/lib/wavefront-sdk/api_mixins/acl.rb +76 -0
- data/lib/wavefront-sdk/api_mixins/tag.rb +62 -0
- data/lib/wavefront-sdk/api_mixins/user.rb +26 -0
- data/lib/wavefront-sdk/apitoken.rb +49 -0
- data/lib/wavefront-sdk/core/exception.rb +1 -0
- data/lib/wavefront-sdk/dashboard.rb +6 -106
- data/lib/wavefront-sdk/defs/version.rb +1 -1
- data/lib/wavefront-sdk/derivedmetric.rb +6 -56
- data/lib/wavefront-sdk/event.rb +4 -50
- data/lib/wavefront-sdk/paginator/base.rb +8 -7
- data/lib/wavefront-sdk/paginator/post.rb +7 -5
- data/lib/wavefront-sdk/source.rb +4 -48
- data/lib/wavefront-sdk/user.rb +2 -2
- data/lib/wavefront-sdk/usergroup.rb +2 -2
- data/lib/wavefront-sdk/validators.rb +10 -0
- data/lib/wavefront-sdk/write.rb +43 -12
- data/lib/wavefront-sdk/writers/socket.rb +2 -2
- data/spec/.rubocop.yml +1 -1
- data/spec/spec_helper.rb +66 -0
- data/spec/wavefront-sdk/alert_spec.rb +14 -0
- data/spec/wavefront-sdk/{support → api_mixins}/user_mixins_spec.rb +2 -2
- data/spec/wavefront-sdk/apitoken_spec.rb +31 -0
- data/spec/wavefront-sdk/core/api_spec.rb +3 -5
- data/spec/wavefront-sdk/credentials_spec.rb +41 -37
- data/spec/wavefront-sdk/dashboard_spec.rb +4 -52
- data/spec/wavefront-sdk/distribution_spec.rb +1 -3
- data/spec/wavefront-sdk/metric_helper_spec.rb +6 -8
- data/spec/wavefront-sdk/report_spec.rb +2 -2
- data/spec/wavefront-sdk/stdlib/array_spec.rb +6 -6
- data/spec/wavefront-sdk/stdlib/hash_spec.rb +5 -5
- data/spec/wavefront-sdk/support/mixins_spec.rb +34 -36
- data/spec/wavefront-sdk/support/parse_time_spec.rb +25 -29
- data/spec/wavefront-sdk/usergroup_spec.rb +34 -34
- data/spec/wavefront-sdk/validators_spec.rb +10 -1
- data/spec/wavefront-sdk/write_spec.rb +71 -4
- data/spec/wavefront-sdk/writers/core_spec.rb +10 -10
- data/spec/wavefront-sdk/writers/socket_spec.rb +13 -1
- metadata +10 -5
- data/lib/wavefront-sdk/support/user_mixins.rb +0 -24
@@ -1,10 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../spec_helper'
|
4
4
|
require_relative '../../lib/wavefront-sdk/distribution'
|
5
5
|
|
6
|
-
W_CREDS = { proxy: 'wavefront', port: 2878 }.freeze
|
7
|
-
|
8
6
|
DIST = {
|
9
7
|
interval: :m,
|
10
8
|
path: 'test.distribution',
|
@@ -1,8 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
|
-
require 'spy'
|
5
|
-
require 'spy/integration'
|
6
4
|
require_relative '../spec_helper'
|
7
5
|
require_relative '../../lib/wavefront-sdk/metric_helper'
|
8
6
|
|
@@ -136,7 +134,7 @@ class WavefrontMetricHelperTest < MiniTest::Test
|
|
136
134
|
|
137
135
|
out = wf.flush_gauges(input)
|
138
136
|
args = spy.calls.first.args.first
|
139
|
-
assert_instance_of(
|
137
|
+
assert_instance_of(Wavefront::Response, out)
|
140
138
|
assert spy.has_been_called?
|
141
139
|
assert_equal(input, args)
|
142
140
|
assert(args.any? { |a| a.key?(:tags) && a[:tags] == WH_TAGS })
|
@@ -150,7 +148,7 @@ class WavefrontMetricHelperTest < MiniTest::Test
|
|
150
148
|
mocket = BadMocket.new
|
151
149
|
spy = Spy.on(wf.writer.writer, :write).and_return(mocket)
|
152
150
|
out = wf.flush_gauges(input)
|
153
|
-
assert_instance_of(
|
151
|
+
assert_instance_of(Wavefront::Response, out)
|
154
152
|
wf.gauge('m2.p', 9)
|
155
153
|
wf.gauge('m3.p', 9)
|
156
154
|
assert spy.has_been_called?
|
@@ -173,7 +171,7 @@ class WavefrontMetricHelperTest < MiniTest::Test
|
|
173
171
|
out = wf.flush_counters(input)
|
174
172
|
args = spy.calls.first.args.first
|
175
173
|
|
176
|
-
assert_instance_of(
|
174
|
+
assert_instance_of(Wavefront::Response, out)
|
177
175
|
assert spy.has_been_called?
|
178
176
|
assert_equal(3, args.size)
|
179
177
|
|
@@ -201,7 +199,7 @@ class WavefrontMetricHelperTest < MiniTest::Test
|
|
201
199
|
out = wf.flush_counters(input)
|
202
200
|
args = spy.calls.first.args.first
|
203
201
|
|
204
|
-
assert_instance_of(
|
202
|
+
assert_instance_of(Wavefront::Response, out)
|
205
203
|
assert spy.has_been_called?
|
206
204
|
assert_equal(3, args.size)
|
207
205
|
|
@@ -232,7 +230,7 @@ class WavefrontMetricHelperTest < MiniTest::Test
|
|
232
230
|
out = wfd.flush_dists(input)
|
233
231
|
args = spy.calls.first.args.first
|
234
232
|
|
235
|
-
assert_instance_of(
|
233
|
+
assert_instance_of(Wavefront::Response, out)
|
236
234
|
assert spy.has_been_called?
|
237
235
|
assert_equal(3, args.size)
|
238
236
|
|
@@ -261,7 +259,7 @@ class WavefrontMetricHelperTest < MiniTest::Test
|
|
261
259
|
out = wfd.flush_dists(input)
|
262
260
|
args = spy.calls.first.args.first
|
263
261
|
|
264
|
-
assert_instance_of(
|
262
|
+
assert_instance_of(Wavefront::Response, out)
|
265
263
|
assert spy.has_been_called?
|
266
264
|
assert_equal(3, args.size)
|
267
265
|
refute_empty(wfd.buf[:dists])
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative '../spec_helper'
|
4
4
|
require_relative 'resources/dummy_points'
|
5
5
|
|
6
|
-
|
6
|
+
REPORT_HEADERS = POST_HEADERS.merge('Content-Type': 'application/octet-stream')
|
7
7
|
|
8
8
|
# Unit tests for Report class
|
9
9
|
#
|
@@ -14,6 +14,6 @@ class WavefrontReportTest < WavefrontTestBase
|
|
14
14
|
|
15
15
|
def test_write
|
16
16
|
should_work(:write, POINT, ['?f=wavefront', nil],
|
17
|
-
:post,
|
17
|
+
:post, REPORT_HEADERS, POINT_L)
|
18
18
|
end
|
19
19
|
end
|
@@ -7,11 +7,11 @@ require_relative '../../../lib/wavefront-sdk/stdlib/array'
|
|
7
7
|
#
|
8
8
|
class ArrayTest < MiniTest::Test
|
9
9
|
def test_uri_concat
|
10
|
-
assert_equal %w[a b].uri_concat
|
11
|
-
assert_equal ['', 'a', 'b'].uri_concat
|
12
|
-
assert_equal %w[a /b].uri_concat
|
13
|
-
assert_equal ['', 'a', 'b/'].uri_concat
|
14
|
-
assert_equal %w[/a /b/ /c].uri_concat
|
15
|
-
assert_equal
|
10
|
+
assert_equal('a/b', %w[a b].uri_concat)
|
11
|
+
assert_equal('/a/b', ['', 'a', 'b'].uri_concat)
|
12
|
+
assert_equal('a/b', %w[a /b].uri_concat)
|
13
|
+
assert_equal('/a/b', ['', 'a', 'b/'].uri_concat)
|
14
|
+
assert_equal('/a/b/c', %w[/a /b/ /c].uri_concat)
|
15
|
+
assert_equal('/a/b c', ['/a', '/b c'].uri_concat)
|
16
16
|
end
|
17
17
|
end
|
@@ -7,11 +7,11 @@ require_relative '../../../lib/wavefront-sdk/stdlib/hash'
|
|
7
7
|
#
|
8
8
|
class HashTest < MiniTest::Test
|
9
9
|
def test_to_wf_tag
|
10
|
-
assert_equal({}.to_wf_tag
|
11
|
-
assert_equal(
|
12
|
-
'
|
13
|
-
assert_equal({ tag: 'value' }.to_wf_tag
|
14
|
-
assert_equal({ tag: 'two words' }.to_wf_tag
|
10
|
+
assert_equal('', {}.to_wf_tag)
|
11
|
+
assert_equal('gt1="gv1" gt2="gv2"',
|
12
|
+
{ gt1: 'gv1', gt2: 'gv2' }.to_wf_tag)
|
13
|
+
assert_equal('tag="value"', { tag: 'value' }.to_wf_tag)
|
14
|
+
assert_equal('tag="two words"', { tag: 'two words' }.to_wf_tag)
|
15
15
|
assert_equal('tag="say \"hi\""', { tag: 'say "hi"' }.to_wf_tag)
|
16
16
|
assert_equal('tag1="say \"hi\"" tag2="some stuff!"',
|
17
17
|
{ tag1: 'say "hi"', tag2: 'some stuff!' }.to_wf_tag)
|
@@ -9,18 +9,17 @@ require 'spy/integration'
|
|
9
9
|
class WavefrontMixinsTest < MiniTest::Test
|
10
10
|
include Wavefront::Mixins
|
11
11
|
|
12
|
-
# rubocop:disable Lint/UnifiedInteger
|
13
12
|
def test_parse_time
|
14
13
|
base_t = Time.now.to_i
|
15
|
-
assert_equal parse_time(1_469_711_187)
|
16
|
-
assert_equal parse_time('2016-07-28 14:25:36 +0100')
|
17
|
-
|
18
|
-
|
14
|
+
assert_equal(1_469_711_187, parse_time(1_469_711_187))
|
15
|
+
assert_equal(1_469_712_336, parse_time('2016-07-28 14:25:36 +0100'))
|
16
|
+
assert_kind_of(Numeric, parse_time(Time.now))
|
17
|
+
assert_kind_of(Numeric, parse_time(Time.now, true))
|
19
18
|
assert parse_time(Time.now) >= base_t
|
20
19
|
assert parse_time(Time.now, true) >= base_t * 1000
|
21
20
|
assert parse_time(Time.now, true) < base_t * 1001
|
22
|
-
|
23
|
-
|
21
|
+
assert_kind_of(Numeric, parse_time(Time.now))
|
22
|
+
assert_kind_of(Numeric, parse_time(Time.now, true))
|
24
23
|
assert_raises(Wavefront::Exception::InvalidTimestamp) do
|
25
24
|
parse_time('nonsense')
|
26
25
|
end
|
@@ -32,7 +31,6 @@ class WavefrontMixinsTest < MiniTest::Test
|
|
32
31
|
|
33
32
|
assert_equal trt_spy.calls.length, 2
|
34
33
|
end
|
35
|
-
# rubocop:enable Lint/UnifiedInteger
|
36
34
|
|
37
35
|
def test_relative_time
|
38
36
|
base = Time.now
|
@@ -40,15 +38,15 @@ class WavefrontMixinsTest < MiniTest::Test
|
|
40
38
|
ms_base = base.to_date
|
41
39
|
mbi = ms_base.strftime('%Q').to_i
|
42
40
|
|
43
|
-
assert_equal relative_time('+60s', false, base)
|
44
|
-
assert_equal relative_time('-60s', false, base)
|
45
|
-
assert_equal relative_time('+.5m', false, base)
|
46
|
-
assert_equal relative_time('-000.50m', false, base)
|
41
|
+
assert_equal(bi + 60, relative_time('+60s', false, base))
|
42
|
+
assert_equal(bi - 60, relative_time('-60s', false, base))
|
43
|
+
assert_equal(bi + 30, relative_time('+.5m', false, base))
|
44
|
+
assert_equal(bi - 30, relative_time('-000.50m', false, base))
|
47
45
|
|
48
|
-
assert_equal relative_time('+60s', true, ms_base)
|
49
|
-
assert_equal relative_time('-60s', true, ms_base)
|
50
|
-
assert_equal relative_time('+.5m', true, ms_base)
|
51
|
-
assert_equal relative_time('-000.50m', true, ms_base)
|
46
|
+
assert_equal(mbi + 60_000, relative_time('+60s', true, ms_base))
|
47
|
+
assert_equal(mbi - 60_000, relative_time('-60s', true, ms_base))
|
48
|
+
assert_equal(mbi + 30_000, relative_time('+.5m', true, ms_base))
|
49
|
+
assert_equal(mbi - 30_000, relative_time('-000.50m', true, ms_base))
|
52
50
|
|
53
51
|
assert_raises(Wavefront::Exception::InvalidRelativeTime) do
|
54
52
|
relative_time('5m')
|
@@ -73,19 +71,19 @@ class WavefrontMixinsTest < MiniTest::Test
|
|
73
71
|
end
|
74
72
|
|
75
73
|
def test_parse_relative_time
|
76
|
-
assert_equal parse_relative_time('-5s')
|
77
|
-
assert_equal parse_relative_time('-5s', true)
|
78
|
-
assert_equal parse_relative_time('+10000s')
|
79
|
-
assert_equal parse_relative_time('-5m')
|
80
|
-
assert_equal parse_relative_time('-.5m')
|
81
|
-
assert_equal parse_relative_time('-0.5m')
|
82
|
-
assert_equal parse_relative_time('+5m')
|
83
|
-
assert_equal parse_relative_time('+.5m')
|
84
|
-
assert_equal parse_relative_time('+.50m')
|
85
|
-
assert_equal parse_relative_time('+.50m', true)
|
86
|
-
assert_equal parse_relative_time('+.50m')
|
87
|
-
assert_equal parse_relative_time('+1.5d')
|
88
|
-
assert_equal parse_relative_time('-1.5d')
|
74
|
+
assert_equal(-5, parse_relative_time('-5s'))
|
75
|
+
assert_equal(-5000, parse_relative_time('-5s', true))
|
76
|
+
assert_equal(10_000, parse_relative_time('+10000s'))
|
77
|
+
assert_equal(-300, parse_relative_time('-5m'))
|
78
|
+
assert_equal(-30, parse_relative_time('-.5m'))
|
79
|
+
assert_equal(-30, parse_relative_time('-0.5m'))
|
80
|
+
assert_equal(300, parse_relative_time('+5m'))
|
81
|
+
assert_equal(30, parse_relative_time('+.5m'))
|
82
|
+
assert_equal(30, parse_relative_time('+.50m'))
|
83
|
+
assert_equal(30_000, parse_relative_time('+.50m', true))
|
84
|
+
assert_equal(30, parse_relative_time('+.50m'))
|
85
|
+
assert_equal(129_600, parse_relative_time('+1.5d'))
|
86
|
+
assert_equal(-129_600, parse_relative_time('-1.5d'))
|
89
87
|
|
90
88
|
['-1.5p', '1.5m', '+1.3.5s'].each do
|
91
89
|
assert_raises Wavefront::Exception::InvalidRelativeTime do |t|
|
@@ -95,13 +93,13 @@ class WavefrontMixinsTest < MiniTest::Test
|
|
95
93
|
end
|
96
94
|
|
97
95
|
def test_time_multiplier
|
98
|
-
assert_equal time_multiplier(:s)
|
99
|
-
assert_equal time_multiplier('s')
|
100
|
-
assert_equal time_multiplier(:m)
|
101
|
-
assert_equal time_multiplier(:h)
|
102
|
-
assert_equal time_multiplier(:d)
|
103
|
-
assert_equal time_multiplier(:w)
|
104
|
-
assert_equal time_multiplier(:y)
|
96
|
+
assert_equal(1, time_multiplier(:s))
|
97
|
+
assert_equal(1, time_multiplier('s'))
|
98
|
+
assert_equal(60, time_multiplier(:m))
|
99
|
+
assert_equal(3600, time_multiplier(:h))
|
100
|
+
assert_equal(86_400, time_multiplier(:d))
|
101
|
+
assert_equal(604_800, time_multiplier(:w))
|
102
|
+
assert_equal(31_536_000, time_multiplier(:y))
|
105
103
|
|
106
104
|
assert_raises(Wavefront::Exception::InvalidTimeUnit) do
|
107
105
|
time_multiplier(:p)
|
@@ -3,14 +3,11 @@
|
|
3
3
|
require_relative '../../spec_helper'
|
4
4
|
require_relative '../../../lib/wavefront-sdk/support/parse_time'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
TSM = 1517151869523
|
9
|
-
# rubocop:enable Style/NumericLiterals
|
6
|
+
TSS = 1_517_151_869
|
7
|
+
TSM = 1_517_151_869_523
|
10
8
|
|
11
|
-
# Test parse_time class
|
9
|
+
# Test parse_time class
|
12
10
|
#
|
13
|
-
# rubocop:disable Lint/UnifiedInteger
|
14
11
|
# rubocop:disable Style/DateTime
|
15
12
|
class WavefrontParseTimeTest < MiniTest::Test
|
16
13
|
attr_reader :pts, :ptm
|
@@ -21,51 +18,50 @@ class WavefrontParseTimeTest < MiniTest::Test
|
|
21
18
|
end
|
22
19
|
|
23
20
|
def test_parse_time_fixnum
|
24
|
-
assert_equal(pts.parse_time_fixnum
|
25
|
-
assert_equal(ptm.parse_time_fixnum
|
21
|
+
assert_equal(TSS, pts.parse_time_fixnum)
|
22
|
+
assert_equal(TSM, ptm.parse_time_fixnum)
|
26
23
|
end
|
27
24
|
|
28
25
|
def test_parse_time_integer
|
29
|
-
assert_equal(pts.parse_time_integer
|
30
|
-
assert_equal(ptm.parse_time_integer
|
26
|
+
assert_equal(TSS, pts.parse_time_integer)
|
27
|
+
assert_equal(TSM, ptm.parse_time_integer)
|
31
28
|
end
|
32
29
|
|
33
30
|
def test_parse_time_string
|
34
31
|
ptss = Wavefront::ParseTime.new(TSS.to_s, false)
|
35
32
|
ptms = Wavefront::ParseTime.new(TSM.to_s, true)
|
36
|
-
|
37
|
-
|
38
|
-
assert_equal(ptss.parse_time_string
|
39
|
-
assert_equal(ptms.parse_time_string
|
40
|
-
|
41
|
-
|
33
|
+
assert_kind_of(Numeric, ptss.parse_time_string)
|
34
|
+
assert_kind_of(Numeric, ptms.parse_time_string)
|
35
|
+
assert_equal(TSS, ptss.parse_time_string)
|
36
|
+
assert_equal(TSM, ptms.parse_time_string)
|
37
|
+
assert_kind_of(Numeric, ptss.parse!)
|
38
|
+
assert_kind_of(Numeric, ptms.parse!)
|
42
39
|
end
|
43
40
|
|
44
41
|
def test_parse_time_time
|
45
42
|
ptst = Wavefront::ParseTime.new(Time.at(TSS), false)
|
46
43
|
ptmt = Wavefront::ParseTime.new(DateTime.strptime(TSM.to_s,
|
47
44
|
'%Q').to_time, true)
|
48
|
-
assert_equal(ptst.parse_time_time
|
49
|
-
assert_equal(ptmt.parse_time_time
|
50
|
-
|
51
|
-
|
45
|
+
assert_equal(TSS, ptst.parse_time_time)
|
46
|
+
assert_equal(TSM, ptmt.parse_time_time)
|
47
|
+
assert_kind_of(Numeric, ptst.parse!)
|
48
|
+
assert_kind_of(Numeric, ptmt.parse!)
|
52
49
|
end
|
53
50
|
|
54
51
|
def test_parse_time_datetime
|
55
52
|
ptsd = Wavefront::ParseTime.new(Time.at(TSS).to_datetime, false)
|
56
53
|
ptmd = Wavefront::ParseTime.new(DateTime.strptime(TSM.to_s, '%Q'), true)
|
57
|
-
|
58
|
-
|
59
|
-
assert_equal(ptsd.parse_time_datetime
|
60
|
-
assert_equal(ptmd.parse_time_datetime
|
61
|
-
|
62
|
-
|
54
|
+
assert_kind_of(Numeric, ptsd.parse_time_datetime, TSS)
|
55
|
+
assert_kind_of(Numeric, ptmd.parse_time_datetime, TSM)
|
56
|
+
assert_equal(TSS, ptsd.parse_time_datetime)
|
57
|
+
assert_equal(TSM, ptmd.parse_time_datetime)
|
58
|
+
assert_kind_of(Numeric, ptsd.parse!)
|
59
|
+
assert_kind_of(Numeric, ptmd.parse!)
|
63
60
|
end
|
64
61
|
|
65
62
|
def test_parse!
|
66
|
-
|
67
|
-
|
63
|
+
assert_kind_of(Numeric, pts.parse!)
|
64
|
+
assert_kind_of(Numeric, ptm.parse!)
|
68
65
|
end
|
69
66
|
end
|
70
|
-
# rubocop:enable Lint/UnifiedInteger
|
71
67
|
# rubocop:enable Style/DateTime
|
@@ -2,23 +2,23 @@
|
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
G_USERGROUP_ID = 'f8dc0c14-91a0-4ca9-8a2a-7d47f4db4672'.freeze
|
6
|
+
G_BAD_USERGROUP_ID = 'some_rubbish'.freeze
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
G_USERGROUP_BODY = { name: 'test group',
|
9
|
+
permissions: %w[alerts_management
|
10
|
+
dashboard_management
|
11
|
+
events_management] }.freeze
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
G_USER_LIST = %w[someone@somewhere.com other@elsewhere.net].freeze
|
14
|
+
G_BAD_USER_LIST = ['bad' * 500, ''].freeze
|
15
15
|
|
16
|
-
|
16
|
+
G_PERMISSION = 'alerts_management'.freeze
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
G_GROUP_LIST = %w[f8dc0c14-91a0-4ca9-8a2a-7d47f4db4672
|
19
|
+
2659191e-aad4-4302-a94e-9667e1517127].freeze
|
20
20
|
|
21
|
-
|
21
|
+
G_BAD_GROUP_LIST = %w[some-nonsense more-nonsense].freeze
|
22
22
|
|
23
23
|
# Unit tests for WavefrontUserGroup
|
24
24
|
#
|
@@ -28,71 +28,71 @@ class WavefrontUserGroupTest < WavefrontTestBase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_create
|
31
|
-
should_work(:create,
|
32
|
-
JSON_POST_HEADERS,
|
31
|
+
should_work(:create, G_USERGROUP_BODY, '', :post,
|
32
|
+
JSON_POST_HEADERS, G_USERGROUP_BODY.to_json)
|
33
33
|
assert_raises(ArgumentError) { wf.create }
|
34
34
|
assert_raises(ArgumentError) { wf.create('test') }
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_delete
|
38
|
-
should_work(:delete,
|
38
|
+
should_work(:delete, G_USERGROUP_ID, G_USERGROUP_ID, :delete)
|
39
39
|
should_be_invalid(:delete)
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_describe
|
43
|
-
should_work(:describe,
|
43
|
+
should_work(:describe, G_USERGROUP_ID, G_USERGROUP_ID)
|
44
44
|
assert_raises(ArgumentError) { wf.describe }
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_update
|
48
|
-
should_work(:update, [
|
49
|
-
|
50
|
-
|
51
|
-
should_be_invalid(:update, ['!some rubbish!',
|
48
|
+
should_work(:update, [G_USERGROUP_ID, G_USERGROUP_BODY, false],
|
49
|
+
G_USERGROUP_ID, :put, JSON_POST_HEADERS,
|
50
|
+
G_USERGROUP_BODY.to_json)
|
51
|
+
should_be_invalid(:update, ['!some rubbish!', G_USERGROUP_BODY])
|
52
52
|
assert_raises(ArgumentError) { wf.update }
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_add_users_to_group
|
56
|
-
should_work(:add_users_to_group, [
|
57
|
-
[
|
56
|
+
should_work(:add_users_to_group, [G_USERGROUP_ID, G_USER_LIST],
|
57
|
+
[G_USERGROUP_ID, :addUsers].uri_concat, :post)
|
58
58
|
|
59
59
|
assert_raises(Wavefront::Exception::InvalidUserId) do
|
60
|
-
wf.add_users_to_group(
|
60
|
+
wf.add_users_to_group(G_USERGROUP_ID, G_BAD_USER_LIST)
|
61
61
|
end
|
62
62
|
|
63
63
|
assert_raises(Wavefront::Exception::InvalidUserGroupId) do
|
64
|
-
wf.add_users_to_group(
|
64
|
+
wf.add_users_to_group(G_BAD_USERGROUP_ID, G_USER_LIST)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_remove_users_from_group
|
69
|
-
should_work(:remove_users_from_group, [
|
70
|
-
[
|
69
|
+
should_work(:remove_users_from_group, [G_USERGROUP_ID, G_USER_LIST],
|
70
|
+
[G_USERGROUP_ID, :removeUsers].uri_concat, :post)
|
71
71
|
|
72
72
|
assert_raises(Wavefront::Exception::InvalidUserId) do
|
73
|
-
wf.remove_users_from_group(
|
73
|
+
wf.remove_users_from_group(G_USERGROUP_ID, G_BAD_USER_LIST)
|
74
74
|
end
|
75
75
|
|
76
76
|
assert_raises(Wavefront::Exception::InvalidUserGroupId) do
|
77
|
-
wf.remove_users_from_group(
|
77
|
+
wf.remove_users_from_group(G_BAD_USERGROUP_ID, G_USER_LIST)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
def test_grant
|
82
|
-
should_work(:grant, [
|
83
|
-
[:grant,
|
82
|
+
should_work(:grant, [G_PERMISSION, G_GROUP_LIST],
|
83
|
+
[:grant, G_PERMISSION].uri_concat, :post)
|
84
84
|
|
85
85
|
assert_raises(Wavefront::Exception::InvalidUserGroupId) do
|
86
|
-
wf.grant(
|
86
|
+
wf.grant(G_PERMISSION, G_BAD_GROUP_LIST)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_revoke
|
91
|
-
should_work(:revoke, [
|
92
|
-
[:revoke,
|
91
|
+
should_work(:revoke, [G_PERMISSION, G_GROUP_LIST],
|
92
|
+
[:revoke, G_PERMISSION].uri_concat, :post)
|
93
93
|
|
94
94
|
assert_raises(Wavefront::Exception::InvalidUserGroupId) do
|
95
|
-
wf.revoke(
|
95
|
+
wf.revoke(G_PERMISSION, G_BAD_GROUP_LIST)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|