summaryrefslogtreecommitdiff
path: root/spec/unit/user_spec.rb
diff options
context:
space:
mode:
authorSteven Danna <steve@opscode.com>2013-01-23 11:18:23 -0800
committerBryan McLellan <btm@opscode.com>2013-02-06 09:51:02 -0800
commit84e37f62bdf06994242ead934faecf9d219e084a (patch)
tree6fbec91ae4b235bf560efd56479ae7d7d5f033aa /spec/unit/user_spec.rb
parent42d5ab44d53c02a731a7cc5ca987d728f6dc2f59 (diff)
downloadchef-84e37f62bdf06994242ead934faecf9d219e084a.tar.gz
Use same name validations as used by the server in user model.
Diffstat (limited to 'spec/unit/user_spec.rb')
-rw-r--r--spec/unit/user_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb
index 9d011fc0e0..d5bb4e7213 100644
--- a/spec/unit/user_spec.rb
+++ b/spec/unit/user_spec.rb
@@ -42,6 +42,20 @@ describe Chef::User do
@client.name.should == "ops_master"
end
+ # It is not feasible to check all invalid characters. Here are a few
+ # that we probably care about.
+ it "should not accept invalid characters" do
+ # capital letters
+ lambda { @user.name "Bar" }.should raise_error(ArgumentError)
+ # slashes
+ lambda { @user.name "foo/bar" }.should raise_error(ArgumentError)
+ # ?
+ lambda { @user.name "foo?" }.should raise_error(ArgumentError)
+ # &
+ lambda { @user.name "foo&" }.should raise_error(ArgumentError)
+ end
+
+
it "should not accept spaces" do
lambda { @client.name "ops master" }.should raise_error(ArgumentError)
end