Fix first ACL test and threadbuilder
This commit is contained in:
parent
43dbdd8d68
commit
70b2068f3f
@ -19,6 +19,7 @@ func TestACLStateBuilder_UserJoinBuild(t *testing.T) {
|
|||||||
keychain.GetIdentity("A"),
|
keychain.GetIdentity("A"),
|
||||||
keychain.EncryptionKeys["A"],
|
keychain.EncryptionKeys["A"],
|
||||||
threadmodels.NewEd25519Decoder(),
|
threadmodels.NewEd25519Decoder(),
|
||||||
|
NewPlainTextDocumentStateProvider(),
|
||||||
false)
|
false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should build acl aclState without err: %v", err)
|
t.Fatalf("should build acl aclState without err: %v", err)
|
||||||
@ -53,6 +54,7 @@ func TestACLStateBuilder_UserRemoveBuild(t *testing.T) {
|
|||||||
keychain.GetIdentity("A"),
|
keychain.GetIdentity("A"),
|
||||||
keychain.EncryptionKeys["A"],
|
keychain.EncryptionKeys["A"],
|
||||||
threadmodels.NewEd25519Decoder(),
|
threadmodels.NewEd25519Decoder(),
|
||||||
|
NewPlainTextDocumentStateProvider(),
|
||||||
false)
|
false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should build acl aclState without err: %v", err)
|
t.Fatalf("should build acl aclState without err: %v", err)
|
||||||
@ -83,6 +85,7 @@ func TestACLStateBuilder_UserRemoveBeforeBuild(t *testing.T) {
|
|||||||
keychain.GetIdentity("A"),
|
keychain.GetIdentity("A"),
|
||||||
keychain.EncryptionKeys["A"],
|
keychain.EncryptionKeys["A"],
|
||||||
threadmodels.NewEd25519Decoder(),
|
threadmodels.NewEd25519Decoder(),
|
||||||
|
NewPlainTextDocumentStateProvider(),
|
||||||
false)
|
false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should build acl aclState without err: %v", err)
|
t.Fatalf("should build acl aclState without err: %v", err)
|
||||||
@ -114,6 +117,7 @@ func TestACLStateBuilder_InvalidSnapshotBuild(t *testing.T) {
|
|||||||
keychain.GetIdentity("A"),
|
keychain.GetIdentity("A"),
|
||||||
keychain.EncryptionKeys["A"],
|
keychain.EncryptionKeys["A"],
|
||||||
threadmodels.NewEd25519Decoder(),
|
threadmodels.NewEd25519Decoder(),
|
||||||
|
NewPlainTextDocumentStateProvider(),
|
||||||
false)
|
false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should build acl aclState without err: %v", err)
|
t.Fatalf("should build acl aclState without err: %v", err)
|
||||||
@ -144,6 +148,7 @@ func TestACLStateBuilder_ValidSnapshotBuild(t *testing.T) {
|
|||||||
keychain.GetIdentity("A"),
|
keychain.GetIdentity("A"),
|
||||||
keychain.EncryptionKeys["A"],
|
keychain.EncryptionKeys["A"],
|
||||||
threadmodels.NewEd25519Decoder(),
|
threadmodels.NewEd25519Decoder(),
|
||||||
|
NewPlainTextDocumentStateProvider(),
|
||||||
false)
|
false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should build acl aclState without err: %v", err)
|
t.Fatalf("should build acl aclState without err: %v", err)
|
||||||
|
|||||||
@ -17,21 +17,14 @@ func TestDocumentStateBuilder_UserJoinBuild(t *testing.T) {
|
|||||||
thread,
|
thread,
|
||||||
keychain.GetIdentity("A"),
|
keychain.GetIdentity("A"),
|
||||||
keychain.EncryptionKeys["A"],
|
keychain.EncryptionKeys["A"],
|
||||||
|
NewPlainTextDocumentStateProvider(),
|
||||||
threadmodels.NewEd25519Decoder())
|
threadmodels.NewEd25519Decoder())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should build acl aclState without err: %v", err)
|
t.Fatalf("should build acl aclState without err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
st := ctx.DocState
|
st := ctx.DocState.(*PlainTextDocumentState)
|
||||||
allIds := make(map[string]bool)
|
assert.Equal(t, st.Text, "")
|
||||||
for _, b := range st.Blocks() {
|
|
||||||
allIds[b.Id] = true
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("iterate should not return error: %v", err)
|
|
||||||
}
|
|
||||||
assert.True(t, allIds["root"])
|
|
||||||
assert.True(t, allIds["first"])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDocumentStateBuilder_UserRemoveBuild(t *testing.T) {
|
func TestDocumentStateBuilder_UserRemoveBuild(t *testing.T) {
|
||||||
@ -44,19 +37,12 @@ func TestDocumentStateBuilder_UserRemoveBuild(t *testing.T) {
|
|||||||
thread,
|
thread,
|
||||||
keychain.GetIdentity("A"),
|
keychain.GetIdentity("A"),
|
||||||
keychain.EncryptionKeys["A"],
|
keychain.EncryptionKeys["A"],
|
||||||
|
NewPlainTextDocumentStateProvider(),
|
||||||
threadmodels.NewEd25519Decoder())
|
threadmodels.NewEd25519Decoder())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should build acl aclState without err: %v", err)
|
t.Fatalf("should build acl aclState without err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
st := ctx.DocState
|
st := ctx.DocState.(*PlainTextDocumentState)
|
||||||
allIds := make(map[string]bool)
|
assert.Equal(t, st.Text, "")
|
||||||
for _, b := range st.Blocks() {
|
|
||||||
allIds[b.Id] = true
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("iterate should not return error: %v", err)
|
|
||||||
}
|
|
||||||
assert.True(t, allIds["root"])
|
|
||||||
assert.True(t, allIds["second"])
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,6 +47,10 @@ func (p *PlainTextDocumentState) applyChange(ch *pb.PlainTextChangeContent) erro
|
|||||||
|
|
||||||
type PlainTextDocumentStateProvider struct{}
|
type PlainTextDocumentStateProvider struct{}
|
||||||
|
|
||||||
|
func NewPlainTextDocumentStateProvider() *PlainTextDocumentStateProvider {
|
||||||
|
return &PlainTextDocumentStateProvider{}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PlainTextDocumentStateProvider) ProvideFromInitialChange(change []byte, id string) (DocumentState, error) {
|
func (p *PlainTextDocumentStateProvider) ProvideFromInitialChange(change []byte, id string) (DocumentState, error) {
|
||||||
var changesData pb.PlainTextChangeData
|
var changesData pb.PlainTextChangeData
|
||||||
err := proto.Unmarshal(change, &changesData)
|
err := proto.Unmarshal(change, &changesData)
|
||||||
|
|||||||
@ -126,7 +126,7 @@ func (t *ThreadBuilder) Parse(thread *YMLThread) {
|
|||||||
newChange.readKey = k
|
newChange.readKey = k
|
||||||
newChange.signKey = t.keychain.SigningKeys[ch.Identity]
|
newChange.signKey = t.keychain.SigningKeys[ch.Identity]
|
||||||
aclChange := &pb.ACLChange{}
|
aclChange := &pb.ACLChange{}
|
||||||
aclChange.Identity = ch.Identity
|
aclChange.Identity = t.keychain.GetIdentity(ch.Identity)
|
||||||
if len(ch.AclChanges) > 0 || ch.AclSnapshot != nil {
|
if len(ch.AclChanges) > 0 || ch.AclSnapshot != nil {
|
||||||
aclChange.AclData = &pb.ACLChangeACLData{}
|
aclChange.AclData = &pb.ACLChangeACLData{}
|
||||||
if ch.AclSnapshot != nil {
|
if ch.AclSnapshot != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user