From 51bdded2ce3fc2a2c3112e35c511d0afe8cb0acd Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Wed, 23 Sep 2009 23:04:43 -0500 Subject: [PATCH 1/4] require 'nokogiri' in rspec-rails include file --- lib/webrat/integrations/rspec-rails.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/webrat/integrations/rspec-rails.rb b/lib/webrat/integrations/rspec-rails.rb index d274987..6aaeb8a 100644 --- a/lib/webrat/integrations/rspec-rails.rb +++ b/lib/webrat/integrations/rspec-rails.rb @@ -1,8 +1,9 @@ # Supports using the matchers in controller, helper, and view specs if you're # using rspec-rails. Just add a require statement to spec/spec_helper.rb or env.rb: # -# require 'webrat/rspec-rails' +# require 'webrat/integrations/rspec-rails' # +require "nokogiri" require "webrat/core/matchers" Spec::Runner.configure do |config| From f9f2a98189d554d27c232cf6db1a8fa14267bde1 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 15 Nov 2009 16:42:39 -0500 Subject: [PATCH 2/4] History --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index 4dc3b53..c845241 100644 --- a/History.txt +++ b/History.txt @@ -20,6 +20,7 @@ CHANGED: Due to a reorganization, if you're currently requiring "webrat/rspec-ra * Bug fixes + * Require nokogiri form rspec-rails.rb (David Chelimsky) * Fix logger issue when running inside Cucumber (Damian Janowski) * Fix various issues related to submitting values with HTML entities (Kieran P) * Call #to_i on the :count option in matchers (Michael Christenson II) From 61b0fce82888b75436d05ddfa0c045b2b9d3fc80 Mon Sep 17 00:00:00 2001 From: Michael Klett Date: Wed, 23 Sep 2009 10:46:17 -0400 Subject: [PATCH 3/4] Base64 encoding of HTTP basic auth credentials should omit newlines (do not enforce a 76 character line limit) According to RFC 2617 (http://www.ietf.org/rfc/rfc2617.txt), the 76 character line limit normally enforced by Base64 encoding should not apply to the encoding of HTTP basic authentication credentials. --- lib/webrat/core/session.rb | 2 +- spec/public/basic_auth_spec.rb | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/webrat/core/session.rb b/lib/webrat/core/session.rb index ee180d7..619f3c6 100644 --- a/lib/webrat/core/session.rb +++ b/lib/webrat/core/session.rb @@ -105,7 +105,7 @@ For example: end def basic_auth(user, pass) - encoded_login = ["#{user}:#{pass}"].pack("m*") + encoded_login = ["#{user}:#{pass}"].pack("m*").gsub(/\n/, '') header('HTTP_AUTHORIZATION', "Basic #{encoded_login}") end diff --git a/spec/public/basic_auth_spec.rb b/spec/public/basic_auth_spec.rb index 1d6b590..655f417 100644 --- a/spec/public/basic_auth_spec.rb +++ b/spec/public/basic_auth_spec.rb @@ -6,7 +6,7 @@ describe "Basic Auth HTTP headers" do end it "should be present in visit" do - webrat_session.should_receive(:get).with("/", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"}) + webrat_session.should_receive(:get).with("/", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ="}) visit("/") end @@ -18,7 +18,18 @@ describe "Basic Auth HTTP headers" do HTML - webrat_session.should_receive(:post).with("/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"}) + webrat_session.should_receive(:post).with("/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ="}) click_button end + + context "with long username and password combination" do + before do + basic_auth('user', 'secret1234567890123456789012345678901234567890123456789012345678901234567890') + end + + it "should be present, without new lines, in visit" do + webrat_session.should_receive(:get).with("/", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkw"}) + visit("/") + end + end end From a9ff3efcd7b3606eb07e3e3bbcb7a9693b30c149 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 15 Nov 2009 16:50:03 -0500 Subject: [PATCH 4/4] History --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index c845241..7b59579 100644 --- a/History.txt +++ b/History.txt @@ -20,6 +20,7 @@ CHANGED: Due to a reorganization, if you're currently requiring "webrat/rspec-ra * Bug fixes + * Remove newlines from HTTP Basic authentication credentials (Michael Klett) * Require nokogiri form rspec-rails.rb (David Chelimsky) * Fix logger issue when running inside Cucumber (Damian Janowski) * Fix various issues related to submitting values with HTML entities (Kieran P)