wavefront-sdk 3.3.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +42 -35
- data/README.md +5 -5
- data/lib/wavefront-sdk/alert.rb +2 -0
- data/lib/wavefront-sdk/core/api_caller.rb +6 -3
- data/lib/wavefront-sdk/defs/version.rb +2 -2
- data/lib/wavefront-sdk/derivedmetric.rb +7 -0
- data/lib/wavefront-sdk/externallink.rb +2 -2
- data/lib/wavefront-sdk/maintenancewindow.rb +6 -2
- data/lib/wavefront-sdk/notificant.rb +7 -0
- data/lib/wavefront-sdk/paginator/base.rb +8 -0
- data/lib/wavefront-sdk/search.rb +11 -2
- data/lib/wavefront-sdk/user.rb +39 -8
- data/lib/wavefront-sdk/webhook.rb +1 -1
- data/spec/constants.rb +30 -0
- data/spec/spec_helper.rb +12 -237
- data/spec/support/bad_mocket.rb +15 -0
- data/spec/support/hash.rb +9 -0
- data/spec/support/minitest_assertions.rb +110 -0
- data/spec/support/mocket.rb +19 -0
- data/spec/test_mixins/acl.rb +78 -0
- data/spec/test_mixins/general.rb +120 -0
- data/spec/test_mixins/tag.rb +55 -0
- data/spec/test_mixins/update_keys.rb +11 -0
- data/spec/wavefront-sdk/alert_spec.rb +88 -136
- data/spec/wavefront-sdk/apitoken_spec.rb +26 -13
- data/spec/wavefront-sdk/cloudintegration_spec.rb +42 -44
- data/spec/wavefront-sdk/dashboard_spec.rb +53 -72
- data/spec/wavefront-sdk/derivedmetric_spec.rb +23 -49
- data/spec/wavefront-sdk/distribution_spec.rb +14 -14
- data/spec/wavefront-sdk/event_spec.rb +39 -48
- data/spec/wavefront-sdk/externallink_spec.rb +19 -50
- data/spec/wavefront-sdk/integration_spec.rb +33 -38
- data/spec/wavefront-sdk/maintenancewindow_spec.rb +18 -33
- data/spec/wavefront-sdk/message_spec.rb +19 -4
- data/spec/wavefront-sdk/metric_spec.rb +13 -9
- data/spec/wavefront-sdk/notificant_spec.rb +16 -15
- data/spec/wavefront-sdk/proxy_spec.rb +20 -25
- data/spec/wavefront-sdk/query_spec.rb +50 -24
- data/spec/wavefront-sdk/report_spec.rb +3 -6
- data/spec/wavefront-sdk/resources/user_responses/add_user_groups.json +1 -0
- data/spec/wavefront-sdk/resources/user_responses/create.json +28 -0
- data/spec/wavefront-sdk/resources/user_responses/delete_multiple.json +1 -0
- data/spec/wavefront-sdk/resources/user_responses/describe.json +1 -0
- data/spec/wavefront-sdk/resources/user_responses/grant.json +1 -0
- data/spec/wavefront-sdk/resources/user_responses/list.json +1 -0
- data/spec/wavefront-sdk/savedsearch_spec.rb +41 -35
- data/spec/wavefront-sdk/search_spec.rb +35 -29
- data/spec/wavefront-sdk/settings_spec.rb +18 -12
- data/spec/wavefront-sdk/source_spec.rb +29 -32
- data/spec/wavefront-sdk/user_spec.rb +101 -74
- data/spec/wavefront-sdk/usergroup_spec.rb +56 -67
- data/spec/wavefront-sdk/webhook_spec.rb +22 -34
- data/spec/wavefront-sdk/write_spec.rb +2 -0
- data/spec/wavefront-sdk/writers/core_spec.rb +2 -0
- data/spec/wavefront-sdk/writers/summary_spec.rb +2 -0
- data/wavefront-sdk.gemspec +5 -5
- metadata +44 -13
@@ -1,41 +1,36 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
|
-
|
5
|
-
PROXY = 'fd248f53-378e-4fbe-bbd3-efabace8d724'.freeze
|
4
|
+
require_relative '../test_mixins/general'
|
6
5
|
|
7
6
|
# Unit tests for proxy class
|
8
7
|
#
|
9
8
|
class WavefrontProxyTest < WavefrontTestBase
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
include WavefrontTest::DeleteUndelete
|
10
|
+
include WavefrontTest::Describe
|
11
|
+
include WavefrontTest::List
|
12
|
+
|
13
|
+
def test_rename
|
14
|
+
assert_puts("/api/v2/proxy/#{id}", name: 'newname') do
|
15
|
+
wf.rename(id, 'newname')
|
16
|
+
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
assert_raises(ArgumentError) { wf.describe }
|
18
|
+
assert_invalid_id { wf.rename(invalid_id, 'newname') }
|
19
|
+
assert_raises(ArgumentError) { wf.rename(id) }
|
20
|
+
assert_raises(ArgumentError) { wf.rename }
|
18
21
|
end
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
private
|
24
|
+
|
25
|
+
def api_class
|
26
|
+
'proxy'
|
23
27
|
end
|
24
28
|
|
25
|
-
def
|
26
|
-
|
27
|
-
[PROXY, { name: 'newname' }.to_json], :put,
|
28
|
-
JSON_POST_HEADERS)
|
29
|
-
assert_raises(ArgumentError) { wf.rename }
|
30
|
-
assert_raises(ArgumentError) { wf.rename('abc123') }
|
31
|
-
assert_raises(Wavefront::Exception::InvalidProxyId) do
|
32
|
-
wf.rename('abc', 'name')
|
33
|
-
end
|
29
|
+
def id
|
30
|
+
'fd248f53-378e-4fbe-bbd3-efabace8d724'
|
34
31
|
end
|
35
32
|
|
36
|
-
def
|
37
|
-
|
38
|
-
:post, POST_HEADERS)
|
39
|
-
should_be_invalid('undelete')
|
33
|
+
def invalid_id
|
34
|
+
'my awesome stupid proxy id'
|
40
35
|
end
|
41
36
|
end
|
@@ -4,30 +4,47 @@ require 'cgi'
|
|
4
4
|
require 'date'
|
5
5
|
require_relative '../spec_helper'
|
6
6
|
|
7
|
-
SERIES = 'test.metric'.freeze
|
8
|
-
T = Time.now.freeze
|
9
|
-
T_MS = T.to_datetime.strftime('%Q').freeze
|
10
|
-
TE = (T + 10).freeze
|
11
|
-
TE_MS = TE.to_datetime.strftime('%Q')
|
12
|
-
Q = "ts(\"#{SERIES}\")".freeze
|
13
|
-
QE = CGI.escape(Q).freeze
|
14
|
-
|
15
7
|
# Unit tests for Query class
|
16
8
|
#
|
17
9
|
class WavefrontQueryTest < WavefrontTestBase
|
18
|
-
|
19
|
-
|
10
|
+
attr_reader :series, :t_start, :t_start_in_ms, :t_end, :t_end_in_ms,
|
11
|
+
:query, :escaped_query
|
12
|
+
|
13
|
+
def setup_fixtures
|
14
|
+
@series = 'test.metric'
|
15
|
+
@t_start = Time.now
|
16
|
+
@t_start_in_ms = t_start.to_datetime.strftime('%Q')
|
17
|
+
@t_end = t_start + 10
|
18
|
+
@t_end_in_ms = t_end.to_datetime.strftime('%Q')
|
19
|
+
@query = "ts(\"#{series}\")"
|
20
|
+
@escaped_query = CGI.escape(query)
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_query
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
assert_gets("/api/v2/chart/api?q=#{escaped_query}&g=d&" \
|
25
|
+
"s=#{t_start_in_ms}") do
|
26
|
+
wf.query(query, 'd', t_start_in_ms)
|
27
|
+
end
|
28
|
+
|
29
|
+
assert_gets("/api/v2/chart/api?q=#{escaped_query}&g=h&" \
|
30
|
+
"s=#{t_start_in_ms}") do
|
31
|
+
wf.query(query, 'h', t_start)
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_gets("/api/v2/chart/api?q=#{escaped_query}&g=m&" \
|
35
|
+
"s=#{t_start_in_ms}&e=#{t_end_in_ms}") do
|
36
|
+
wf.query(query, 'm', t_start, t_end)
|
37
|
+
end
|
38
|
+
|
39
|
+
assert_gets("/api/v2/chart/api?q=#{query}&g=h&s=#{t_start_in_ms}") do
|
40
|
+
wf.query(query, 'h', t_start, nil, {})
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_gets("/api/v2/chart/api?q=#{escaped_query}&g=h&" \
|
44
|
+
"s=#{t_start_in_ms}&strict=true&summarization=MAX") do
|
45
|
+
wf.query(query, 'h', t_start, nil, strict: true,
|
46
|
+
summarization: 'MAX')
|
47
|
+
end
|
31
48
|
|
32
49
|
assert_raises(ArgumentError) { wf.query }
|
33
50
|
|
@@ -41,12 +58,21 @@ class WavefrontQueryTest < WavefrontTestBase
|
|
41
58
|
end
|
42
59
|
|
43
60
|
def test_raw
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
"
|
61
|
+
assert_gets("/api/v2/chart/raw?metric=#{series}&source=src") do
|
62
|
+
wf.raw(series, 'src')
|
63
|
+
end
|
64
|
+
|
65
|
+
assert_gets("/api/v2/chart/raw?metric=#{series}&source=src&" \
|
66
|
+
"startTime=#{t_start_in_ms}") do
|
67
|
+
wf.raw(series, 'src', t_start)
|
68
|
+
end
|
69
|
+
|
70
|
+
assert_gets("/api/v2/chart/raw?metric=#{series}&source=src&" \
|
71
|
+
"startTime=#{t_start_in_ms}" \
|
72
|
+
"&endTime=#{t_end_in_ms}") do
|
73
|
+
wf.raw(series, 'src', t_start, t_end)
|
74
|
+
end
|
75
|
+
|
50
76
|
assert_raises(ArgumentError) { wf.raw }
|
51
77
|
end
|
52
78
|
end
|
@@ -8,12 +8,9 @@ REPORT_HEADERS = POST_HEADERS.merge('Content-Type': 'application/octet-stream')
|
|
8
8
|
# Unit tests for Report class
|
9
9
|
#
|
10
10
|
class WavefrontReportTest < WavefrontTestBase
|
11
|
-
def uri_base
|
12
|
-
"https://#{CREDS[:endpoint]}/report"
|
13
|
-
end
|
14
|
-
|
15
11
|
def test_write
|
16
|
-
|
17
|
-
|
12
|
+
assert_posts('/report?f=wavefront', POINT_L, :octet) do
|
13
|
+
wf.write(POINT)
|
14
|
+
end
|
18
15
|
end
|
19
16
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"identifier":"slackboy@gmail.com","customer":"sysdef","lastSuccessfulLogin":1535977667674,"groups":["host_tag_management","dashboard_management","embedded_charts","metrics_management","agent_management","events_management","external_links_management","alerts_management","ingestion","user_management","application_management"],"userGroups":[{"id":"2659191e-aad4-4302-a94e-9667e1517127","name":"Everyone","permissions":[],"customer":"sysdef","properties":{"nameEditable":false,"permissionsEditable":true,"usersEditable":false},"description":"System group which contains all users"},{"id":"6fd972d9-9a20-4872-acf9-4ef34797f14e","name":"grp1","permissions":["host_tag_management","alerts_management"],"customer":"sysdef"}]}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"status": {
|
3
|
+
"result": "OK",
|
4
|
+
"message": "Invalid user groups found and ignored [8b23136b-ecd2-4cb5-8c92-62477dcc4090]",
|
5
|
+
"code": 202
|
6
|
+
},
|
7
|
+
"response": {
|
8
|
+
"identifier": "user@example.com",
|
9
|
+
"customer": "sysdef",
|
10
|
+
"groups": [
|
11
|
+
"user_management"
|
12
|
+
],
|
13
|
+
"userGroups": [
|
14
|
+
{
|
15
|
+
"id": "2659191e-aad4-4302-a94e-9667e1517127",
|
16
|
+
"name": "Everyone",
|
17
|
+
"permissions": [],
|
18
|
+
"customer": "sysdef",
|
19
|
+
"properties": {
|
20
|
+
"nameEditable": false,
|
21
|
+
"permissionsEditable": true,
|
22
|
+
"usersEditable": false
|
23
|
+
},
|
24
|
+
"description": "System group which contains all users"
|
25
|
+
}
|
26
|
+
]
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"status":{"result":"OK","message":"","code":200},"response":["user@example.com"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"identifier":"user1@merp.com","customer":"sysdef","groups":[],"userGroups":[{"id":"2659191e-aad4-4302-a94e-9667e1517127","name":"Everyone","permissions":[],"customer":"sysdef","properties":{"nameEditable":false,"permissionsEditable":true,"usersEditable":false},"description":"System group which contains all users"}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"identifier":"user1@merp.com","customer":"sysdef","groups":["host_tag_management"],"userGroups":[{"id":"2659191e-aad4-4302-a94e-9667e1517127","name":"Everyone","permissions":[],"customer":"sysdef","properties":{"nameEditable":false,"permissionsEditable":true,"usersEditable":false},"description":"System group which contains all users"}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
[{"identifier":"dev+sysdef@wavefront.com","customer":"sysdef","lastSuccessfulLogin":1549996596333,"groups":["agent_management","alerts_management","dashboard_management","ingestion","events_management","host_tag_management","user_management","embedded_charts","metrics_management","application_management","external_links_management"]},{"identifier":"rob.fisher@hivehome.com","customer":"sysdef","lastSuccessfulLogin":1560162693875,"groups":["user_management","alerts_management"]},{"identifier":"rob@sysdef.xyz","customer":"sysdef","lastSuccessfulLogin":1567547135169,"groups":["agent_management","host_tag_management","events_management","alerts_management","dashboard_management","metrics_management","embedded_charts","ingestion","user_management","application_management","external_links_management"]},{"identifier":"sam@outsidethe.net","customer":"sysdef","lastSuccessfulLogin":1558370774253,"groups":[]},{"identifier":"services@id264.net","customer":"sysdef","groups":[]},{"identifier":"slackboy@gmail.com","customer":"sysdef","lastSuccessfulLogin":1535977667674,"groups":["host_tag_management","dashboard_management","embedded_charts","metrics_management","agent_management","events_management","external_links_management","alerts_management","ingestion","user_management","application_management"]},{"identifier":"test1@sysdef.xyz","customer":"sysdef","groups":[]},{"identifier":"test@sysdef.xyz","customer":"sysdef","groups":[]},{"identifier":"user1@merp.com","customer":"sysdef","groups":[]}]
|
@@ -1,54 +1,60 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
|
-
|
5
|
-
SAVED_SEARCH = 'e2hLH2FR'.freeze
|
6
|
-
SAVED_SEARCH_BODY = {
|
7
|
-
query: {
|
8
|
-
foo: '{"searchTerms":[{"type":"freetext","value":"foo"}]}'
|
9
|
-
},
|
10
|
-
entityType: 'DASHBOARD'
|
11
|
-
}.freeze
|
4
|
+
require_relative '../test_mixins/general'
|
12
5
|
|
13
6
|
# Unit tests for SavedSearch class
|
14
7
|
#
|
15
8
|
class WavefrontSavedSearchTest < WavefrontTestBase
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
include WavefrontTest::Create
|
10
|
+
include WavefrontTest::Delete
|
11
|
+
include WavefrontTest::Describe
|
12
|
+
include WavefrontTest::List
|
13
|
+
include WavefrontTest::Update
|
14
|
+
|
15
|
+
def test_update
|
16
|
+
assert_puts("/api/v2/savedsearch/#{id}", payload) do
|
17
|
+
wf.update(id, payload)
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_invalid_id { wf.update(invalid_id, payload) }
|
21
|
+
assert_raises(ArgumentError) { wf.update }
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def test_entity
|
25
|
+
%w[ALERT EVENT MAINTENANCE_WINDOW DASHBOARD SOURCE AGENT].each do |e|
|
26
|
+
assert_gets("/api/v2/savedsearch/type/#{e}?offset=0&limit=100") do
|
27
|
+
wf.entity(e)
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_gets("/api/v2/savedsearch/type/#{e}?offset=20&limit=100") do
|
31
|
+
wf.entity(e, 20)
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_gets("/api/v2/savedsearch/type/#{e}?offset=10&limit=50") do
|
35
|
+
wf.entity(e, 10, 50)
|
36
|
+
end
|
37
|
+
end
|
27
38
|
end
|
28
39
|
|
29
|
-
|
30
|
-
|
31
|
-
|
40
|
+
private
|
41
|
+
|
42
|
+
def api_class
|
43
|
+
'savedsearch'
|
32
44
|
end
|
33
45
|
|
34
|
-
def
|
35
|
-
|
36
|
-
should_be_invalid(:describe)
|
46
|
+
def id
|
47
|
+
'e2hLH2FR'
|
37
48
|
end
|
38
49
|
|
39
|
-
def
|
40
|
-
|
41
|
-
SAVED_SEARCH, :put, JSON_POST_HEADERS,
|
42
|
-
SAVED_SEARCH_BODY.to_json)
|
43
|
-
should_be_invalid(:update, ['abcde', SAVED_SEARCH_BODY])
|
44
|
-
assert_raises(ArgumentError) { wf.update }
|
50
|
+
def invalid_id
|
51
|
+
'some bad id or other'
|
45
52
|
end
|
46
53
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
54
|
+
def payload
|
55
|
+
{ query: {
|
56
|
+
foo: '{"searchTerms":[{"type":"freetext","value":"foo"}]}'
|
57
|
+
},
|
58
|
+
entityType: 'DASHBOARD' }
|
53
59
|
end
|
54
60
|
end
|
@@ -2,44 +2,38 @@
|
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
4
|
|
5
|
-
SEARCH_BODY = {
|
6
|
-
limit: 10,
|
7
|
-
offset: 0,
|
8
|
-
query: [{ key: 'name',
|
9
|
-
value: 'Wavefront',
|
10
|
-
matchingMethod: 'CONTAINS' }],
|
11
|
-
sort: { field: 'string',
|
12
|
-
ascending: true }
|
13
|
-
}.freeze
|
14
|
-
|
15
5
|
# Unit tests for Search class
|
16
6
|
#
|
17
7
|
class WavefrontSearchTest < WavefrontTestBase
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
8
|
+
def test_raw_search
|
9
|
+
assert_posts('/api/v2/search/agent', payload) do
|
10
|
+
wf.raw_search('agent', payload)
|
11
|
+
end
|
12
|
+
|
13
|
+
assert_posts('/api/v2/search/agent/deleted', payload) do
|
14
|
+
wf.raw_search('agent', payload, true)
|
15
|
+
end
|
16
|
+
|
24
17
|
assert_raises(ArgumentError) { wf.raw_search('ALERT', 'junk') }
|
18
|
+
assert_raises(ArgumentError) { wf.raw_search }
|
25
19
|
end
|
26
20
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
21
|
+
def test_raw_facet_search
|
22
|
+
assert_posts('/api/v2/search/agent/facets', payload) do
|
23
|
+
wf.raw_facet_search('agent', payload)
|
24
|
+
end
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
assert_posts('/api/v2/search/agent/deleted/facets', payload) do
|
27
|
+
wf.raw_facet_search('agent', payload, true)
|
28
|
+
end
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
assert_posts('/api/v2/search/agent/Tags', payload) do
|
31
|
+
wf.raw_facet_search('agent', payload, false, 'Tags')
|
32
|
+
end
|
39
33
|
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
assert_posts('/api/v2/search/agent/deleted/Tags', payload) do
|
35
|
+
wf.raw_facet_search('agent', payload, true, 'Tags')
|
36
|
+
end
|
43
37
|
|
44
38
|
assert_raises(ArgumentError) { wf.raw_facet_search }
|
45
39
|
assert_raises(ArgumentError) { wf.raw_facet_search('ALERT', 'junk') }
|
@@ -72,4 +66,16 @@ class WavefrontSearchTest < WavefrontTestBase
|
|
72
66
|
r4 = wf.body(q, sort_field: :mykey)
|
73
67
|
assert_equal({ field: :mykey, ascending: true }, r4[:sort])
|
74
68
|
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def payload
|
73
|
+
{ limit: 10,
|
74
|
+
offset: 0,
|
75
|
+
query: [{ key: 'name',
|
76
|
+
value: 'Wavefront',
|
77
|
+
matchingMethod: 'CONTAINS' }],
|
78
|
+
sort: { field: 'string',
|
79
|
+
ascending: true } }
|
80
|
+
end
|
75
81
|
end
|
@@ -2,30 +2,36 @@
|
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
4
|
|
5
|
-
SETTINGS_BODY = { showQuerybuilderByDefault: true,
|
6
|
-
hideTSWhenQuerybuilderShown: true }.freeze
|
7
|
-
|
8
5
|
# Unit tests for Settings class
|
9
6
|
#
|
10
7
|
class WavefrontSettingsTest < WavefrontTestBase
|
11
|
-
def api_base
|
12
|
-
'customer'
|
13
|
-
end
|
14
|
-
|
15
8
|
def test_permissions
|
16
|
-
|
9
|
+
assert_gets('/api/v2/customer/permissions') do
|
10
|
+
wf.permissions
|
11
|
+
end
|
17
12
|
end
|
18
13
|
|
19
14
|
def test_preferences
|
20
|
-
|
15
|
+
assert_gets('/api/v2/customer/preferences') do
|
16
|
+
wf.preferences
|
17
|
+
end
|
21
18
|
end
|
22
19
|
|
23
20
|
def test_update_preferences
|
24
|
-
|
25
|
-
|
21
|
+
assert_posts('/api/v2/customer/preferences', payload) do
|
22
|
+
wf.update_preferences(payload)
|
23
|
+
end
|
26
24
|
end
|
27
25
|
|
28
26
|
def test_default_user_groups
|
29
|
-
|
27
|
+
assert_gets('/api/v2/customer/preferences/defaultUserGroups') do
|
28
|
+
wf.default_user_groups
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def payload
|
35
|
+
{ showQuerybuilderByDefault: true, hideTSWhenQuerybuilderShown: true }
|
30
36
|
end
|
31
37
|
end
|
@@ -1,51 +1,48 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
|
-
|
5
|
-
|
6
|
-
SOURCE_BODY = {
|
7
|
-
sourceName: 'source.name',
|
8
|
-
tags: {
|
9
|
-
sourceTag1: true
|
10
|
-
},
|
11
|
-
description: 'Source Description'
|
12
|
-
}.freeze
|
4
|
+
require_relative '../test_mixins/general'
|
5
|
+
require_relative '../test_mixins/tag'
|
13
6
|
|
14
7
|
# Unit tests for Source class
|
15
8
|
#
|
16
9
|
class WavefrontSourceTest < WavefrontTestBase
|
10
|
+
include WavefrontTest::Create
|
11
|
+
include WavefrontTest::Delete
|
12
|
+
include WavefrontTest::Describe
|
13
|
+
include WavefrontTest::Tag
|
14
|
+
include WavefrontTest::Update
|
15
|
+
|
17
16
|
def test_list
|
18
|
-
|
19
|
-
|
20
|
-
should_work(:list, [10, 'mysource'], '?limit=10&cursor=mysource')
|
21
|
-
should_work(:list, [nil, 'mysource'], '?cursor=mysource')
|
22
|
-
end
|
17
|
+
assert_gets('/api/v2/source') { wf.list }
|
18
|
+
assert_gets('/api/v2/source?limit=10') { wf.list(10) }
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
assert_gets('/api/v2/source?limit=10&cursor=mysource') do
|
21
|
+
wf.list(10, 'mysource')
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_gets('/api/v2/source?cursor=mysource') do
|
25
|
+
wf.list(nil, 'mysource')
|
26
|
+
end
|
29
27
|
end
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
private
|
30
|
+
|
31
|
+
def api_class
|
32
|
+
'source'
|
34
33
|
end
|
35
34
|
|
36
|
-
def
|
37
|
-
|
38
|
-
should_be_invalid(:delete)
|
35
|
+
def id
|
36
|
+
'74a247a9-f67c-43ad-911f-fabafa9dc2f3joyent'
|
39
37
|
end
|
40
38
|
|
41
|
-
def
|
42
|
-
|
43
|
-
JSON_POST_HEADERS, SOURCE_BODY.to_json)
|
44
|
-
should_be_invalid(:update, ['!invalid source!', SOURCE_BODY])
|
45
|
-
assert_raises(ArgumentError) { wf.update }
|
39
|
+
def invalid_id
|
40
|
+
'(>_<)'
|
46
41
|
end
|
47
42
|
|
48
|
-
def
|
49
|
-
|
43
|
+
def payload
|
44
|
+
{ sourceName: 'source.name',
|
45
|
+
tags: { sourceTag1: true },
|
46
|
+
description: 'Source Description' }
|
50
47
|
end
|
51
48
|
end
|