1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

Implement correct validation

This commit is contained in:
Mikhail Rakhmanov 2025-05-26 12:33:49 +02:00
parent 6ff6aee8b9
commit 1690896a67
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
2 changed files with 22 additions and 0 deletions

View file

@ -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

View file

@ -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 (