added test to make sure password is not leaked in user json/xml feed
This commit is contained in:
@@ -17,7 +17,8 @@ module Danbooru
|
|||||||
options[:except] += hidden_attributes
|
options[:except] += hidden_attributes
|
||||||
super(options, &block)
|
super(options, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
def hidden_attributes
|
def hidden_attributes
|
||||||
[:uploader_ip_addr, :updater_ip_addr, :creator_ip_addr, :ip_addr]
|
[:uploader_ip_addr, :updater_ip_addr, :creator_ip_addr, :ip_addr]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -156,6 +156,24 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "ip address" do
|
||||||
|
setup do
|
||||||
|
@user = Factory.create(:user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "in the json representation" do
|
||||||
|
should "not appear" do
|
||||||
|
assert(@user.to_json !~ /addr/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "in the xml representation" do
|
||||||
|
should "not appear" do
|
||||||
|
assert(@user.to_xml !~ /addr/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "password" do
|
context "password" do
|
||||||
should "match the confirmation" do
|
should "match the confirmation" do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
@@ -187,6 +205,26 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
new_pass = @user.reset_password
|
new_pass = @user.reset_password
|
||||||
assert(User.authenticate(@user.name, new_pass), "Authentication should have succeeded")
|
assert(User.authenticate(@user.name, new_pass), "Authentication should have succeeded")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "in the json representation" do
|
||||||
|
setup do
|
||||||
|
@user = Factory.create(:user)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not appear" do
|
||||||
|
assert(@user.to_json !~ /password/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "in the xml representation" do
|
||||||
|
setup do
|
||||||
|
@user = Factory.create(:user)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not appear" do
|
||||||
|
assert(@user.to_xml !~ /password/)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user