chef-attribute-validator 0.4.0 → 0.5.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 +8 -8
- data/CHANGES +5 -0
- data/README.md +22 -5
- data/chef-attribute-validator.gemspec +1 -1
- data/lib/chef-attribute-validator/checks/looks_like.rb +57 -13
- data/lib/chef-attribute-validator/version.rb +1 -1
- data/test/fixtures/check_looks_like_arg_email.rb +6 -0
- data/test/fixtures/check_looks_like_arg_guid.rb +6 -0
- data/test/fixtures/check_looks_like_arg_hostname.rb +6 -0
- data/test/fixtures/check_looks_like_email.rb +74 -0
- data/test/fixtures/check_looks_like_guid.rb +38 -0
- data/test/fixtures/check_looks_like_hostname.rb +70 -0
- data/test/unit/check_looks_like_spec.rb +141 -0
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTQ4ZTZkNWViNzg0YmRiM2NiODkwOWE5NzM1MGU5YzFiMTk2MWU3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjUyYjI3YTRmNmQ0ODJjMGUyOTZlZGY2MjVjMGJhNWE3ZjliMzQwMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Mzk5MjVlOTQ0MzYzMmMzNTVlZWViN2VmZGQ3MGU0YWUxYWNlZGFhOGRjNjQw
|
10
|
+
YWQ2ODI3MDM3MDhhZDZiOWM1ZGQ5Nzk5MzExNGE0NmU4NDYwNjk1NDA1ZTcy
|
11
|
+
MDk1OTBjNjI1Yzc3YWJiZGI5NGQ5YzhjZmI5NjM1NmYyY2Q5YWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDVhNjc5MGE0YWE4Yzg0N2M2NWM4MWZlZjhlNDk5ZjBmMDBkMjg5NGVkYzNj
|
14
|
+
OGVmMDA1NWJmODRmMDU5YjYwYzhmYzk4NTBiNzAzYjFhNzkyZDU4MjIzZmI5
|
15
|
+
YzNlZDY4NjE5YTFhZDk3MTUwYmVkODA2MDc3N2I3M2FkM2JmMzI=
|
data/CHANGES
CHANGED
data/README.md
CHANGED
@@ -76,7 +76,27 @@ Boolean. If true, fails if the path matches zero attributes, or the value is ni
|
|
76
76
|
|
77
77
|
#### looks_like
|
78
78
|
|
79
|
-
String, one of '
|
79
|
+
String, one of 'email', 'guid', 'ip', 'url'. Applies canned regexes (or more sophisticated matchers, like constructing objects from the stdlib). Details:
|
80
|
+
|
81
|
+
##### email
|
82
|
+
|
83
|
+
Uses a naive regex to do a simple sanity check. It may be too tight or too loose for you, in which case you can use a Proc and spend as much of your energy as you please solving that problem.
|
84
|
+
|
85
|
+
##### guid
|
86
|
+
|
87
|
+
Uses a regex to match GUID/UUIDs, like 'ec73f2a8-510d-4e6a-be5d-7b234da03c92'
|
88
|
+
|
89
|
+
##### hostname
|
90
|
+
|
91
|
+
Uses a regex to guess if it looks hostnamish. Does not require a dot. Accepts IPv4, and checks ranges.
|
92
|
+
|
93
|
+
##### ip
|
94
|
+
|
95
|
+
Uses the stdlib 'ipaddr' library to try to construct an IPAddr object from the value. If it worked, it's an IP. IPv6 is supported; ranges are checked; CIDR notation is supported; and no you can't pass a hostname to this.
|
96
|
+
|
97
|
+
##### url
|
98
|
+
|
99
|
+
Uses the stdlib 'url' library to try to construct an URI object from the value. If it worked, it's an URL. This is probably too loose; it will accept bare hostnames, for example.
|
80
100
|
|
81
101
|
#### enum
|
82
102
|
|
@@ -108,12 +128,10 @@ Open a github issue at https://github.com/clintoncwolfe/chef-attribute-validator
|
|
108
128
|
|
109
129
|
#### Some wildcard syntax not yet supported
|
110
130
|
|
111
|
-
Possibly eventually support for
|
131
|
+
Possibly eventually support for [<charclass>], or {<alternatives>}.
|
112
132
|
|
113
133
|
#### Planned checks:
|
114
134
|
|
115
|
-
looks_like/hostname
|
116
|
-
looks_like/email
|
117
135
|
name_regex - Regexp. Applies given regex to the last element in the attribute path ('basename', if you will)
|
118
136
|
|
119
137
|
### Bugs and Defects
|
@@ -126,7 +144,6 @@ No real exception class, just raising a bare string exception, which could certa
|
|
126
144
|
|
127
145
|
BrutalRegex is terrible.
|
128
146
|
|
129
|
-
|
130
147
|
## Author
|
131
148
|
|
132
149
|
Clinton Wolfe
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Chef::Attribute::Validator::VERSION
|
9
9
|
spec.authors = ["Clinton Wolfe"]
|
10
10
|
spec.email = ["clinton@omniti.com"]
|
11
|
-
spec.description = %q{Define, enforce, and handle violations of validation rules for Chef node attributes. This gem provides the validation engine, and can be used outside of a convergence run; a cookbook (attribute-validator) is
|
11
|
+
spec.description = %q{Define, enforce, and handle violations of validation rules for Chef node attributes. This gem provides the validation engine, and can be used outside of a convergence run; a cookbook (attribute-validator) is available to perform validation during a chef run, at compile or converge time.}
|
12
12
|
spec.summary = %q{A Rubygem implementing a rule engine for validating Chef node attributes.}
|
13
13
|
spec.homepage = "https://github.com/clintoncwolfe/chef-attribute-validator"
|
14
14
|
spec.license = "BSD (3-clause)"
|
@@ -12,6 +12,9 @@ class Chef
|
|
12
12
|
|
13
13
|
def validate_check_arg
|
14
14
|
expected = [
|
15
|
+
'email',
|
16
|
+
'guid',
|
17
|
+
'hostname',
|
15
18
|
'ip',
|
16
19
|
'url',
|
17
20
|
]
|
@@ -26,25 +29,66 @@ class Chef
|
|
26
29
|
attrset.each do |path, value|
|
27
30
|
if val_scalar?(value) then
|
28
31
|
next if value.nil?
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
IPAddr.new(value)
|
33
|
-
rescue
|
34
|
-
violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Value '#{value}' does not look like an IP address")
|
35
|
-
end
|
36
|
-
when 'url'
|
37
|
-
begin
|
38
|
-
URI(value)
|
39
|
-
rescue
|
40
|
-
violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Value '#{value}' does not look like a URL")
|
41
|
-
end
|
32
|
+
unless value.respond_to?(:match)
|
33
|
+
violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Value '#{value}' is not string-like, so it can't be a #{check_arg}")
|
34
|
+
next
|
42
35
|
end
|
36
|
+
send(('ll_check_' + check_arg).to_sym, value, path, violations)
|
43
37
|
end
|
44
38
|
end
|
45
39
|
violations
|
46
40
|
end
|
47
41
|
|
42
|
+
private
|
43
|
+
|
44
|
+
def ll_check_guid(value, path, violations)
|
45
|
+
guid_regex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/
|
46
|
+
unless value.match(guid_regex)
|
47
|
+
violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Value '#{value}' does not look like a v4 UUID (see RFC 4122)")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def ll_check_ip(value, path, violations)
|
52
|
+
begin
|
53
|
+
IPAddr.new(value)
|
54
|
+
rescue
|
55
|
+
violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Value '#{value}' does not look like an IP address")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def ll_check_url(value, path, violations)
|
60
|
+
begin
|
61
|
+
URI(value)
|
62
|
+
rescue
|
63
|
+
violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Value '#{value}' does not look like a URL")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def ll_check_email(value, path, violations)
|
68
|
+
# This is simple and crude. Will reject some things you might wish it didn't:
|
69
|
+
# root@localhost
|
70
|
+
# root
|
71
|
+
#
|
72
|
+
|
73
|
+
# Email validation with regexes is stupid.
|
74
|
+
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
|
75
|
+
unless value.match(email_regex)
|
76
|
+
violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Value '#{value}' does not look like an email address, but I could be wrong. If I am wrong, use a Proc instead.")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def ll_check_hostname(value, path, violations)
|
81
|
+
ip_regex = /^(\d{1,3}\.){3}\d{1,3}$/
|
82
|
+
hostname_regex = /^([a-z0-9\-]+\.)*[a-z0-9\-]{2,}$/i
|
83
|
+
|
84
|
+
if value.match(ip_regex)
|
85
|
+
ll_check_ip(value, path, violations)
|
86
|
+
else
|
87
|
+
unless value.match(hostname_regex)
|
88
|
+
violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Value '#{value}' does not look like a hostname, nor an IPv4.")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
48
92
|
end
|
49
93
|
end
|
50
94
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
default['nil'] = nil
|
3
|
+
default['empty'] = ''
|
4
|
+
|
5
|
+
default['email']['joe'] = 'joe@example.com'
|
6
|
+
default['email']['case']['lower'] = 'ray@cartalk.com'
|
7
|
+
default['email']['case']['upper'] = 'TOMMY@CARTALK.COM'
|
8
|
+
default['email']['tagged'] = 'joe+tag@foo.com'
|
9
|
+
|
10
|
+
default['email']['no']['user'] = '@foo.com'
|
11
|
+
default['email']['no']['hostname'] = 'johnny@'
|
12
|
+
|
13
|
+
default['email']['bad']['quotes'] = '"Click and Clack" <show@cartalk.com>'
|
14
|
+
default['email']['bad']['spaces'] = '"Click and Clack" <show@cartalk.com>'
|
15
|
+
default['email']['bad']['phonetic'] = 'joeATfoo.com'
|
16
|
+
|
17
|
+
rules = default['attribute-validator']['rules']
|
18
|
+
rules['email-missing'] = {
|
19
|
+
'path' => '/nope',
|
20
|
+
'looks_like' => 'email',
|
21
|
+
}
|
22
|
+
|
23
|
+
rules['email-nil'] = {
|
24
|
+
'path' => '/nil',
|
25
|
+
'looks_like' => 'email',
|
26
|
+
}
|
27
|
+
|
28
|
+
rules['email-empty'] = {
|
29
|
+
'path' => '/empty',
|
30
|
+
'looks_like' => 'email',
|
31
|
+
}
|
32
|
+
|
33
|
+
rules['email-spaces'] = {
|
34
|
+
'path' => '/email/bad/spaces',
|
35
|
+
'looks_like' => 'email',
|
36
|
+
}
|
37
|
+
|
38
|
+
rules['email-case-upper'] = {
|
39
|
+
'path' => '/email/case/upper',
|
40
|
+
'looks_like' => 'email',
|
41
|
+
}
|
42
|
+
|
43
|
+
rules['email-joe'] = {
|
44
|
+
'path' => '/email/joe',
|
45
|
+
'looks_like' => 'email',
|
46
|
+
}
|
47
|
+
|
48
|
+
rules['email-tagged'] = {
|
49
|
+
'path' => '/email/tagged',
|
50
|
+
'looks_like' => 'email',
|
51
|
+
}
|
52
|
+
|
53
|
+
rules['email-no-user'] = {
|
54
|
+
'path' => '/email/no/user',
|
55
|
+
'looks_like' => 'email',
|
56
|
+
}
|
57
|
+
|
58
|
+
rules['email-no-hostname'] = {
|
59
|
+
'path' => '/email/no/hostname',
|
60
|
+
'looks_like' => 'email',
|
61
|
+
}
|
62
|
+
|
63
|
+
rules['email-quotes'] = {
|
64
|
+
'path' => '/email/bad/quotes',
|
65
|
+
'looks_like' => 'email',
|
66
|
+
}
|
67
|
+
|
68
|
+
rules['email-phonetic-at'] = {
|
69
|
+
'path' => '/email/bad/phonetic',
|
70
|
+
'looks_like' => 'email',
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
default['nil'] = nil
|
3
|
+
default['empty'] = ''
|
4
|
+
|
5
|
+
default['guid']['case']['lower'] = 'ec73f2a8-510d-4e6a-be5d-7b234da03c92'
|
6
|
+
default['guid']['case']['upper'] = 'ACCF642E-2CD3-4D20-921E-A80E91EAFEC8'
|
7
|
+
default['guid']['spaces'] = 'db592238 8175 491b a914 f1e4eaf732bf'
|
8
|
+
|
9
|
+
rules = default['attribute-validator']['rules']
|
10
|
+
rules['guid-missing'] = {
|
11
|
+
'path' => '/nope',
|
12
|
+
'looks_like' => 'guid',
|
13
|
+
}
|
14
|
+
|
15
|
+
rules['guid-nil'] = {
|
16
|
+
'path' => '/nil',
|
17
|
+
'looks_like' => 'guid',
|
18
|
+
}
|
19
|
+
|
20
|
+
rules['guid-empty'] = {
|
21
|
+
'path' => '/empty',
|
22
|
+
'looks_like' => 'guid',
|
23
|
+
}
|
24
|
+
|
25
|
+
rules['guid-spaces'] = {
|
26
|
+
'path' => '/guid/spaces',
|
27
|
+
'looks_like' => 'guid',
|
28
|
+
}
|
29
|
+
|
30
|
+
rules['guid-upper-case'] = {
|
31
|
+
'path' => '/guid/case/upper',
|
32
|
+
'looks_like' => 'guid',
|
33
|
+
}
|
34
|
+
|
35
|
+
rules['guid-lower-case'] = {
|
36
|
+
'path' => '/guid/case/lower',
|
37
|
+
'looks_like' => 'guid',
|
38
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
default['nil'] = nil
|
3
|
+
default['empty'] = ''
|
4
|
+
|
5
|
+
default['hostname']['case']['lower'] = 'wombat.example.org'
|
6
|
+
default['hostname']['case']['upper'] = 'WOMBAT.EXAMPLE.ORG'
|
7
|
+
default['hostname']['spaces'] = 'wombat example.org'
|
8
|
+
default['hostname']['localhost'] = 'localhost'
|
9
|
+
default['hostname']['underscore'] = 'under_score.org'
|
10
|
+
default['hostname']['iad'] = 'foo.iad'
|
11
|
+
default['hostname']['ip']['i127'] = '127.0.0.1'
|
12
|
+
default['hostname']['ip']['i300'] = '300.300.300.300'
|
13
|
+
|
14
|
+
rules = default['attribute-validator']['rules']
|
15
|
+
rules['hostname-missing'] = {
|
16
|
+
'path' => '/nope',
|
17
|
+
'looks_like' => 'hostname',
|
18
|
+
}
|
19
|
+
|
20
|
+
rules['hostname-nil'] = {
|
21
|
+
'path' => '/nil',
|
22
|
+
'looks_like' => 'hostname',
|
23
|
+
}
|
24
|
+
|
25
|
+
rules['hostname-empty'] = {
|
26
|
+
'path' => '/empty',
|
27
|
+
'looks_like' => 'hostname',
|
28
|
+
}
|
29
|
+
|
30
|
+
rules['hostname-case-lower'] = {
|
31
|
+
'path' => '/hostname/case/lower',
|
32
|
+
'looks_like' => 'hostname',
|
33
|
+
}
|
34
|
+
|
35
|
+
rules['hostname-case-upper'] = {
|
36
|
+
'path' => '/hostname/case/upper',
|
37
|
+
'looks_like' => 'hostname',
|
38
|
+
}
|
39
|
+
|
40
|
+
rules['hostname-localhost'] = {
|
41
|
+
'path' => '/hostname/localhost',
|
42
|
+
'looks_like' => 'hostname',
|
43
|
+
}
|
44
|
+
|
45
|
+
rules['hostname-iad'] = {
|
46
|
+
'path' => '/hostname/iad',
|
47
|
+
'looks_like' => 'hostname',
|
48
|
+
}
|
49
|
+
|
50
|
+
rules['hostname-ip-127'] = {
|
51
|
+
'path' => '/hostname/ip/i127',
|
52
|
+
'looks_like' => 'hostname',
|
53
|
+
}
|
54
|
+
|
55
|
+
rules['hostname-ip-300'] = {
|
56
|
+
'path' => '/hostname/ip/i300',
|
57
|
+
'looks_like' => 'hostname',
|
58
|
+
}
|
59
|
+
|
60
|
+
rules['hostname-underscore'] = {
|
61
|
+
'path' => '/hostname/underscore',
|
62
|
+
'looks_like' => 'hostname',
|
63
|
+
}
|
64
|
+
|
65
|
+
rules['hostname-spaces'] = {
|
66
|
+
'path' => '/hostname/spaces',
|
67
|
+
'looks_like' => 'hostname',
|
68
|
+
}
|
69
|
+
|
70
|
+
|
@@ -12,6 +12,18 @@ describe "'looks_like' check" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "check_arg checks" do
|
15
|
+
it "should accept 'email'" do
|
16
|
+
node = CAVHelper.load_fixture_attributes('check_looks_like_arg_email')
|
17
|
+
expect { Chef::Attribute::Validator.new(node) }.not_to raise_error
|
18
|
+
end
|
19
|
+
it "should accept 'guid'" do
|
20
|
+
node = CAVHelper.load_fixture_attributes('check_looks_like_arg_guid')
|
21
|
+
expect { Chef::Attribute::Validator.new(node) }.not_to raise_error
|
22
|
+
end
|
23
|
+
it "should accept 'hostname'" do
|
24
|
+
node = CAVHelper.load_fixture_attributes('check_looks_like_arg_hostname')
|
25
|
+
expect { Chef::Attribute::Validator.new(node) }.not_to raise_error
|
26
|
+
end
|
15
27
|
it "should accept 'ip'" do
|
16
28
|
node = CAVHelper.load_fixture_attributes('check_looks_like_arg_ip')
|
17
29
|
expect { Chef::Attribute::Validator.new(node) }.not_to raise_error
|
@@ -101,6 +113,135 @@ describe "'looks_like' check" do
|
|
101
113
|
|
102
114
|
end
|
103
115
|
|
116
|
+
context "when the mode is 'guid'" do
|
117
|
+
let(:node) { CAVHelper.load_fixture_attributes('check_looks_like_guid') }
|
118
|
+
let(:av) { Chef::Attribute::Validator.new(node) }
|
119
|
+
|
120
|
+
it "should not violate on missing" do
|
121
|
+
expect(av.validate_rule('guid-missing')).to be_empty
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should not violate on nil" do
|
125
|
+
expect(av.validate_rule('guid-nil')).to be_empty
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should not violate on a lower-case guid" do
|
129
|
+
expect(av.validate_rule('guid-lower-case')).to be_empty
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should not violate on a upper-case guid" do
|
133
|
+
expect(av.validate_rule('guid-upper-case')).to be_empty
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should violate on a guid without dashes" do
|
137
|
+
expect(av.validate_rule('guid-spaces')).not_to be_empty
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should violate on an empty string" do
|
141
|
+
expect(av.validate_rule('guid-empty')).not_to be_empty
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
context "when the mode is 'email'" do
|
147
|
+
let(:node) { CAVHelper.load_fixture_attributes('check_looks_like_email') }
|
148
|
+
let(:av) { Chef::Attribute::Validator.new(node) }
|
149
|
+
|
150
|
+
it "should not violate on missing" do
|
151
|
+
expect(av.validate_rule('email-missing')).to be_empty
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should not violate on nil" do
|
155
|
+
expect(av.validate_rule('email-nil')).to be_empty
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should violate on an empty string" do
|
159
|
+
expect(av.validate_rule('email-empty')).not_to be_empty
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should not violate on joe@example.com" do
|
163
|
+
expect(av.validate_rule('email-joe')).to be_empty
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should not violate on a upper-case email" do
|
167
|
+
expect(av.validate_rule('email-case-upper')).to be_empty
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should not violate on a joe+tag@foo.com" do
|
171
|
+
expect(av.validate_rule('email-tagged')).to be_empty
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should violate on a email without a user" do
|
175
|
+
expect(av.validate_rule('email-no-user')).not_to be_empty
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should violate on a email without a hostname" do
|
179
|
+
expect(av.validate_rule('email-no-hostname')).not_to be_empty
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should violate on a email with spaces" do
|
183
|
+
expect(av.validate_rule('email-spaces')).not_to be_empty
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should violate on a email with quotes" do
|
187
|
+
expect(av.validate_rule('email-quotes')).not_to be_empty
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should violate on phonetic-at" do
|
191
|
+
expect(av.validate_rule('email-phonetic-at')).not_to be_empty
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
context "when the mode is 'hostname'" do
|
197
|
+
let(:node) { CAVHelper.load_fixture_attributes('check_looks_like_hostname') }
|
198
|
+
let(:av) { Chef::Attribute::Validator.new(node) }
|
199
|
+
|
200
|
+
it "should not violate on missing" do
|
201
|
+
expect(av.validate_rule('hostname-missing')).to be_empty
|
202
|
+
end
|
203
|
+
|
204
|
+
it "should not violate on nil" do
|
205
|
+
expect(av.validate_rule('hostname-nil')).to be_empty
|
206
|
+
end
|
104
207
|
|
208
|
+
it "should violate on an empty string" do
|
209
|
+
expect(av.validate_rule('hostname-empty')).not_to be_empty
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should not violate on a lower-case hostname" do
|
213
|
+
expect(av.validate_rule('hostname-case-lower')).to be_empty
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should not violate on a upper-case hostname" do
|
217
|
+
expect(av.validate_rule('hostname-case-upper')).to be_empty
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should not violate on a 'localhost'" do
|
221
|
+
expect(av.validate_rule('hostname-localhost')).to be_empty
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should not violate on 'foo.iad'" do
|
225
|
+
expect(av.validate_rule('hostname-iad')).to be_empty
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should not violate on '127.0.0.1'" do
|
229
|
+
expect(av.validate_rule('hostname-ip-127')).to be_empty
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should violate on '300.300.300.300'" do
|
233
|
+
expect(av.validate_rule('hostname-ip-300')).not_to be_empty
|
234
|
+
end
|
235
|
+
|
236
|
+
it "should violate on 'under_score.com'" do
|
237
|
+
expect(av.validate_rule('hostname-underscore')).not_to be_empty
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should violate on spaces" do
|
241
|
+
expect(av.validate_rule('hostname-spaces')).not_to be_empty
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
|
105
246
|
|
106
247
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-attribute-validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clinton Wolfe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version: 11.6.0
|
57
57
|
description: Define, enforce, and handle violations of validation rules for Chef node
|
58
58
|
attributes. This gem provides the validation engine, and can be used outside of
|
59
|
-
a convergence run; a cookbook (attribute-validator) is
|
59
|
+
a convergence run; a cookbook (attribute-validator) is available to perform validation
|
60
60
|
during a chef run, at compile or converge time.
|
61
61
|
email:
|
62
62
|
- clinton@omniti.com
|
@@ -97,10 +97,16 @@ files:
|
|
97
97
|
- test/fixtures/check_enum_assorted.rb
|
98
98
|
- test/fixtures/check_enum_nil.rb
|
99
99
|
- test/fixtures/check_enum_string.rb
|
100
|
+
- test/fixtures/check_looks_like_arg_email.rb
|
101
|
+
- test/fixtures/check_looks_like_arg_guid.rb
|
102
|
+
- test/fixtures/check_looks_like_arg_hostname.rb
|
100
103
|
- test/fixtures/check_looks_like_arg_ip.rb
|
101
104
|
- test/fixtures/check_looks_like_arg_regex.rb
|
102
105
|
- test/fixtures/check_looks_like_arg_url.rb
|
103
106
|
- test/fixtures/check_looks_like_arg_your_mom.rb
|
107
|
+
- test/fixtures/check_looks_like_email.rb
|
108
|
+
- test/fixtures/check_looks_like_guid.rb
|
109
|
+
- test/fixtures/check_looks_like_hostname.rb
|
104
110
|
- test/fixtures/check_looks_like_ip.rb
|
105
111
|
- test/fixtures/check_looks_like_url.rb
|
106
112
|
- test/fixtures/check_present_assorted.rb
|
@@ -177,10 +183,16 @@ test_files:
|
|
177
183
|
- test/fixtures/check_enum_assorted.rb
|
178
184
|
- test/fixtures/check_enum_nil.rb
|
179
185
|
- test/fixtures/check_enum_string.rb
|
186
|
+
- test/fixtures/check_looks_like_arg_email.rb
|
187
|
+
- test/fixtures/check_looks_like_arg_guid.rb
|
188
|
+
- test/fixtures/check_looks_like_arg_hostname.rb
|
180
189
|
- test/fixtures/check_looks_like_arg_ip.rb
|
181
190
|
- test/fixtures/check_looks_like_arg_regex.rb
|
182
191
|
- test/fixtures/check_looks_like_arg_url.rb
|
183
192
|
- test/fixtures/check_looks_like_arg_your_mom.rb
|
193
|
+
- test/fixtures/check_looks_like_email.rb
|
194
|
+
- test/fixtures/check_looks_like_guid.rb
|
195
|
+
- test/fixtures/check_looks_like_hostname.rb
|
184
196
|
- test/fixtures/check_looks_like_ip.rb
|
185
197
|
- test/fixtures/check_looks_like_url.rb
|
186
198
|
- test/fixtures/check_present_assorted.rb
|