summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuo Yan <nuo@opscode.com>2010-09-21 15:16:21 -0700
committerNuo Yan <nuo@opscode.com>2010-09-21 15:16:21 -0700
commit58951da00f8d8ec6b79ae40c53d941616cc474dd (patch)
tree1c721575280159347ee3234332541981c093777f
parent1f3120f89b2e413d71c105e8f9a01b3575f80179 (diff)
downloadchef-beta-1-deploy.tar.gz
fixing CHEF-1541beta-1beta-1-deploy
-rw-r--r--chef/lib/chef/node.rb3
-rw-r--r--chef/spec/data/nodes/default.rb2
-rw-r--r--chef/spec/data/nodes/test.rb2
-rw-r--r--chef/spec/unit/cookbook_spec.rb2
-rw-r--r--chef/spec/unit/node_spec.rb10
5 files changed, 12 insertions, 7 deletions
diff --git a/chef/lib/chef/node.rb b/chef/lib/chef/node.rb
index a1a9916f97..2ad5f07a43 100644
--- a/chef/lib/chef/node.rb
+++ b/chef/lib/chef/node.rb
@@ -197,7 +197,8 @@ class Chef
validate(
{:name => arg },
{:name => { :kind_of => String,
- :cannot_be => :blank}
+ :cannot_be => :blank,
+ :regex => /^[\-[:alnum:]_:.]+$/}
})
@name = arg
else
diff --git a/chef/spec/data/nodes/default.rb b/chef/spec/data/nodes/default.rb
index e1c3cff92e..d2d3cfd409 100644
--- a/chef/spec/data/nodes/default.rb
+++ b/chef/spec/data/nodes/default.rb
@@ -1,7 +1,7 @@
##
# Nodes should have a unique name
##
-name "test.example.com default"
+name "test.example.com-default"
##
# Nodes can set arbitrary arguments
diff --git a/chef/spec/data/nodes/test.rb b/chef/spec/data/nodes/test.rb
index d968816d60..e47c6cba55 100644
--- a/chef/spec/data/nodes/test.rb
+++ b/chef/spec/data/nodes/test.rb
@@ -1,7 +1,7 @@
##
# Nodes should have a unique name
##
-name "test.example.com short"
+name "test.example.com-short"
##
# Nodes can set arbitrary arguments
diff --git a/chef/spec/unit/cookbook_spec.rb b/chef/spec/unit/cookbook_spec.rb
index a7c9076adc..8adf458d9b 100644
--- a/chef/spec/unit/cookbook_spec.rb
+++ b/chef/spec/unit/cookbook_spec.rb
@@ -25,7 +25,7 @@ describe Chef::CookbookVersion do
@cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new)
@cookbook = @cookbook_collection[:openldap]
@node = Chef::Node.new
- @node.name "Julia Child"
+ @node.name "JuliaChild"
@run_context = Chef::RunContext.new(@node, @cookbook_collection)
end
diff --git a/chef/spec/unit/node_spec.rb b/chef/spec/unit/node_spec.rb
index 9163bc1e0f..97bfd59dd4 100644
--- a/chef/spec/unit/node_spec.rb
+++ b/chef/spec/unit/node_spec.rb
@@ -57,6 +57,10 @@ describe Chef::Node do
it "cannot be blank" do
lambda { @node.name("")}.should raise_error(Chef::Exceptions::ValidationFailed)
end
+
+ it "should not accept name doesn't match /^[\-[:alnum:]_:.]+$/" do
+ lambda { @node.name("space in it")}.should raise_error(Chef::Exceptions::ValidationFailed)
+ end
end
describe "attributes" do
@@ -357,7 +361,7 @@ describe Chef::Node do
describe "from file" do
it "should load a node from a ruby file" do
@node.from_file(File.expand_path(File.join(CHEF_SPEC_DATA, "nodes", "test.rb")))
- @node.name.should eql("test.example.com short")
+ @node.name.should eql("test.example.com-short")
@node.sunshine.should eql("in")
@node.something.should eql("else")
@node.recipes.should == ["operations-master", "operations-monitoring"]
@@ -378,7 +382,7 @@ describe Chef::Node do
File.stub!(:exists?).and_return(true)
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "test.example.com.rb")).and_return(false)
@node.find_file("test.example.com")
- @node.name.should == "test.example.com short"
+ @node.name.should == "test.example.com-short"
end
it "should load a node from the default file" do
@@ -386,7 +390,7 @@ describe Chef::Node do
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "test.example.com.rb")).and_return(false)
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "test.rb")).and_return(false)
@node.find_file("test.example.com")
- @node.name.should == "test.example.com default"
+ @node.name.should == "test.example.com-default"
end
it "should raise an ArgumentError if it cannot find any node file at all" do