Skip to content

Commit 940a207

Browse files
committed
updated changes and test to only account for leading or trailing whitespace
1 parent 0190f12 commit 940a207

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/puppet/type/sshkey.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def self.title_patterns
5353

5454
newproperty(:key) do
5555
desc "The key itself; generally a long string of unencoded characters. The `key`
56-
attribute may not contain whitespace.
56+
attribute may not contain leading or trailing whitespace.
5757
5858
Make sure to omit the following in this attribute (and specify them in
5959
other attributes):
@@ -62,7 +62,7 @@ def self.title_patterns
6262
* Key identifiers / comments, such as 'joescomputer.local' --- put these in
6363
the `name` attribute/resource title."
6464
validate do |value|
65-
raise Puppet::Error, _('Key must not contain whitespace: %{value}') % { value: value } if %r{\s}.match?(value)
65+
raise Puppet::Error, _('Key must contain neither leading nor trailing whitespace: %{value}') % { value: value } if %r{^\s|\s$}.match?(value)
6666
end
6767
end
6868

spec/unit/type/sshkey_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@
7676
}.to raise_error(Puppet::Error, %r{cannot include whitespace})
7777
end
7878

79-
it "doesn't accept whitespace in the key contents" do
79+
it "doesn't accept leading or trailing whitespace in the key contents" do
8080
expect {
81-
described_class.new(name: 'foo', key: 'AAA FA==')
82-
}.to raise_error(Puppet::Error, %r{Key must not contain whitespace})
81+
described_class.new(name: 'foo', key: ' AAAFA==')
82+
}.to raise_error(Puppet::Error, %r{Key must contain neither leading nor trailing whitespace})
8383
end
8484

8585
it "doesn't accept aliases in the resourcename" do

0 commit comments

Comments
 (0)