From 7c84ec9ced3ccbdad575e02dbfa81e53b52f909e Mon Sep 17 00:00:00 2001 From: Tobias Haagen Michaelsen Date: Fri, 9 Jan 2015 11:33:23 +0100 Subject: [PATCH 1/4] Use RFC 2396 compatible URI parser for trustroot. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From Ruby 2.2 the default `URI.parse` method uses a new RFC 3986 compatible parser, which will parse most of the “invalid” URLs in the trustroot test. --- lib/openid/trustroot.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/openid/trustroot.rb b/lib/openid/trustroot.rb index 28c56292..80daec3d 100644 --- a/lib/openid/trustroot.rb +++ b/lib/openid/trustroot.rb @@ -178,7 +178,7 @@ def TrustRoot._parse_url(url) end begin - parsed = URI::parse(url) + parsed = URI::DEFAULT_PARSER.parse(url) rescue URI::InvalidURIError return nil end From fc499f74bc1a7b0578c9391859ae64684158164e Mon Sep 17 00:00:00 2001 From: Tobias Haagen Michaelsen Date: Fri, 9 Jan 2015 13:40:06 +0100 Subject: [PATCH 2/4] Added missing require statements in tests to run independently. Now you can run all test files individually, because each now correctly requires everything it needs. --- test/test_association.rb | 1 + test/test_associationmanager.rb | 2 ++ test/test_discovery_manager.rb | 2 +- test/test_pape.rb | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test_association.rb b/test/test_association.rb index dc9142b7..0721fee6 100644 --- a/test/test_association.rb +++ b/test/test_association.rb @@ -1,5 +1,6 @@ require "minitest/autorun" require "openid/association" +require "openid/protocolerror" module OpenID class AssociationTestCase < Minitest::Test diff --git a/test/test_associationmanager.rb b/test/test_associationmanager.rb index 8a2eaf24..47c22645 100644 --- a/test/test_associationmanager.rb +++ b/test/test_associationmanager.rb @@ -1,10 +1,12 @@ require "minitest/autorun" +require "testutil" require "openid/consumer/associationmanager" require "openid/association" require "openid/dh" require "openid/util" require "openid/cryptutil" require "openid/message" +require "openid/protocolerror" require "openid/store/memory" require "util" require "time" diff --git a/test/test_discovery_manager.rb b/test/test_discovery_manager.rb index 830d0059..9a8abc22 100644 --- a/test/test_discovery_manager.rb +++ b/test/test_discovery_manager.rb @@ -1,5 +1,5 @@ require 'minitest/autorun' -require 'openid/consumer/discovery_manager' +require 'openid/consumer' require 'testutil' module OpenID diff --git a/test/test_pape.rb b/test/test_pape.rb index 2b9ff036..bd35bc78 100644 --- a/test/test_pape.rb +++ b/test/test_pape.rb @@ -2,7 +2,7 @@ require 'openid/extensions/pape' require 'openid/message' require 'openid/server' -require 'openid/consumer/responses' +require 'openid/consumer' module OpenID module PAPETest From 8a522e3aa66a2f119d6ad9cf0238f865aac71857 Mon Sep 17 00:00:00 2001 From: Tobias Haagen Michaelsen Date: Fri, 9 Jan 2015 13:52:42 +0100 Subject: [PATCH 3/4] Don't use explicit `return` inside Proc. An explicit return inside a Proc can return from the current scope. This fixes an issue with the test exiting before all tests are run. --- test/test_discover.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/test_discover.rb b/test/test_discover.rb index 3a51b567..da873728 100644 --- a/test/test_discover.rb +++ b/test/test_discover.rb @@ -746,13 +746,9 @@ def test_discover_function # XXX these were all different tests in python, but they're # combined here so I only have to use with_method_overridden # once. - discoverXRI = Proc.new { |identifier| - return 'XRI' - } + discoverXRI = Proc.new { |identifier| 'XRI' } - discoverURI = Proc.new { |identifier| - return 'URI' - } + discoverURI = Proc.new { |identifier| 'URI' } OpenID.extend(OverrideMethodMixin) From b6402eb3cac8e76d748ff58aa7513ef196d4da1f Mon Sep 17 00:00:00 2001 From: Tobias Haagen Michaelsen Date: Fri, 9 Jan 2015 14:14:27 +0100 Subject: [PATCH 4/4] Don't test Ruby's build in methods. This test became obsolete after openid/ruby-openid#61 was merged, since the code now uses Ruby's build in `String#start_with?` rather than a custom implementation. --- test/test_extras.rb | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 test/test_extras.rb diff --git a/test/test_extras.rb b/test/test_extras.rb deleted file mode 100644 index ffc89266..00000000 --- a/test/test_extras.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'minitest/autorun' - -class StartsWithTestCase < Minitest::Test - def test_starts_with - [["anything", ""], - ["something else", ""], - ["", ""], - ["foos", "foo"], - ].each{|str,target| assert(str.start_with?(target))} - end - - def test_not_starts_with - [["x", "y"], - ["foos", "ball"], - ["xx", "xy"], - ].each{|str,target| assert(!(str.start_with? target)) } - end - - def test_ends_with - [["anything", ""], - ["something else", " else"], - ["", ""], - ["foos", "oos"], - ].each{|str,target| assert(str.end_with?(target))} - end - - def test_not_ends_with - [["x", "y"], - ["foos", "ball"], - ["xx", "xy"], - ["foosball", "foosbal"], - ].each{|str,target| assert(!(str.end_with? target)) } - end -end