mirror of
https://github.com/diaspora/diaspora.git
synced 2026-04-29 03:01:03 -04:00
added tests to make sure Person.by_webfinger only returns exact matches
This commit is contained in:
@@ -97,7 +97,7 @@ class Person
|
||||
# Raise an error if identifier is not a valid email (generous regexp)
|
||||
raise "Identifier is invalid" if !(identifier =~ /\A.*\@.*\..*\Z/)
|
||||
|
||||
query = /#{Regexp.escape(identifier.gsub('acct:', '').to_s)}/i
|
||||
query = /\A^#{Regexp.escape(identifier.gsub('acct:', '').to_s)}\z/i
|
||||
local_person = Person.first(:diaspora_handle => query)
|
||||
|
||||
if local_person
|
||||
|
||||
@@ -187,6 +187,25 @@ describe Person do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it 'should only find people who are exact matches' do
|
||||
user = Factory(:user, :username => "SaMaNtHa")
|
||||
person = Factory(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com")
|
||||
user.person.diaspora_handle = "tom@tom.joindiaspora.com"
|
||||
user.person.save
|
||||
Person.by_webfinger("tom@tom.joindiaspora.com").diaspora_handle.should == "tom@tom.joindiaspora.com"
|
||||
end
|
||||
|
||||
it 'should return nil if there is not an exact match' do
|
||||
Redfinger.stub!(:finger).and_return(nil)
|
||||
Person.stub!(:from_webfinger_profile).and_return(false)
|
||||
|
||||
person = Factory(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com")
|
||||
#Person.by_webfinger("tom@tom.joindiaspora.com").should_be false
|
||||
proc{ Person.by_webfinger("tom@tom.joindiaspora.com")}.should raise_error
|
||||
end
|
||||
|
||||
|
||||
it 'identifier should be a valid email' do
|
||||
stub_success("joe.valid+email@my-address.com")
|
||||
Proc.new {
|
||||
|
||||
Reference in New Issue
Block a user