diff options
author | Steven Danna <steve@opscode.com> | 2012-12-22 09:22:51 -0800 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-02-06 09:51:02 -0800 |
commit | 42d5ab44d53c02a731a7cc5ca987d728f6dc2f59 (patch) | |
tree | ea1d04b98dd8a3f7e661bf40dd38748ead837c8b /spec/unit/user_spec.rb | |
parent | 4d45c9fb1bb4ec70c342fee963c3ac9b1134fdba (diff) | |
download | chef-42d5ab44d53c02a731a7cc5ca987d728f6dc2f59.tar.gz |
Chef::User.list should handle responses from Hosted/Private Chef
The API responses from a GET to the "users" endpoint currently returns
a different response on Hosted and Private Chef. Chef::User.list
transforms this response into form returned by the open source server.
Diffstat (limited to 'spec/unit/user_spec.rb')
-rw-r--r-- | spec/unit/user_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb index 0377e920fe..9d011fc0e0 100644 --- a/spec/unit/user_spec.rb +++ b/spec/unit/user_spec.rb @@ -186,6 +186,26 @@ describe Chef::User do Chef::REST.stub!(:new).and_return(@http_client) end + describe "list" do + before(:each) do + Chef::Config[:chef_server_url] = "http://www.example.com" + @osc_response = { "admin" => "http://www.example.com/users/admin"} + @ohc_response = [ { "user" => { "username" => "admin" }} ] + end + + it "lists all clients on an OSC server" do + @http_client.stub!(:get_rest).with("users").and_return(@osc_response) + Chef::User.list.should == @osc_response + end + + it "lists all clients on an OHC/OPC server" do + @http_client.stub!(:get_rest).with("users").and_return(@ohc_response) + # We expect that Chef::User.list will give a consistent response + # so OHC API responses should be transformed to OSC-style output. + Chef::User.list.should == @osc_response + end + end + describe "create" do it "creates a new user via the API" do @user.password "password" |