Add obfuscation of link share passwords when retrieving them
This commit is contained in:
parent
96553f7f7d
commit
e96911e39c
|
@ -22,3 +22,12 @@
|
||||||
shared_by_id: 1
|
shared_by_id: 1
|
||||||
created: 2018-12-01 15:13:12
|
created: 2018-12-01 15:13:12
|
||||||
updated: 2018-12-02 15:13:12
|
updated: 2018-12-02 15:13:12
|
||||||
|
- id: 4
|
||||||
|
hash: testWithPassword
|
||||||
|
list_id: 1
|
||||||
|
right: 0
|
||||||
|
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
|
||||||
|
sharing_type: 2
|
||||||
|
shared_by_id: 1
|
||||||
|
created: 2018-12-01 15:13:12
|
||||||
|
updated: 2018-12-02 15:13:12
|
||||||
|
|
|
@ -81,3 +81,59 @@ func TestLinkSharing_Create(t *testing.T) {
|
||||||
}, false)
|
}, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLinkSharing_ReadAll(t *testing.T) {
|
||||||
|
doer := &user.User{ID: 1}
|
||||||
|
|
||||||
|
t.Run("all no password", func(t *testing.T) {
|
||||||
|
db.LoadAndAssertFixtures(t)
|
||||||
|
s := db.NewSession()
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
|
share := &LinkSharing{
|
||||||
|
ListID: 1,
|
||||||
|
}
|
||||||
|
all, _, _, err := share.ReadAll(s, doer, "", 1, -1)
|
||||||
|
shares := all.([]*LinkSharing)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Len(t, shares, 2)
|
||||||
|
for _, sharing := range shares {
|
||||||
|
assert.Empty(t, sharing.Password)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLinkSharing_ReadOne(t *testing.T) {
|
||||||
|
doer := &user.User{ID: 1}
|
||||||
|
|
||||||
|
t.Run("normal", func(t *testing.T) {
|
||||||
|
db.LoadAndAssertFixtures(t)
|
||||||
|
s := db.NewSession()
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
|
share := &LinkSharing{
|
||||||
|
ID: 1,
|
||||||
|
}
|
||||||
|
err := share.ReadOne(s, doer)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NotEmpty(t, share.Hash)
|
||||||
|
assert.Equal(t, SharingTypeWithoutPassword, share.SharingType)
|
||||||
|
})
|
||||||
|
t.Run("with password", func(t *testing.T) {
|
||||||
|
db.LoadAndAssertFixtures(t)
|
||||||
|
s := db.NewSession()
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
|
share := &LinkSharing{
|
||||||
|
ID: 4,
|
||||||
|
}
|
||||||
|
err := share.ReadOne(s, doer)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NotEmpty(t, share.Hash)
|
||||||
|
assert.Equal(t, SharingTypeWithPassword, share.SharingType)
|
||||||
|
assert.Empty(t, share.Password)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue