wavefront-sdk 5.0.0 → 5.3.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -37
- data/.travis.yml +4 -4
- data/HISTORY.md +19 -0
- data/lib/wavefront-sdk/cloudintegration.rb +27 -0
- data/lib/wavefront-sdk/core/exception.rb +2 -0
- data/lib/wavefront-sdk/credentials.rb +28 -9
- data/lib/wavefront-sdk/defs/version.rb +3 -1
- data/lib/wavefront-sdk/distribution.rb +2 -0
- data/lib/wavefront-sdk/paginator/post.rb +1 -1
- data/lib/wavefront-sdk/proxy.rb +10 -0
- data/lib/wavefront-sdk/role.rb +24 -0
- data/lib/wavefront-sdk/support/mixins.rb +1 -1
- data/lib/wavefront-sdk/support/parse_time.rb +1 -1
- data/lib/wavefront-sdk/validators.rb +13 -0
- data/lib/wavefront-sdk/writers/core.rb +2 -2
- data/spec/.rubocop.yml +9 -40
- data/spec/support/minitest_assertions.rb +5 -11
- data/spec/wavefront-sdk/cloudintegration_spec.rb +38 -0
- data/spec/wavefront-sdk/core/logger_spec.rb +3 -3
- data/spec/wavefront-sdk/credentials_spec.rb +5 -4
- data/spec/wavefront-sdk/misc_spec.rb +18 -0
- data/spec/wavefront-sdk/proxy_spec.rb +6 -0
- data/spec/wavefront-sdk/role_spec.rb +28 -0
- data/spec/wavefront-sdk/validators_spec.rb +6 -0
- data/spec/wavefront-sdk/writers/core_spec.rb +1 -1
- data/wavefront-sdk.gemspec +6 -6
- metadata +19 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9589c220f3c1cb86c7e3c4e3f051315508358580656e61e61d716a756568e9a4
|
4
|
+
data.tar.gz: 03b24e65b9617170af9b03eadae0d7cbd9d78cea99f1be60f8452ef79989d81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ea8ef64251bb430053390d991a16024f1d1545524fe36479a5369c94dcf87669bb77a1cfab92395e2cdd6e23d10fa6c38738fe7227a6e572e0630f35830afca
|
7
|
+
data.tar.gz: b85aa3b9a03e338b4db8fc702bb0b03532d1eaa7618e044f10a7dbc9a973ffebdeaa4891f4a02c717e7c59db280cee551b8765d6cf8dee2f8fe630f6d5bb4201
|
data/.rubocop.yml
CHANGED
@@ -2,47 +2,17 @@
|
|
2
2
|
|
3
3
|
AllCops:
|
4
4
|
TargetRubyVersion: 2.4
|
5
|
+
NewCops: enable
|
5
6
|
|
6
7
|
Metrics/ClassLength:
|
7
8
|
Max: 150
|
8
9
|
|
9
|
-
# New cops
|
10
|
-
#
|
11
|
-
Lint/RaiseException:
|
12
|
-
Enabled: true
|
13
|
-
Lint/StructNewOverride:
|
14
|
-
Enabled: true
|
15
|
-
Style/ExponentialNotation:
|
16
|
-
Enabled: true
|
17
|
-
Style/HashEachMethods:
|
18
|
-
Enabled: true
|
19
|
-
Style/HashTransformKeys:
|
20
|
-
Enabled: true
|
21
|
-
Style/HashTransformValues:
|
22
|
-
Enabled: true
|
23
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
24
|
-
Enabled: true
|
25
|
-
Layout/SpaceAroundMethodCallOperator:
|
26
|
-
Enabled: true
|
27
|
-
Style/SlicingWithRange:
|
28
|
-
Enabled: true
|
29
|
-
Lint/DeprecatedOpenSSLConstant:
|
30
|
-
Enabled: true
|
31
|
-
Lint/MixedRegexpCaptureTypes:
|
32
|
-
Enabled: true
|
33
|
-
Style/RedundantRegexpCharacterClass:
|
34
|
-
Enabled: true
|
35
|
-
Style/RedundantRegexpEscape:
|
36
|
-
Enabled: true
|
37
|
-
Style/AccessorGrouping:
|
38
|
-
Enabled: true
|
39
|
-
Style/BisectedAttrAccessor:
|
40
|
-
Enabled: true
|
41
|
-
Style/RedundantAssignment:
|
42
|
-
Enabled: true
|
43
|
-
Style/RedundantFetchBlock:
|
44
|
-
Enabled: true
|
45
|
-
|
46
10
|
# Is nothing sacred?
|
47
11
|
Layout/LineLength:
|
48
12
|
Max: 80
|
13
|
+
|
14
|
+
Style/StringConcatenation:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/OptionalBooleanParameter:
|
18
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,9 +2,9 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
4
|
- 2.4.9
|
5
|
-
- 2.5.
|
6
|
-
- 2.6.
|
7
|
-
- 2.7.
|
5
|
+
- 2.5.8
|
6
|
+
- 2.6.6
|
7
|
+
- 2.7.2
|
8
8
|
before_install: gem install bundler --no-document
|
9
9
|
deploy:
|
10
10
|
provider: rubygems
|
@@ -14,7 +14,7 @@ deploy:
|
|
14
14
|
on:
|
15
15
|
tags: true
|
16
16
|
repo: snltd/wavefront-sdk
|
17
|
-
ruby: 2.6.
|
17
|
+
ruby: 2.6.6
|
18
18
|
notifications:
|
19
19
|
email: false
|
20
20
|
slack:
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 5.3.0 (2020-10-10)
|
4
|
+
* Add `Wavefront::Proxy#shutdown` which can shut down a proxy via the API.
|
5
|
+
|
6
|
+
## 5.2.1 (2020-09-18)
|
7
|
+
* Remove necessity for user to `require 'pathname'`
|
8
|
+
|
9
|
+
## 5.2.0 (2020-09-03)
|
10
|
+
* Add `:raise_on_no_profile` option to `Wavefront::Credentials` constructor
|
11
|
+
options. If this is true and a specific config stanza is requested but not
|
12
|
+
found, `Wavefront::Exception::MissingConfigProfile` is thrown.
|
13
|
+
|
14
|
+
## 5.1.0 (2020-08-15)
|
15
|
+
* Add `create_aws_external_id`, `delete_aws_external_id`, and
|
16
|
+
`confirm_aws_external_id` methods to `Wavefront::CloudIntegration`.
|
17
|
+
|
18
|
+
## 5.0.1 (2020-07-08)
|
19
|
+
* Reinstate `Wavefront::Role#grant` and `Wavefront::Role#revoke`, which were
|
20
|
+
accidentally removed prior to release of 5.0.0.
|
21
|
+
|
3
22
|
## 5.0.0 (2020-07-08)
|
4
23
|
* Remove `Wavefront::UserGroup#grant` and `Wavefront::UserGroup#revoke` as [the
|
5
24
|
API paths they used have been
|
@@ -101,5 +101,32 @@ module Wavefront
|
|
101
101
|
wf_cloudintegration_id?(id)
|
102
102
|
api.post([id, 'undelete'].uri_concat)
|
103
103
|
end
|
104
|
+
|
105
|
+
# POST /api/v2/cloudintegration/awsExternalIdCreate an external id
|
106
|
+
# @return [Wavefront::Response]
|
107
|
+
#
|
108
|
+
def create_aws_external_id
|
109
|
+
api.post('awsExternalId', nil, 'application/json')
|
110
|
+
end
|
111
|
+
|
112
|
+
# DELETE /api/v2/cloudintegration/awsExternalId/{id}DELETEs an external id
|
113
|
+
# that was created by Wavefront
|
114
|
+
# @param id [String] AWS external ID
|
115
|
+
# @return [Wavefront::Response]
|
116
|
+
#
|
117
|
+
def delete_aws_external_id(external_id)
|
118
|
+
wf_aws_external_id?(external_id)
|
119
|
+
api.delete(['awsExternalId', external_id].uri_concat)
|
120
|
+
end
|
121
|
+
|
122
|
+
# GET /api/v2/cloudintegration/awsExternalId/{id}GETs (confirms) a valid
|
123
|
+
# external id that was created by Wavefront
|
124
|
+
# @param id [String] AWS external ID
|
125
|
+
# @return [Wavefront::Response]
|
126
|
+
#
|
127
|
+
def confirm_aws_external_id(external_id)
|
128
|
+
wf_aws_external_id?(external_id)
|
129
|
+
api.get(['awsExternalId', external_id].uri_concat)
|
130
|
+
end
|
104
131
|
end
|
105
132
|
end
|
@@ -12,6 +12,7 @@ module Wavefront
|
|
12
12
|
class InvalidAlertId < RuntimeError; end
|
13
13
|
class InvalidAlertSeverity < RuntimeError; end
|
14
14
|
class InvalidApiTokenId < RuntimeError; end
|
15
|
+
class InvalidAwsExternalId < RuntimeError; end
|
15
16
|
class InvalidConfigFile < RuntimeError; end
|
16
17
|
class InvalidCloudIntegrationId < RuntimeError; end
|
17
18
|
class InvalidDashboardId < RuntimeError; end
|
@@ -54,6 +55,7 @@ module Wavefront
|
|
54
55
|
class InvalidUserGroupId < RuntimeError; end
|
55
56
|
class InvalidVersion < RuntimeError; end
|
56
57
|
class InvalidWebhookId < RuntimeError; end
|
58
|
+
class MissingConfigProfile < RuntimeError; end
|
57
59
|
class NetworkTimeout < RuntimeError; end
|
58
60
|
class NotImplemented < RuntimeError; end
|
59
61
|
class SocketError < RuntimeError; end
|
@@ -31,11 +31,16 @@ module Wavefront
|
|
31
31
|
# @param options [Hash] keys may be 'file', which
|
32
32
|
# specifies a config file which will be loaded and parsed. If
|
33
33
|
# no file is supplied, those listed above will be used.;
|
34
|
-
# and/or 'profile' which select a profile section from 'file'
|
34
|
+
# and/or 'profile' which select a profile section from 'file'.
|
35
|
+
# Specify the key :raise_noprofile to have an exception thrown
|
36
|
+
# if a given profile cannot be found. Otherwise that is ignored and
|
37
|
+
# options are built from other sources.
|
35
38
|
#
|
36
39
|
def initialize(options = {})
|
37
|
-
|
38
|
-
|
40
|
+
@raise_noprofile = options[:raise_on_no_profile] || false
|
41
|
+
raw = load_from_file(real_files(cred_files(options)),
|
42
|
+
options[:profile] || 'default')
|
43
|
+
|
39
44
|
populate(env_override(raw))
|
40
45
|
end
|
41
46
|
|
@@ -80,31 +85,45 @@ module Wavefront
|
|
80
85
|
end
|
81
86
|
end
|
82
87
|
|
88
|
+
def real_files(files)
|
89
|
+
files.select { |f| f.exist? && f.file? }
|
90
|
+
end
|
91
|
+
|
83
92
|
# @param files [Array][Pathname] a list of ini-style config files
|
84
93
|
# @param profile [String] a profile name
|
94
|
+
# @param disallow_missing [Bool] whether or not to raise an exception if
|
95
|
+
# we are given a profile but can't find it.
|
85
96
|
# @return [Hash] the given profile from the given list of files.
|
86
97
|
# If multiple files match, the last one will be used
|
87
98
|
#
|
88
99
|
def load_from_file(files, profile = 'default')
|
89
100
|
ret = {}
|
101
|
+
profiles_found = conf_files_found = 0
|
90
102
|
|
91
103
|
files.each do |f|
|
92
|
-
next unless f.exist? && f.file?
|
93
|
-
|
94
104
|
ret = load_profile(f, profile)
|
105
|
+
conf_files_found += 1
|
106
|
+
profiles_found += 1 unless ret.empty?
|
95
107
|
ret[:file] = f
|
96
108
|
end
|
97
109
|
|
110
|
+
raise_on_missing_profile(profile, profiles_found, conf_files_found)
|
98
111
|
ret
|
99
112
|
end
|
100
113
|
|
101
|
-
|
102
|
-
|
114
|
+
def raise_on_missing_profile(profile, profiles_found, conf_files_found)
|
115
|
+
return true unless @raise_noprofile
|
116
|
+
return true unless profiles_found.zero? && conf_files_found.positive?
|
117
|
+
|
118
|
+
raise Wavefront::Exception::MissingConfigProfile, profile
|
119
|
+
end
|
120
|
+
|
121
|
+
# Load in an (optionally) given section of an ini-style configuration
|
122
|
+
# file. If the section is not there, we don't consider that an error.
|
103
123
|
#
|
104
124
|
# @param file [Pathname] the file to read
|
105
125
|
# @param profile [String] the section in the config to read
|
106
|
-
# @return [Hash] options loaded from file. Each key becomes a
|
107
|
-
# symbol
|
126
|
+
# @return [Hash] options loaded from file. Each key becomes a symbol
|
108
127
|
#
|
109
128
|
def load_profile(file, profile = 'default')
|
110
129
|
IniFile.load(file)[profile].each_with_object({}) do |(k, v), memo|
|
@@ -65,6 +65,7 @@ module Wavefront
|
|
65
65
|
raise Wavefront::Exception::InvalidDistribution
|
66
66
|
end
|
67
67
|
|
68
|
+
# rubocop:disable Metrics/AbcSize
|
68
69
|
def dist_hash(dist)
|
69
70
|
dist.dup.tap do |d|
|
70
71
|
d[:interval] = distribution_interval(dist)
|
@@ -75,6 +76,7 @@ module Wavefront
|
|
75
76
|
d[:opttags] = tags_or_nothing(opts[:tags])
|
76
77
|
end
|
77
78
|
end
|
79
|
+
# rubocop:enable Metrics/AbcSize
|
78
80
|
|
79
81
|
def distribution_timestamp(dist)
|
80
82
|
parse_time(dist.fetch(:ts, Time.now))
|
data/lib/wavefront-sdk/proxy.rb
CHANGED
@@ -86,5 +86,15 @@ module Wavefront
|
|
86
86
|
wf_proxy_id?(id)
|
87
87
|
api.put(id, payload)
|
88
88
|
end
|
89
|
+
|
90
|
+
# Shutdown a proxy. Requires proxy >=5.x. Might not be effective if you
|
91
|
+
# have something like systemd or SMF restarting a failed proxy.
|
92
|
+
# @param id [String] ID of the proxy
|
93
|
+
# @return [Wavefront::Response]
|
94
|
+
#
|
95
|
+
def shutdown(id)
|
96
|
+
wf_proxy_id?(id)
|
97
|
+
api.put(id, { shutdown: true }, 'application/json')
|
98
|
+
end
|
89
99
|
end
|
90
100
|
end
|
data/lib/wavefront-sdk/role.rb
CHANGED
@@ -100,5 +100,29 @@ module Wavefront
|
|
100
100
|
assignees,
|
101
101
|
'application/json')
|
102
102
|
end
|
103
|
+
|
104
|
+
# POST /api/v2/role/grant/{permission}
|
105
|
+
# Grants a single permission to role(s)
|
106
|
+
# @param permission [String] permission to grant
|
107
|
+
# @param roles [Array[String]] list of roles to receive permission
|
108
|
+
# @return [Wavefront::Response]
|
109
|
+
#
|
110
|
+
def grant(permission, roles)
|
111
|
+
wf_permission?(permission)
|
112
|
+
validate_role_list(roles)
|
113
|
+
api.post(['grant', permission].uri_concat, roles, 'application/json')
|
114
|
+
end
|
115
|
+
|
116
|
+
# POST /api/v2/role/revoke/{permission}
|
117
|
+
# Revokes a single permission from role(s)
|
118
|
+
# @param permission [String] permission to revoke
|
119
|
+
# @param roles [Array[String]] list of roles to lose permission
|
120
|
+
# @return [Wavefront::Response]
|
121
|
+
#
|
122
|
+
def revoke(permission, roles)
|
123
|
+
wf_permission?(permission)
|
124
|
+
validate_role_list(roles)
|
125
|
+
api.post(['revoke', permission].uri_concat, roles, 'application/json')
|
126
|
+
end
|
103
127
|
end
|
104
128
|
end
|
@@ -23,7 +23,7 @@ module Wavefront
|
|
23
23
|
# @raise Wavefront::InvalidTimestamp
|
24
24
|
#
|
25
25
|
def parse_time(time, in_ms = false)
|
26
|
-
return relative_time(time, in_ms) if time.to_s
|
26
|
+
return relative_time(time, in_ms) if time.to_s.match?(/^[\-+]/)
|
27
27
|
|
28
28
|
ParseTime.new(time, in_ms).parse!
|
29
29
|
end
|
@@ -626,6 +626,19 @@ module Wavefront
|
|
626
626
|
|
627
627
|
raise Wavefront::Exception::InvalidRoleId, id
|
628
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
|
629
642
|
end
|
630
643
|
# rubocop:enable Metrics/ModuleLength
|
631
644
|
end
|
@@ -138,8 +138,8 @@ module Wavefront
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def log_invalid_point(rawpoint, exception)
|
141
|
-
logger.log('Invalid point, skipping.', :
|
142
|
-
logger.log(exception.class, :
|
141
|
+
logger.log('Invalid point, skipping.', :warn)
|
142
|
+
logger.log(exception.class, :warn)
|
143
143
|
logger.log(format('Invalid point: %<rawpoint>s (%<message>s)',
|
144
144
|
rawpoint: rawpoint,
|
145
145
|
message: exception.to_s), :debug)
|
data/spec/.rubocop.yml
CHANGED
@@ -1,54 +1,23 @@
|
|
1
|
-
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
|
2
4
|
Metrics/AbcSize:
|
3
5
|
Max: 64
|
4
6
|
|
5
|
-
# Offense count: 5
|
6
7
|
# Configuration parameters: CountComments.
|
7
8
|
Metrics/ClassLength:
|
8
9
|
Max: 400
|
9
10
|
|
10
|
-
# Offense count: 46
|
11
11
|
# Configuration parameters: CountComments, ExcludedMethods.
|
12
12
|
Metrics/MethodLength:
|
13
13
|
Max: 39
|
14
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
15
|
# Is nothing sacred?
|
53
16
|
Layout/LineLength:
|
54
17
|
Max: 80
|
18
|
+
|
19
|
+
Style/StringConcatenation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/OptionalBooleanParameter:
|
23
|
+
Enabled: false
|
@@ -95,18 +95,12 @@ module Minitest
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def header_lookup(type)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
'application/json'
|
103
|
-
when :octet
|
104
|
-
'application/octet-stream'
|
105
|
-
when :form
|
106
|
-
'application/x-www-form-urlencoded'
|
107
|
-
end
|
98
|
+
ctypes = { plain: 'text/plain',
|
99
|
+
json: 'application/json',
|
100
|
+
octet: 'application/octet-stream',
|
101
|
+
form: 'application/x-www-form-urlencoded' }
|
108
102
|
|
109
|
-
{ 'Content-Type':
|
103
|
+
{ 'Content-Type': ctypes[type], Accept: 'application/json' }
|
110
104
|
end
|
111
105
|
end
|
112
106
|
end
|
@@ -37,6 +37,36 @@ class WavefrontCloudIntegrationTest < WavefrontTestBase
|
|
37
37
|
assert_raises(ArgumentError) { wf.disable }
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_create_aws_external_id
|
41
|
+
assert_posts('/api/v2/cloudintegration/awsExternalId', nil, :json) do
|
42
|
+
wf.create_aws_external_id
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_delete_aws_external_id
|
47
|
+
assert_deletes("/api/v2/cloudintegration/awsExternalId/#{external_id}") do
|
48
|
+
wf.delete_aws_external_id(external_id)
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_raises(Wavefront::Exception::InvalidAwsExternalId) do
|
52
|
+
wf.delete_aws_external_id(invalid_external_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
assert_raises(ArgumentError) { wf.delete_aws_external_id }
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_confirm_aws_external_id
|
59
|
+
assert_gets("/api/v2/cloudintegration/awsExternalId/#{external_id}") do
|
60
|
+
wf.confirm_aws_external_id(external_id)
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_raises(Wavefront::Exception::InvalidAwsExternalId) do
|
64
|
+
wf.confirm_aws_external_id(invalid_external_id)
|
65
|
+
end
|
66
|
+
|
67
|
+
assert_raises(ArgumentError) { wf.confirm_aws_external_id }
|
68
|
+
end
|
69
|
+
|
40
70
|
private
|
41
71
|
|
42
72
|
def id
|
@@ -62,4 +92,12 @@ class WavefrontCloudIntegrationTest < WavefrontTestBase
|
|
62
92
|
def api_class
|
63
93
|
'cloudintegration'
|
64
94
|
end
|
95
|
+
|
96
|
+
def external_id
|
97
|
+
'HqOM4mru5svd3uFp'
|
98
|
+
end
|
99
|
+
|
100
|
+
def invalid_external_id
|
101
|
+
'__nonsense__'
|
102
|
+
end
|
65
103
|
end
|
@@ -41,21 +41,21 @@ class WavefrontLoggerTest < MiniTest::Test
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_log_logger_debug
|
44
|
-
l = Wavefront::Logger.new(logger: Logger.new(
|
44
|
+
l = Wavefront::Logger.new(logger: Logger.new($stdout))
|
45
45
|
out, err = capture_subprocess_io { l.log('my message', :debug) }
|
46
46
|
assert_match(/DEBUG -- : my message$/, out)
|
47
47
|
assert_empty(err)
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_log_logger_info
|
51
|
-
l = Wavefront::Logger.new(logger: Logger.new(
|
51
|
+
l = Wavefront::Logger.new(logger: Logger.new($stdout))
|
52
52
|
out, err = capture_subprocess_io { l.log('my message', :info) }
|
53
53
|
assert_match(/INFO -- : my message$/, out)
|
54
54
|
assert_empty(err)
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_log_logger_error
|
58
|
-
l = Wavefront::Logger.new(logger: Logger.new(
|
58
|
+
l = Wavefront::Logger.new(logger: Logger.new($stdout))
|
59
59
|
out, err = capture_subprocess_io { l.log('my message', :error) }
|
60
60
|
assert_match(/ERROR -- : my message$/, out)
|
61
61
|
assert_empty(err)
|
@@ -60,9 +60,11 @@ end
|
|
60
60
|
# Test individual methods. We must override the constructor to do
|
61
61
|
# this.
|
62
62
|
#
|
63
|
+
# rubocop:disable Lint/MissingSuper
|
63
64
|
class Giblets < Wavefront::Credentials
|
64
65
|
def initialize; end
|
65
66
|
end
|
67
|
+
# rubocop:enable Lint/MissingSuper
|
66
68
|
|
67
69
|
# And here are the tests
|
68
70
|
#
|
@@ -153,10 +155,9 @@ class GibletsTest < MiniTest::Test
|
|
153
155
|
end
|
154
156
|
|
155
157
|
def test_load_from_file
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
))
|
158
|
+
assert_raises(Wavefront::Exception::InvalidConfigFile) do
|
159
|
+
wf.load_from_file([Pathname.new('/nofile/1'), Pathname.new('/nofile/2')])
|
160
|
+
end
|
160
161
|
|
161
162
|
assert_equal({ file: CONF1 }, wf.load_from_file([CONF1], 'noprofile'))
|
162
163
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../spec_helper'
|
5
|
+
require_relative '../../lib/wavefront-sdk/defs/version'
|
6
|
+
|
7
|
+
# Tests for things that aren't in the SDK itself.
|
8
|
+
#
|
9
|
+
class WavefrontMiscTest < MiniTest::Test
|
10
|
+
# Check the latest version mentioned in the changelog is the version the SDK
|
11
|
+
# defines itself as.
|
12
|
+
#
|
13
|
+
def test_version_vs_history
|
14
|
+
history_file = WF_SDK_LOCATION + 'HISTORY.md'
|
15
|
+
history_vers = IO.read(history_file).match(/^## (\d+\.\d+\.\d+) \(/)
|
16
|
+
assert_equal(WF_SDK_VERSION, history_vers.captures.first)
|
17
|
+
end
|
18
|
+
end
|
@@ -21,6 +21,12 @@ class WavefrontProxyTest < WavefrontTestBase
|
|
21
21
|
assert_raises(ArgumentError) { wf.rename }
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_shutdown
|
25
|
+
assert_puts("/api/v2/proxy/#{id}", { shutdown: true }.to_json, :json) do
|
26
|
+
wf.shutdown(id)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
private
|
25
31
|
|
26
32
|
def api_class
|
@@ -33,6 +33,34 @@ class WavefrontRoleTest < WavefrontTestBase
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def test_grant
|
37
|
+
assert_posts("/api/v2/role/grant/#{permission}", roles.to_json) do
|
38
|
+
wf.grant(permission, roles)
|
39
|
+
end
|
40
|
+
|
41
|
+
assert_raises(Wavefront::Exception::InvalidRoleId) do
|
42
|
+
wf.grant(permission, [invalid_id])
|
43
|
+
end
|
44
|
+
|
45
|
+
assert_raises(Wavefront::Exception::InvalidPermission) do
|
46
|
+
wf.grant('made_up_permission', roles)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_revoke
|
51
|
+
assert_posts("/api/v2/role/revoke/#{permission}", roles.to_json) do
|
52
|
+
wf.revoke(permission, roles)
|
53
|
+
end
|
54
|
+
|
55
|
+
assert_raises(Wavefront::Exception::InvalidRoleId) do
|
56
|
+
wf.revoke(permission, [invalid_id])
|
57
|
+
end
|
58
|
+
|
59
|
+
assert_raises(Wavefront::Exception::InvalidPermission) do
|
60
|
+
wf.revoke('made_up_permission', roles)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
36
64
|
private
|
37
65
|
|
38
66
|
def api_class
|
@@ -411,4 +411,10 @@ class WavefrontValidatorsTest < MiniTest::Test
|
|
411
411
|
bad = %w[fa312fb-5ff4-420d-862d-5d6d99ed6bcf thing 123]
|
412
412
|
good_and_bad('wf_role_id?', 'InvalidRoleId', good, bad)
|
413
413
|
end
|
414
|
+
|
415
|
+
def test_wf_aws_external_id
|
416
|
+
good = %w[ah5Z9dkr46jbvLtJ HqOM4mru5svd3uFp c1lBxILCBNxLKdx9]
|
417
|
+
bad = %w[h5Z9dkr46jbvLtJ HqOM4mru5svd3uFp3 c!lBx!LC*NxLKdx*]
|
418
|
+
good_and_bad('wf_aws_external_id?', 'InvalidAwsExternalId', good, bad)
|
419
|
+
end
|
414
420
|
end
|
data/wavefront-sdk.gemspec
CHANGED
@@ -23,16 +23,16 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.bindir = 'bin'
|
24
24
|
|
25
25
|
gem.add_dependency 'addressable', '~> 2.7'
|
26
|
-
gem.add_dependency 'faraday', '~> 1.
|
26
|
+
gem.add_dependency 'faraday', '~> 1.1'
|
27
27
|
gem.add_dependency 'inifile', '~> 3.0'
|
28
28
|
gem.add_dependency 'map', '~> 6.6'
|
29
29
|
|
30
|
-
gem.add_development_dependency 'minitest', '~> 5.
|
30
|
+
gem.add_development_dependency 'minitest', '~> 5.14'
|
31
31
|
gem.add_development_dependency 'rake', '~> 13.0'
|
32
|
-
gem.add_development_dependency 'rubocop', '
|
33
|
-
gem.add_development_dependency 'simplecov', '~> 0.
|
34
|
-
gem.add_development_dependency 'spy', '
|
35
|
-
gem.add_development_dependency 'webmock', '~> 3.
|
32
|
+
gem.add_development_dependency 'rubocop', '1.0'
|
33
|
+
gem.add_development_dependency 'simplecov', '~> 0.18'
|
34
|
+
gem.add_development_dependency 'spy', '1.0.0'
|
35
|
+
gem.add_development_dependency 'webmock', '~> 3.9'
|
36
36
|
gem.add_development_dependency 'yard', '~> 0.9'
|
37
37
|
|
38
38
|
gem.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
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: 5.
|
4
|
+
version: 5.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: 2020-
|
11
|
+
date: 2020-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: inifile
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '5.
|
75
|
+
version: '5.14'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '5.
|
82
|
+
version: '5.14'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,42 +98,42 @@ dependencies:
|
|
98
98
|
name: rubocop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '1.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '1.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0.
|
117
|
+
version: '0.18'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0.
|
124
|
+
version: '0.18'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: spy
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 1.0.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 1.0.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '3.
|
145
|
+
version: '3.9'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '3.
|
152
|
+
version: '3.9'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: yard
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,6 +276,7 @@ files:
|
|
276
276
|
- spec/wavefront-sdk/message_spec.rb
|
277
277
|
- spec/wavefront-sdk/metric_helper_spec.rb
|
278
278
|
- spec/wavefront-sdk/metric_spec.rb
|
279
|
+
- spec/wavefront-sdk/misc_spec.rb
|
279
280
|
- spec/wavefront-sdk/notificant_spec.rb
|
280
281
|
- spec/wavefront-sdk/paginator/base_spec.rb
|
281
282
|
- spec/wavefront-sdk/paginator/post_spec.rb
|
@@ -336,8 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
337
|
- !ruby/object:Gem::Version
|
337
338
|
version: '0'
|
338
339
|
requirements: []
|
339
|
-
|
340
|
-
rubygems_version: 2.7.7
|
340
|
+
rubygems_version: 3.0.8
|
341
341
|
signing_key:
|
342
342
|
specification_version: 4
|
343
343
|
summary: SDK for Wavefront API v2
|
@@ -374,6 +374,7 @@ test_files:
|
|
374
374
|
- spec/wavefront-sdk/message_spec.rb
|
375
375
|
- spec/wavefront-sdk/metric_helper_spec.rb
|
376
376
|
- spec/wavefront-sdk/metric_spec.rb
|
377
|
+
- spec/wavefront-sdk/misc_spec.rb
|
377
378
|
- spec/wavefront-sdk/notificant_spec.rb
|
378
379
|
- spec/wavefront-sdk/paginator/base_spec.rb
|
379
380
|
- spec/wavefront-sdk/paginator/post_spec.rb
|