forked from andreaseger/sinatra-browserid
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.5.0: Switch to token['sub'], add normalization, tests
In the future the token will no longer contain ['email']. Normalization is done by the broker now, the simpleidn gem used here however does not always produce the same result. Merging mmriis/simpleidn#13 will fix this.
- Loading branch information
Showing
6 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs << 'test' | ||
end | ||
|
||
desc "Run tests" | ||
task :default => :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'minitest/autorun' | ||
require 'sinatra/portier.rb' | ||
|
||
|
||
class NormalizationTest < Minitest::Test | ||
include Sinatra::BrowserID::Helpers | ||
def test_valid | ||
assert_equal("example.foo+bar@example.com", normalize_email("example.foo+bar@example.com")) | ||
assert_equal("example.foo+bar@example.com", normalize_email("EXAMPLE.FOO+BAR@EXAMPLE.COM")) | ||
assert_equal("björn@xn--gteborg-90a.test", normalize_email("BJÖRN@göteborg.test")) | ||
assert_equal("i̇ⅲ@xn--iiii-qwc.example", normalize_email("İⅢ@İⅢ.example")) | ||
end | ||
|
||
def test_invalid | ||
assert_raises("ArgumentError") { | ||
normalize_email("foo") | ||
} | ||
assert_raises("ArgumentError") { | ||
normalize_email("foo@") | ||
} | ||
assert_raises("ArgumentError") { | ||
normalize_email("@foo.example") | ||
} | ||
assert_raises("ArgumentError") { | ||
normalize_email("foo@127.0.0.1") | ||
} | ||
assert_raises("ArgumentError") { | ||
normalize_email("foo@[::1]") | ||
} | ||
end | ||
end |