diff options
author | Adam Jacob <adam@opscode.com> | 2009-08-01 21:26:21 -0700 |
---|---|---|
committer | Adam Jacob <adam@opscode.com> | 2009-08-20 13:31:58 -0700 |
commit | 89779a4d487ac7dd313e16eb68732835bd13d4e4 (patch) | |
tree | d8b867f3a5610ed39bd864149152085af05a1c3d /features/steps/request_steps.rb | |
parent | 89a2609242a63d6bc85e0ddfed078319b4d4a81b (diff) | |
download | chef-89779a4d487ac7dd313e16eb68732835bd13d4e4.tar.gz |
Initial pass at a Chef 0.8.0 alpha
Conflicts:
Rakefile
chef-server-slice/Rakefile
chef-server-slice/app/controllers/application.rb
chef-server-slice/app/controllers/exceptions.rb
chef-server-slice/app/controllers/nodes.rb
chef-server-slice/app/controllers/openid_consumer.rb
chef-server-slice/app/controllers/openid_server.rb
chef-server-slice/app/helpers/nodes_helper.rb
chef-server/Rakefile
chef-server/config/dependencies.rb
chef-server/config/init.rb
chef/Rakefile
chef/lib/chef.rb
chef/lib/chef/application/indexer.rb
chef/lib/chef/client.rb
chef/lib/chef/config.rb
chef/lib/chef/node.rb
chef/lib/chef/queue.rb
chef/spec/unit/application/indexer_spec.rb
chef/spec/unit/client_spec.rb
chef/spec/unit/config_spec.rb
cucumber.yml
features/api/nodes/create_node_api.feature
features/api/nodes/delete_node_api.feature
features/api/nodes/list_nodes_api.feature
features/api/nodes/show_node_api.feature
features/api/nodes/update_node_api.feature
features/api/roles/list_roles_api.feature
features/steps/fixture_steps.rb
Diffstat (limited to 'features/steps/request_steps.rb')
-rw-r--r-- | features/steps/request_steps.rb | 96 |
1 files changed, 93 insertions, 3 deletions
diff --git a/features/steps/request_steps.rb b/features/steps/request_steps.rb index 156fc88b3a..892195e80e 100644 --- a/features/steps/request_steps.rb +++ b/features/steps/request_steps.rb @@ -1,21 +1,55 @@ -When /^I '(.+)' the path '(.+)'$/ do |http_method, request_uri| +When /^I '([^']*)' (?:to )?the path '([^']*)'$/ do |http_method, request_uri| begin self.response = rest.send("#{http_method}_rest".downcase.to_sym, request_uri) - self.inflated_response = self.response + self.inflated_response = self.response rescue + Chef::Log.debug("Caught exception in request: #{$!.message}") self.exception = $! end end +When /^I '([^']*)' to the path '(.+)'$/ do |http_method, request_uri| + When "I '#{http_method}' the path '#{request_uri}'" +end + +When /^I '(.+)' the path '(.+)' using a wrong private key$/ do |http_method, request_uri| + key = OpenSSL::PKey::RSA.generate(2048) + File.open(File.join(tmpdir, 'false_key.pem'), "w") { |f| f.print key } + @rest = Chef::REST.new(Chef::Config[:chef_server_url], 'snakebite' , File.join(tmpdir, 'false_key.pem')) + + When "I '#{http_method}' the path '#{request_uri}'" +end + When /^I '(.+)' the '(.+)' to the path '(.+)'$/ do |http_method, stash_key, request_uri| begin - self.response = rest.send("#{http_method}_rest".downcase.to_sym, request_uri, stash[stash_key]) + self.response = rest.send("#{http_method.to_s.downcase}_rest".downcase.to_sym, request_uri, stash[stash_key]) self.inflated_response = response rescue self.exception = $! end end +When /^I '(.+)' the '(.+)' to the path '(.+)' using a wrong private key$/ do |http_method, stash_key, request_uri| + key = OpenSSL::PKey::RSA.generate(2048) + File.open(File.join(tmpdir, 'false_key.pem'), "w") { |f| f.print key } + @rest = Chef::REST.new(Chef::Config[:chef_server_url], 'snakebite' , File.join(tmpdir, 'false_key.pem')) + + When "I '#{http_method}' the '#{stash_key}' to the path '#{request_uri}'" +end + +When /^I delete local private key/ do + Chef::FileCache.delete("private_key.pem") +end + +When /^I register '(.+)'$/ do |user| + begin + rest = Chef::REST.new(Chef::Config[:registration_url]) + rest.register("bobo") + rescue + self.exception = $! + end +end + When /^I authenticate as '(.+)'$/ do |reg| begin rest.authenticate(reg, 'tclown') @@ -24,3 +58,59 @@ When /^I authenticate as '(.+)'$/ do |reg| end end + + + +# When /^I '(.+)' the path '(.+)'$/ do |http_method, request_uri| +# begin +# #if http_method.downcase == 'get' +# # self.response = @rest.get_rest(request_uri) +# #else +# #puts "test test test \n\n\n\n\n\n\n" +# @response = @rest.send("#{http_method}_rest".downcase.to_sym, request_uri) +# #end +# puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" +# puts @response +# puts @response['content-type'] +# #puts self.response +# #puts self.response.inspect +# #self.inflated_response = self.response +# @inflated_response = @response#JSON.parse(response.body.to_s) +# puts "~~~~~~~~INFLATED RESPONSE~~~~~~~~~~~~" +# puts @inflated_response +# rescue +# self.exception = $! +# end +# end +# +# When /^I '(.+)' the '(.+)' to the path '(.+)'$/ do |http_method, stash_key, request_uri| +# begin +# #if http_method.downcase == 'post' +# # puts "post request" +# # self.response = @rest.post_rest(request_uri, @stash[stash_key]) +# # puts self.response +# #else +# puts "This is the request -- @stash[stash_key]:" +# puts @stash[stash_key].to_s +# @response = @rest.send("#{http_method}_rest".downcase.to_sym, request_uri, @stash[stash_key]) +# #end +# puts "This is the response:" +# #puts self.response.body.to_s +# puts @response +# #self.inflated_response = response +# @inflated_response = @response#JSON.parse(self.response.body.to_s) +# puts "~~~~~~~~INFLATED RESPONSE~~~~~~~~~~~~" +# puts @inflated_response +# rescue +# self.exception = $! +# end +# end +# +# When /^I authenticate as '(.+)'$/ do |reg| +# begin +# rest.authenticate(reg, 'tclown') +# rescue +# self.exception = $! +# end +# end +# |