@ -45,38 +45,49 @@ func TestSettingShowUserEmailProfile(t *testing.T) {
defer tests . PrepareTestEnv ( t ) ( )
defer tests . PrepareTestEnv ( t ) ( )
showUserEmail := setting . UI . ShowUserEmail
showUserEmail := setting . UI . ShowUserEmail
// user1: keep_email_private = false, user2: keep_email_private = true
setting . UI . ShowUserEmail = true
setting . UI . ShowUserEmail = true
session := loginUser ( t , "user2" )
// user1 can see self
req := NewRequest ( t , "GET" , "/user2" )
session := loginUser ( t , "user1" )
req := NewRequest ( t , "GET" , "/user1" )
resp := session . MakeRequest ( t , req , http . StatusOK )
resp := session . MakeRequest ( t , req , http . StatusOK )
htmlDoc := NewHTMLParser ( t , resp . Body )
htmlDoc := NewHTMLParser ( t , resp . Body )
assert . Contains ( t ,
assert . Contains ( t , htmlDoc . doc . Find ( ".user.profile" ) . Text ( ) , "user1@example.com" )
htmlDoc . doc . Find ( ".user.profile" ) . Text ( ) ,
"user2@example.com" ,
)
setting . UI . ShowUserEmail = false
// user1 can not see user2
req = NewRequest ( t , "GET" , "/user2" )
req = NewRequest ( t , "GET" , "/user2" )
resp = session . MakeRequest ( t , req , http . StatusOK )
resp = session . MakeRequest ( t , req , http . StatusOK )
htmlDoc = NewHTMLParser ( t , resp . Body )
htmlDoc = NewHTMLParser ( t , resp . Body )
// Should contain since this user owns the profile page
// Should not contain even if the user visits their own profile page
assert . Contains ( t ,
assert . NotContains ( t , htmlDoc . doc . Find ( ".user.profile" ) . Text ( ) , "user2@example.com" )
htmlDoc . doc . Find ( ".user.profile" ) . Text ( ) ,
"user2@example.com" ,
)
setting . UI . ShowUserEmail = showUserEmail
// user2 can see user1
session = loginUser ( t , "user2" )
req = NewRequest ( t , "GET" , "/user1" )
resp = session . MakeRequest ( t , req , http . StatusOK )
htmlDoc = NewHTMLParser ( t , resp . Body )
assert . Contains ( t , htmlDoc . doc . Find ( ".user.profile" ) . Text ( ) , "user1@example.com" )
session = loginUser ( t , "user4" )
// user2 can not see self
session = loginUser ( t , "user2" )
req = NewRequest ( t , "GET" , "/user2" )
req = NewRequest ( t , "GET" , "/user2" )
resp = session . MakeRequest ( t , req , http . StatusOK )
resp = session . MakeRequest ( t , req , http . StatusOK )
htmlDoc = NewHTMLParser ( t , resp . Body )
htmlDoc = NewHTMLParser ( t , resp . Body )
assert . NotContains ( t ,
assert . NotContains ( t , htmlDoc . doc . Find ( ".user.profile" ) . Text ( ) , "user2@example.com" )
htmlDoc . doc . Find ( ".user.profile" ) . Text ( ) ,
"user2@example.com" ,
setting . UI . ShowUserEmail = false
)
// user1 can not see self
session = loginUser ( t , "user1" )
req = NewRequest ( t , "GET" , "/user1" )
resp = session . MakeRequest ( t , req , http . StatusOK )
htmlDoc = NewHTMLParser ( t , resp . Body )
assert . NotContains ( t , htmlDoc . doc . Find ( ".user.profile" ) . Text ( ) , "user1@example.com" )
setting . UI . ShowUserEmail = showUserEmail
}
}
func TestSettingLandingPage ( t * testing . T ) {
func TestSettingLandingPage ( t * testing . T ) {