]> git.openstreetmap.org Git - rails.git/blob - vendor/plugins/open_id_authentication/test/normalize_test.rb
Merge branch 'master' into openid
[rails.git] / vendor / plugins / open_id_authentication / test / normalize_test.rb
1 require File.dirname(__FILE__) + '/test_helper'
2
3 class NormalizeTest < Test::Unit::TestCase
4   include OpenIdAuthentication
5
6   NORMALIZATIONS = {
7     "openid.aol.com/nextangler"             => "http://openid.aol.com/nextangler",
8     "http://openid.aol.com/nextangler"      => "http://openid.aol.com/nextangler",
9     "https://openid.aol.com/nextangler"     => "https://openid.aol.com/nextangler",
10     "HTTP://OPENID.AOL.COM/NEXTANGLER"      => "http://openid.aol.com/NEXTANGLER",
11     "HTTPS://OPENID.AOL.COM/NEXTANGLER"     => "https://openid.aol.com/NEXTANGLER",
12     "loudthinking.com"                      => "http://loudthinking.com/",
13     "http://loudthinking.com"               => "http://loudthinking.com/",
14     "http://loudthinking.com:80"            => "http://loudthinking.com/",
15     "https://loudthinking.com:443"          => "https://loudthinking.com/",
16     "http://loudthinking.com:8080"          => "http://loudthinking.com:8080/",
17     "techno-weenie.net"                     => "http://techno-weenie.net/",
18     "http://techno-weenie.net"              => "http://techno-weenie.net/",
19     "http://techno-weenie.net  "            => "http://techno-weenie.net/",
20     "=name"                                 => "=name"
21   }
22
23   def test_normalizations
24     NORMALIZATIONS.each do |from, to|
25       assert_equal to, normalize_identifier(from)
26     end
27   end
28
29   def test_broken_open_id
30     assert_raises(InvalidOpenId) { normalize_identifier(nil) }
31   end
32 end