diff options
author | Lamont Granquist <lamont@opscode.com> | 2021-06-21 10:52:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-21 10:52:46 -0700 |
commit | 29aac65c635f6ca6cc4cfd4bea46c823ff80d999 (patch) | |
tree | 16299f8a3ce395f7b28b9c8b7bbb098026272d96 | |
parent | 14322805574a96ace59d65c2a997b5042b836d4a (diff) | |
parent | 852cc5287765a350d09122e044c94a8c616f4116 (diff) | |
download | chef-29aac65c635f6ca6cc4cfd4bea46c823ff80d999.tar.gz |
Merge pull request #11732 from chef/lcg/revert-11569
Revert "Fixed Validation failed while creating databag and databag item"
-rw-r--r-- | lib/chef/data_bag.rb | 3 | ||||
-rw-r--r-- | lib/chef/data_bag_item.rb | 3 | ||||
-rw-r--r-- | spec/unit/data_bag_item_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/data_bag_spec.rb | 2 |
4 files changed, 5 insertions, 7 deletions
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb index 26bf49a008..af0560a640 100644 --- a/lib/chef/data_bag.rb +++ b/lib/chef/data_bag.rb @@ -32,8 +32,7 @@ class Chef include Chef::Mixin::FromFile include Chef::Mixin::ParamsValidate - # Regex reference: https://rubular.com/r/oIMySIO4USPm5x - VALID_NAME = /^[\-[:alnum:]_]+$/.freeze + VALID_NAME = /^[\.\-[:alnum:]_]+$/.freeze RESERVED_NAMES = /^(node|role|environment|client)$/.freeze def self.validate_name!(name) diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb index 17a105a84e..3a4adb84cc 100644 --- a/lib/chef/data_bag_item.rb +++ b/lib/chef/data_bag_item.rb @@ -36,8 +36,7 @@ class Chef include Chef::Mixin::FromFile include Chef::Mixin::ParamsValidate - # Regex reference: https://rubular.com/r/oIMySIO4USPm5x - VALID_ID = /^[\-[:alnum:]_]+$/.freeze + VALID_ID = /^[\.\-[:alnum:]_]+$/.freeze def self.validate_id!(id_str) if id_str.nil? || ( id_str !~ VALID_ID ) diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index 2487bd25d7..61e0a80444 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -73,11 +73,11 @@ describe Chef::DataBagItem do end it "should accept alphanum.alphanum for the id" do - expect { data_bag_item.raw_data = { "id" => "foo.bar" } }.to raise_error(ArgumentError) + expect { data_bag_item.raw_data = { "id" => "foo.bar" } }.not_to raise_error end it "should accept .alphanum for the id" do - expect { data_bag_item.raw_data = { "id" => ".bozo" } }.to raise_error(ArgumentError) + expect { data_bag_item.raw_data = { "id" => ".bozo" } }.not_to raise_error end it "should raise an exception if the id contains anything but alphanum/-/_" do diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb index 891f9c6616..2a7ddddd5b 100644 --- a/spec/unit/data_bag_spec.rb +++ b/spec/unit/data_bag_spec.rb @@ -49,7 +49,7 @@ describe Chef::DataBag do expect { @data_bag.name({}) }.to raise_error(ArgumentError) end - ["-", "_", "1"].each do |char| + [ ".", "-", "_", "1"].each do |char| it "should allow a '#{char}' character in the data bag name" do expect(@data_bag.name("clown#{char}clown")).to eq("clown#{char}clown") end |