1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-07 21:47:02 +09:00

Merge pull request #458 from anyproto/GO-5710-correct-validation

GO-5710: Implement correct validation
This commit is contained in:
Mikhail Rakhmanov 2025-05-26 14:20:43 +02:00 committed by GitHub
commit 55e398cfdc
Signed by: github
GPG key ID: B5690EEEBB952194
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 (