strip voted_ip from response
This commit is contained in:
@@ -425,7 +425,8 @@ func TestRest_Vote(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, cr.Score)
|
||||
assert.Equal(t, 1, cr.Vote)
|
||||
assert.Equal(t, map[string]bool(nil), cr.Votes)
|
||||
assert.Equal(t, map[string]bool(nil), cr.Votes, "hidden")
|
||||
assert.Equal(t, map[string]store.VotedIPInfo(nil), cr.VotedIPs, "hidden")
|
||||
|
||||
assert.Equal(t, 200, vote(-1), "opposite vote allowed")
|
||||
body, code = getWithDevAuth(t, fmt.Sprintf("%s/api/v1/id/%s?site=remark42&url=https://radio-t.com/blah", ts.URL, id1))
|
||||
@@ -461,7 +462,8 @@ func TestRest_Vote(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, -1, cr.Score)
|
||||
assert.Equal(t, 0, cr.Vote, "no vote info for not authed user")
|
||||
assert.Equal(t, map[string]bool(nil), cr.Votes)
|
||||
assert.Equal(t, map[string]bool(nil), cr.Votes, "hidden")
|
||||
assert.Equal(t, map[string]store.VotedIPInfo(nil), cr.VotedIPs, "hidden")
|
||||
|
||||
req, err := http.NewRequest("GET",
|
||||
fmt.Sprintf("%s/api/v1/id/%s?site=remark42&url=https://radio-t.com/blah", ts.URL, id1), nil)
|
||||
@@ -474,7 +476,8 @@ func TestRest_Vote(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, -1, cr.Score)
|
||||
assert.Equal(t, 0, cr.Vote, "no vote info for different user")
|
||||
assert.Equal(t, map[string]bool(nil), cr.Votes)
|
||||
assert.Equal(t, map[string]bool(nil), cr.Votes, "hidden")
|
||||
assert.Equal(t, map[string]store.VotedIPInfo(nil), cr.VotedIPs, "hidden")
|
||||
}
|
||||
|
||||
func TestRest_AnonVote(t *testing.T) {
|
||||
|
||||
@@ -83,6 +83,7 @@ func (c *Comment) PrepareUntrusted() {
|
||||
c.ID = "" // don't allow user to define ID, force auto-gen
|
||||
c.Timestamp = time.Time{} // reset time, force auto-gen
|
||||
c.Votes = make(map[string]bool)
|
||||
c.VotedIPs = make(map[string]VotedIPInfo)
|
||||
c.Score = 0
|
||||
c.Edit = nil
|
||||
c.Pin = false
|
||||
@@ -95,6 +96,7 @@ func (c *Comment) SetDeleted(mode DeleteMode) {
|
||||
c.Orig = ""
|
||||
c.Score = 0
|
||||
c.Votes = map[string]bool{}
|
||||
c.VotedIPs = make(map[string]VotedIPInfo)
|
||||
c.Edit = nil
|
||||
c.Deleted = true
|
||||
c.Pin = false
|
||||
|
||||
@@ -940,7 +940,8 @@ func (s *DataStore) prepVotes(c store.Comment, user store.User) store.Comment {
|
||||
}
|
||||
}
|
||||
|
||||
c.Votes = nil // hide voters list
|
||||
c.Votes = nil // hide voters list
|
||||
c.VotedIPs = nil // hide voted ips (hashes)
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ func TestService_VoteAggressive(t *testing.T) {
|
||||
|
||||
// random +1/-1 result should be [0..2]
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := 0; i < 100; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
Reference in New Issue
Block a user