webrat/spec/public/basic_auth_spec.rb
Michael Klett 61b0fce828 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.
2009-11-15 16:50:40 -05:00

36 lines
1.1 KiB
Ruby

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
describe "Basic Auth HTTP headers" do
before do
basic_auth('user', 'secret')
end
it "should be present in visit" do
webrat_session.should_receive(:get).with("/", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ="})
visit("/")
end
it "should be present in form submits" do
with_html <<-HTML
<html>
<form method="post" action="/form1">
<input type="submit" />
</form>
</html>
HTML
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