Fixing #serviceValidation identation. The right way.

This commit is contained in:
Nick Recobra 2011-01-26 17:53:21 +03:00
Родитель a1ec1c5d6d
Коммит 143b71e553
5 изменённых файлов: 35 добавлений и 10 удалений

Просмотреть файл

@ -11,6 +11,7 @@ class CASServer::Authenticators::Test < CASServer::Authenticators::Base
raise CASServer::AuthenticatorError, "Username is 'do_error'!" if @username == 'do_error' raise CASServer::AuthenticatorError, "Username is 'do_error'!" if @username == 'do_error'
@extra_attributes[:test_string] = "testing!" @extra_attributes[:test_string] = "testing!"
@extra_attributes[:test_utf_string] = "Ютф"
@extra_attributes[:test_numeric] = 123.45 @extra_attributes[:test_numeric] = 123.45
@extra_attributes[:test_serialized] = {:foo => 'bar', :alpha => [1,2,3]} @extra_attributes[:test_serialized] = {:foo => 'bar', :alpha => [1,2,3]}

Просмотреть файл

@ -651,15 +651,17 @@ module CASServer
end end
end end
def serialize_extra_attribute(builder, value) def serialize_extra_attribute(builder, key, value)
if value.kind_of?(String) if value.kind_of?(String)
builder.text! value builder.tag! key, value
elsif value.kind_of?(Numeric) elsif value.kind_of?(Numeric)
builder.text! value.to_s builder.tag! key, value.to_s
else else
builder.tag! key do
builder.cdata! value.to_yaml builder.cdata! value.to_yaml
end end
end end
end end
end end
end

Просмотреть файл

@ -3,9 +3,7 @@ if @success
xml.tag!("cas:authenticationSuccess") do xml.tag!("cas:authenticationSuccess") do
xml.tag!("cas:user", @username.to_s) xml.tag!("cas:user", @username.to_s)
@extra_attributes.each do |key, value| @extra_attributes.each do |key, value|
xml.tag!(key) do serialize_extra_attribute(xml, key, value)
serialize_extra_attribute(xml, value)
end
end end
if @pgtiou if @pgtiou
xml.tag!("cas:proxyGrantingTicket", @pgtiou.to_s) xml.tag!("cas:proxyGrantingTicket", @pgtiou.to_s)

Просмотреть файл

@ -3,9 +3,7 @@ if @success
xml.tag!("cas:authenticationSuccess") do xml.tag!("cas:authenticationSuccess") do
xml.tag!("cas:user", @username.to_s) xml.tag!("cas:user", @username.to_s)
@extra_attributes.each do |key, value| @extra_attributes.each do |key, value|
xml.tag!(key) do serialize_extra_attribute(xml, key, value)
serialize_extra_attribute(xml, value)
end
end end
if @pgtiou if @pgtiou
xml.tag!("cas:proxyGrantingTicket", @pgtiou.to_s) xml.tag!("cas:proxyGrantingTicket", @pgtiou.to_s)

Просмотреть файл

@ -111,4 +111,30 @@ describe 'CASServer' do
page.status_code.should_not == 404 page.status_code.should_not == 404
end end
end end
describe "proxyValidate" do
before do
load_server(File.dirname(__FILE__) + "/default_config.yml")
reset_spec_database
visit "/login?service="+CGI.escape(@target_service)
fill_in 'username', :with => VALID_USERNAME
fill_in 'password', :with => VALID_PASSWORD
click_button 'login-submit'
page.current_url.should =~ /^#{Regexp.escape(@target_service)}\/?\?ticket=ST\-[1-9rA-Z]+/
@ticket = page.current_url.match(/ticket=(.*)$/)[1]
end
it "should have extra attributes in proper format" do
visit "/serviceValidate?service=#{CGI.escape(@target_service)}&ticket=#{@ticket}"
puts page.body
page.body.should match("<test_string>testing!</test_string>")
page.body.should match("<test_numeric>123.45</test_numeric>")
page.body.should match("<test_utf_string>&#1070;&#1090;&#1092;</test_utf_string>")
end
end
end end