mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-07 21:47:02 +09:00
Implement correct validation
This commit is contained in:
parent
6ff6aee8b9
commit
1690896a67
2 changed files with 22 additions and 0 deletions
|
@ -178,6 +178,7 @@ func (a *aclList) ValidateRawRecord(rawRec *consensusproto.RawRecord, afterValid
|
|||
return
|
||||
}
|
||||
stateCopy := a.aclState.Copy()
|
||||
stateCopy.contentValidator = newContentValidator(stateCopy.keyStore, stateCopy, recordverifier.NewValidateFull())
|
||||
err = stateCopy.ApplyRecord(record)
|
||||
if err != nil || afterValid == nil {
|
||||
return
|
||||
|
|
|
@ -310,6 +310,27 @@ func TestAclList_MetadataDecrypt(t *testing.T) {
|
|||
require.NotEqual(t, mockMetadata, meta)
|
||||
}
|
||||
|
||||
func TestAclList_ValidateUsesCorrectVerifier(t *testing.T) {
|
||||
fx := newFixture(t)
|
||||
var ownerAcl = fx.ownerAcl
|
||||
ownerAcl.aclState.contentValidator.(*contentValidator).verifier = recordverifier.New()
|
||||
ownerAcl.verifier = recordverifier.New()
|
||||
// building invite
|
||||
inv, err := ownerAcl.RecordBuilder().BuildInvite()
|
||||
require.NoError(t, err)
|
||||
isCalled := false
|
||||
ok := ownerAcl.aclState.contentValidator.(*contentValidator).verifier.ShouldValidate()
|
||||
require.False(t, ok)
|
||||
err = fx.ownerAcl.ValidateRawRecord(inv.InviteRec, func(state *AclState) error {
|
||||
isCalled = true
|
||||
// check that we change the validator to the verifying one
|
||||
require.True(t, state.contentValidator.(*contentValidator).verifier.ShouldValidate())
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.True(t, isCalled)
|
||||
}
|
||||
|
||||
func TestAclList_ReadKeyChange(t *testing.T) {
|
||||
fx := newFixture(t)
|
||||
var (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue