diff --git a/lib/openid/consumer.rb b/lib/openid/consumer.rb index f5600792..08ecbf89 100644 --- a/lib/openid/consumer.rb +++ b/lib/openid/consumer.rb @@ -7,7 +7,6 @@ require "openid/message" require "openid/yadis/discovery" require "openid/store/nonce" -require "openid/serializer" module OpenID # OpenID support for Relying Parties (aka Consumers). @@ -298,17 +297,11 @@ def complete(query, current_url) protected def session_get(name) - value = @session[session_key(name)] - - if value.is_a?(Array) # new serialized format - Serializer.deserialize(*value) - else # deprecated object format - value - end + @session[session_key(name)] end def session_set(name, val) - @session[session_key(name)] = Serializer.serialize(val) + @session[session_key(name)] = val end def session_key(suffix) diff --git a/lib/openid/consumer/discovery.rb b/lib/openid/consumer/discovery.rb index 57081ecb..acf29b0f 100644 --- a/lib/openid/consumer/discovery.rb +++ b/lib/openid/consumer/discovery.rb @@ -58,7 +58,7 @@ def initialize def display_identifier return @display_identifier if @display_identifier - return @claimed_id if @claimed_id.nil? + return @claimed_id if @claimed_id.nil? begin parsed_identifier = URI.parse(@claimed_id) @@ -376,7 +376,7 @@ def self.discover_yadis(uri) # # @param uri: normalized identity URL # @type uri: str - # + # # @return: (claimed_id, services) # @rtype: (str, list(OpenIDServiceEndpoint)) # diff --git a/lib/openid/serializer.rb b/lib/openid/serializer.rb deleted file mode 100644 index 0d404e8e..00000000 --- a/lib/openid/serializer.rb +++ /dev/null @@ -1,21 +0,0 @@ -module OpenID - class Serializer - SERIALIZABLE = { - "OpenID::OpenIDServiceEndpoint" => [OpenID::OpenIDServiceEndpoint, 0], - "OpenID::Consumer::DiscoveredServices" => [OpenID::Consumer::DiscoveredServices, 3] - } - - def self.serialize(instance) - klass = instance.class.name - raise "unable to serialize #{klass}" unless SERIALIZABLE[klass] - [klass, instance.instance_variables.map { |v| [v.to_s, instance.instance_variable_get(v)] }] - end - - def self.deserialize(klass, data) - klass, arguments = SERIALIZABLE[klass] || raise("unable to deserialize #{klass}") - instance = klass.new(*Array.new(arguments)) - data.each { |k,v| instance.instance_variable_set(k,v) } - instance - end - end -end diff --git a/test/test_consumer.rb b/test/test_consumer.rb index 1d470459..05944884 100644 --- a/test/test_consumer.rb +++ b/test/test_consumer.rb @@ -6,24 +6,14 @@ module OpenID class Consumer module TestConsumer class TestLastEndpoint < Test::Unit::TestCase - def all_instance_variables(object) - object.instance_variables.map { |v| [v.to_s, object.instance_variable_get(v)] } - end - def test_set_get - stored = OpenID::OpenIDServiceEndpoint.new - stored.server_url = "test" session = {} - consumer = Consumer.new(session, nil) - consumer.send(:last_requested_endpoint=, stored) - + consumer.send(:last_requested_endpoint=, :endpoint) ep = consumer.send(:last_requested_endpoint) - assert_equal(all_instance_variables(stored), all_instance_variables(ep)) - + assert_equal(:endpoint, ep) ep = consumer.send(:last_requested_endpoint) - assert_equal(all_instance_variables(stored), all_instance_variables(ep)) - + assert_equal(:endpoint, ep) consumer.send(:cleanup_last_requested_endpoint) ep = consumer.send(:last_requested_endpoint) assert_equal(nil, ep) @@ -120,7 +110,7 @@ def call_begin_without_discovery result = consumer.begin_without_discovery(@service, @anonymous) assert(result.instance_of?(CheckIDRequest)) assert_equal(@anonymous, result.anonymous) - assert_equal(@service.claimed_id, consumer.send(:last_requested_endpoint).claimed_id) + assert_equal(@service, consumer.send(:last_requested_endpoint)) assert_equal(result.instance_variable_get(:@assoc), @assoc) return result end