Greetings, I''m writing an integration test and would like to make sure that, with the correct credentials, I get the proper response. The problem is I don''t know how to use the ''get'' method to attach the username and password to the request. For example, when using RSpec''s Story tests.. When("I request the user information for that user''s id") do get "/api/users/#{@user.id}" end Gives me a 401 Unauthorized response because that request isn''t authenticating. Any help would be appreciated, thanks! ~ Jason C --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 10, 2:25 pm, Jason C <Jason...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Greetings, > > I''m writing anintegrationtestandwouldliketomakesurethat, with > thecorrectcredentials, I get the proper response. The problem is I > don''t know how to use the ''get'' method to attach the username and > password to the request. >Take a look at http://svn.codahale.com/simple_http_auth/test/simple_http_auth_test.rb There is a method at line 268, def login(action, username, password, header = ''HTTP_AUTHORIZATION'') @request.env[header] = "Basic #{Base64.encode64(username << '':'' << password)}" get action end Maybe you can use the complete plugin ( http://svn.codahale.com/simple_http_auth )? Stephan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 11, 2:30 am, Stephan Wehner <stephanweh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Take a look at > > http://svn.codahale.com/simple_http_auth/test/simple_http_auth_test.rb > > There is a method at line 268, > > def login(action, username, password, header = ''HTTP_AUTHORIZATION'') > @request.env[header] = "Basic #{Base64.encode64(username << '':'' << > password)}" > get action > end > > Maybe you can use the complete plugin (http://svn.codahale.com/simple_http_auth)? > > StephanThanks Stephan! That worked! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---