sensu-settings 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sensu/settings/validators/client.rb +28 -0
- data/sensu-settings.gemspec +1 -1
- data/spec/validator_spec.rb +31 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59c86f090d9e6b164204356e7d7924f72163e6b6
|
4
|
+
data.tar.gz: d28b6cced806d5e0283697f5819dff25c227f85d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0249f3b2e216d465ac811e883760ad3c055a6baeedf7c5ddd86632b2692b1550262e246d2d1ae06b976c375aaeb2379d898e7d37ce6b5100bf30708a552ce2da
|
7
|
+
data.tar.gz: b14a67f57e2184907f07e98f21081f66f3decbe90e3bbbf10a6c1e9f55cd4fff56871ced058409758733dbc23b5882a8deaeb82990ce0a2d52d2b310247c164e
|
@@ -105,6 +105,33 @@ module Sensu
|
|
105
105
|
invalid(client, "client signature must be a string")
|
106
106
|
end
|
107
107
|
|
108
|
+
# Validate client registration handlers.
|
109
|
+
# Validates: registration (handler, handlers)
|
110
|
+
#
|
111
|
+
# @param client [Hash] sensu client definition.
|
112
|
+
def validate_client_registration_handlers(client)
|
113
|
+
must_be_a_string_if_set(client[:registration][:handler]) ||
|
114
|
+
invalid(client, "client registration handler must be a string")
|
115
|
+
must_be_an_array_if_set(client[:registration][:handlers]) ||
|
116
|
+
invalid(client, "client registration handlers must be an array")
|
117
|
+
if is_an_array?(client[:registration][:handlers])
|
118
|
+
items_must_be_strings(client[:registration][:handlers]) ||
|
119
|
+
invalid(client, "client registration handlers must each be a string")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Validate client registration.
|
124
|
+
# Validates: registration
|
125
|
+
#
|
126
|
+
# @param client [Hash] sensu client definition.
|
127
|
+
def validate_client_registration(client)
|
128
|
+
must_be_a_hash_if_set(client[:registration]) ||
|
129
|
+
invalid(client, "client registration must be a hash")
|
130
|
+
if is_a_hash?(client[:registration])
|
131
|
+
validate_client_registration_handlers(client)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
108
135
|
# Validate a Sensu client definition.
|
109
136
|
# Validates: name, address, safe_mode
|
110
137
|
#
|
@@ -125,6 +152,7 @@ module Sensu
|
|
125
152
|
validate_client_keepalive(client)
|
126
153
|
validate_client_redact(client)
|
127
154
|
validate_client_signature(client)
|
155
|
+
validate_client_registration(client)
|
128
156
|
end
|
129
157
|
end
|
130
158
|
end
|
data/sensu-settings.gemspec
CHANGED
data/spec/validator_spec.rb
CHANGED
@@ -604,6 +604,37 @@ describe "Sensu::Settings::Validator" do
|
|
604
604
|
expect(@validator.reset).to eq(0)
|
605
605
|
end
|
606
606
|
|
607
|
+
it "can validate client registration" do
|
608
|
+
client = {
|
609
|
+
:name => "foo",
|
610
|
+
:address => "127.0.0.1",
|
611
|
+
:subscriptions => ["bar"]
|
612
|
+
}
|
613
|
+
@validator.validate_client(client)
|
614
|
+
expect(@validator.reset).to eq(0)
|
615
|
+
client[:registration] = true
|
616
|
+
@validator.validate_client(client)
|
617
|
+
expect(@validator.reset).to eq(1)
|
618
|
+
client[:registration] = {}
|
619
|
+
@validator.validate_client(client)
|
620
|
+
expect(@validator.reset).to eq(0)
|
621
|
+
client[:registration][:handler] = 1
|
622
|
+
@validator.validate_client(client)
|
623
|
+
expect(@validator.reset).to eq(1)
|
624
|
+
client[:registration][:handler] = "foo"
|
625
|
+
@validator.validate_client(client)
|
626
|
+
expect(@validator.reset).to eq(0)
|
627
|
+
client[:registration][:handlers] = 1
|
628
|
+
@validator.validate_client(client)
|
629
|
+
expect(@validator.reset).to eq(1)
|
630
|
+
client[:registration][:handlers] = [1]
|
631
|
+
@validator.validate_client(client)
|
632
|
+
expect(@validator.reset).to eq(1)
|
633
|
+
client[:registration][:handlers] = ["foo"]
|
634
|
+
@validator.validate_client(client)
|
635
|
+
expect(@validator.reset).to eq(0)
|
636
|
+
end
|
637
|
+
|
607
638
|
it "can run, validating client" do
|
608
639
|
settings = {
|
609
640
|
:client => {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -157,4 +157,3 @@ test_files:
|
|
157
157
|
- spec/rules_spec.rb
|
158
158
|
- spec/settings_spec.rb
|
159
159
|
- spec/validator_spec.rb
|
160
|
-
has_rdoc:
|