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