test/test_server.rb in ruby-openid-2.2.3 vs test/test_server.rb in ruby-openid-2.3.0

- old
+ new

@@ -54,11 +54,11 @@ expected_args = { 'openid.mode' => 'error', 'openid.error' => 'plucky', } - rt_base, result_args = e.encode_to_url.split('?', 2) + _, result_args = e.encode_to_url.split('?', 2) result_args = Util.parse_query(result_args) assert_equal(result_args, expected_args) end def test_browserWithReturnTo_OpenID2_GET @@ -78,11 +78,11 @@ 'openid.ns' => OPENID2_NS, 'openid.mode' => 'error', 'openid.error' => 'plucky', } - rt_base, result_args = e.encode_to_url.split('?', 2) + _, result_args = e.encode_to_url.split('?', 2) result_args = Util.parse_query(result_args) assert_equal(result_args, expected_args) end def test_browserWithReturnTo_OpenID2_POST @@ -96,16 +96,10 @@ 'openid.claimed_id' => 'http://wagu.unittest/', 'openid.return_to' => return_to, }) e = Server::ProtocolError.new(args, "plucky") assert(e.has_return_to) - expected_args = { - 'openid.ns' => OPENID2_NS, - 'openid.mode' => 'error', - 'openid.error' => 'plucky', - } - assert(e.which_encoding == Server::ENCODE_HTML_FORM) assert(e.to_form_markup == e.to_message.to_form_markup( args.get_arg(OPENID_NS, 'return_to'))) end @@ -125,11 +119,11 @@ 'openid.error' => 'plucky', } assert(e.which_encoding == Server::ENCODE_URL) - rt_base, result_args = e.encode_to_url.split('?', 2) + _, result_args = e.encode_to_url.split('?', 2) result_args = Util.parse_query(result_args) assert_equal(result_args, expected_args) end def test_noReturnTo @@ -659,11 +653,11 @@ def test_invalidns args = {'openid.ns' => 'Vegetables', 'openid.mode' => 'associate'} begin - r = @decode.call(args) + @decode.call(args) rescue Server::ProtocolError => err assert(err.openid_message) assert(err.to_s.index('Vegetables')) end end @@ -1202,13 +1196,12 @@ _expectAnswer(answer, selected_id) end def test_answerAllowWithNoIdentity @request.identity = IDENTIFIER_SELECT - selected_id = 'http://anon.unittest/9861' assert_raise(ArgumentError) { - answer = @request.answer(true, nil, nil) + @request.answer(true, nil, nil) } end def test_immediate_openid1_no_identity @request.message = Message.new(OPENID1_NS) @@ -1231,11 +1224,11 @@ @request.immediate = true @request.mode = 'checkid_immediate' @request.op_endpoint = nil assert_raise(ArgumentError) { - resp = @request.answer(false) + @request.answer(false) } end def test_immediate_encode_to_url @request.message = Message.new(OPENID1_NS) @@ -1247,11 +1240,11 @@ server_url = "http://server.com/server" url = @request.encode_to_url(server_url) assert(url.starts_with?(server_url)) - unused, query = url.split("?", 2) + _, query = url.split("?", 2) args = Util.parse_query(query) m = Message.from_post_args(args) assert(m.get_arg(OPENID_NS, 'trust_root') == "BOGUS") assert(m.get_arg(OPENID_NS, 'assoc_handle') == "ASSOC") @@ -1445,11 +1438,11 @@ def test_encodeToURL server_url = 'http://openid-server.unittest/' result = @request.encode_to_url(server_url) # How to check? How about a round-trip test. - base, result_args = result.split('?', 2) + _, result_args = result.split('?', 2) result_args = Util.parse_query(result_args) message = Message.from_post_args(result_args) rebuilt_request = Server::CheckIDRequest.from_message(message, @server.op_endpoint) @@ -1917,20 +1910,10 @@ @request.answer_unsupported(m) } end end - class Counter - def initialize - @count = 0 - end - - def inc - @count += 1 - end - end - class UnhandledError < Exception end class TestServer < Test::Unit::TestCase include TestUtil @@ -1944,11 +1927,11 @@ def test_failed_dispatch request = Server::OpenIDRequest.new() request.mode = "monkeymode" request.message = Message.new(OPENID1_NS) assert_raise(RuntimeError) { - webresult = @server.handle_request(request) + @server.handle_request(request) } end def test_decode_request @server.decoder = BogusDecoder.new(@server) @@ -1959,22 +1942,20 @@ @server.encoder = BogusEncoder.new assert(@server.encode_response(nil) == "BOGUS") end def test_dispatch - monkeycalled = Counter.new() - @server.extend(InstanceDefExtension) @server.instance_def(:openid_monkeymode) do |request| raise UnhandledError end request = Server::OpenIDRequest.new() request.mode = "monkeymode" request.message = Message.new(OPENID1_NS) assert_raise(UnhandledError) { - webresult = @server.handle_request(request) + @server.handle_request(request) } end def test_associate request = Server::AssociateRequest.from_message(Message.from_post_args({})) @@ -2058,10 +2039,10 @@ assert_log_matches(/Continuing anyway./) { m = Message.from_openid_args({ 'session_type' => 'no-encryption', }) - req = Server::AssociateRequest.from_message(m) + Server::AssociateRequest.from_message(m) } end def test_missingSessionTypeOpenID2 # Make sure session_type is required in OpenID 2