mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 14:07:02 +09:00
testAclState
This commit is contained in:
parent
c6ac38edb3
commit
036e4f85f7
1 changed files with 29 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/liststorage"
|
||||
"github.com/anyproto/any-sync/consensus/consensusproto"
|
||||
|
@ -53,3 +55,30 @@ func NewTestAclWithRoot(keys *accountdata.AccountKeys, root *consensusproto.RawR
|
|||
}
|
||||
return BuildAclListWithIdentity(keys, st, NoOpAcceptorVerifier{})
|
||||
}
|
||||
|
||||
func NewTestAclStateWithUsers(numWriters, numReaders, numInvites int) *AclState {
|
||||
st := &AclState{
|
||||
keys: make(map[string]AclKeys),
|
||||
accountStates: make(map[string]AccountState),
|
||||
inviteKeys: make(map[string]crypto.PubKey),
|
||||
requestRecords: make(map[string]RequestRecord),
|
||||
pendingRequests: make(map[string]string),
|
||||
keyStore: crypto.NewKeyStorage(),
|
||||
}
|
||||
for i := 0; i < numWriters; i++ {
|
||||
st.accountStates[fmt.Sprint("w", i)] = AccountState{
|
||||
Permissions: AclPermissionsWriter,
|
||||
Status: StatusActive,
|
||||
}
|
||||
}
|
||||
for i := 0; i < numReaders; i++ {
|
||||
st.accountStates[fmt.Sprint("r", i)] = AccountState{
|
||||
Permissions: AclPermissionsReader,
|
||||
Status: StatusActive,
|
||||
}
|
||||
}
|
||||
for i := 0; i < numInvites; i++ {
|
||||
st.inviteKeys[fmt.Sprint("r", i)] = nil
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue