Change ACL to Acl
This commit is contained in:
51 files changed
+1039
-1039
No files matched your search
+6
-6
@@ -22,8 +22,8 @@ func New() Service {
|
||||
}
|
||||
|
||||
type Service interface {
|
||||
CreateLog(ctx context.Context, aclId string, rawRec *aclrecordproto.RawACLRecord) (firstRecId string, err error)
|
||||
AddRecord(ctx context.Context, aclId string, rawRec *aclrecordproto.RawACLRecord) (id string, err error)
|
||||
CreateLog(ctx context.Context, aclId string, rawRec *aclrecordproto.RawAclRecord) (firstRecId string, err error)
|
||||
AddRecord(ctx context.Context, aclId string, rawRec *aclrecordproto.RawAclRecord) (id string, err error)
|
||||
Watch(ctx context.Context, spaceId, aclId string, h synchandler.SyncHandler) (err error)
|
||||
UnWatch(aclId string) (err error)
|
||||
app.Component
|
||||
@@ -44,7 +44,7 @@ func (s *service) Name() (name string) {
|
||||
return CName
|
||||
}
|
||||
|
||||
func (s *service) CreateLog(ctx context.Context, aclId string, rawRec *aclrecordproto.RawACLRecord) (firstRecId string, err error) {
|
||||
func (s *service) CreateLog(ctx context.Context, aclId string, rawRec *aclrecordproto.RawAclRecord) (firstRecId string, err error) {
|
||||
logId, err := cidToByte(aclId)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -68,7 +68,7 @@ func (s *service) CreateLog(ctx context.Context, aclId string, rawRec *aclrecord
|
||||
return cidToString(recId)
|
||||
}
|
||||
|
||||
func (s *service) AddRecord(ctx context.Context, aclId string, rawRec *aclrecordproto.RawACLRecord) (id string, err error) {
|
||||
func (s *service) AddRecord(ctx context.Context, aclId string, rawRec *aclrecordproto.RawAclRecord) (id string, err error) {
|
||||
logId, err := cidToByte(aclId)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -108,8 +108,8 @@ func (s *service) UnWatch(aclId string) (err error) {
|
||||
return s.consService.UnWatch(logId)
|
||||
}
|
||||
|
||||
func (s *service) signAndMarshal(rawRec *aclrecordproto.RawACLRecord) (recId, prevId, payload []byte, err error) {
|
||||
var rec = &aclrecordproto.ACLRecord{}
|
||||
func (s *service) signAndMarshal(rawRec *aclrecordproto.RawAclRecord) (recId, prevId, payload []byte, err error) {
|
||||
var rec = &aclrecordproto.AclRecord{}
|
||||
if err = rec.Unmarshal(rawRec.Payload); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestService_CreateLog(t *testing.T) {
|
||||
|
||||
aclId, _ := cidutil.NewCIDFromBytes([]byte("aclId"))
|
||||
|
||||
rec := &aclrecordproto.ACLRecord{
|
||||
rec := &aclrecordproto.AclRecord{
|
||||
PrevId: "",
|
||||
Identity: fx.account.Account().Identity,
|
||||
Data: []byte{'1', '2', '3'},
|
||||
@@ -38,7 +38,7 @@ func TestService_CreateLog(t *testing.T) {
|
||||
}
|
||||
pl, _ := rec.Marshal()
|
||||
|
||||
firstRecId, err := fx.CreateLog(ctx, aclId, &aclrecordproto.RawACLRecord{
|
||||
firstRecId, err := fx.CreateLog(ctx, aclId, &aclrecordproto.RawAclRecord{
|
||||
Payload: pl,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -48,7 +48,7 @@ func TestService_CreateLog(t *testing.T) {
|
||||
assert.NotEmpty(t, firstRecIdBytes)
|
||||
require.Len(t, clog.Records, 1)
|
||||
|
||||
var resultRawAcl = &aclrecordproto.RawACLRecord{}
|
||||
var resultRawAcl = &aclrecordproto.RawAclRecord{}
|
||||
require.NoError(t, resultRawAcl.Unmarshal(clog.Records[0].Payload))
|
||||
valid, err := fx.account.Account().SignKey.GetPublic().Verify(resultRawAcl.Payload, resultRawAcl.AcceptorSignature)
|
||||
require.NoError(t, err)
|
||||
@@ -65,7 +65,7 @@ func TestService_AddRecord(t *testing.T) {
|
||||
|
||||
aclId, _ := cidutil.NewCIDFromBytes([]byte("aclId"))
|
||||
|
||||
rec := &aclrecordproto.ACLRecord{
|
||||
rec := &aclrecordproto.AclRecord{
|
||||
PrevId: "",
|
||||
Identity: fx.account.Account().Identity,
|
||||
Data: []byte{'1', '2', '3'},
|
||||
@@ -73,7 +73,7 @@ func TestService_AddRecord(t *testing.T) {
|
||||
}
|
||||
pl, _ := rec.Marshal()
|
||||
|
||||
firstRecId, err := fx.CreateLog(ctx, aclId, &aclrecordproto.RawACLRecord{
|
||||
firstRecId, err := fx.CreateLog(ctx, aclId, &aclrecordproto.RawAclRecord{
|
||||
Payload: pl,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -85,7 +85,7 @@ func TestService_AddRecord(t *testing.T) {
|
||||
fx.mockClient.EXPECT().AddRecord(ctx, aclIdBytes, gomock.Any()).Do(func(ctx context.Context, logId []byte, rec *consensusproto.Record) {
|
||||
addRec = rec
|
||||
})
|
||||
rec = &aclrecordproto.ACLRecord{
|
||||
rec = &aclrecordproto.AclRecord{
|
||||
PrevId: firstRecId,
|
||||
Identity: fx.account.Account().Identity,
|
||||
Data: []byte{'1', '2', '3', '4'},
|
||||
@@ -93,7 +93,7 @@ func TestService_AddRecord(t *testing.T) {
|
||||
}
|
||||
pl, _ = rec.Marshal()
|
||||
|
||||
newRecId, err := fx.AddRecord(ctx, aclId, &aclrecordproto.RawACLRecord{
|
||||
newRecId, err := fx.AddRecord(ctx, aclId, &aclrecordproto.RawAclRecord{
|
||||
Payload: pl,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
+6
-6
@@ -37,7 +37,7 @@ func (w *watcher) AddConsensusRecords(recs []*consensusproto.Record) {
|
||||
w.isReady.Do(func() {
|
||||
close(w.ready)
|
||||
})
|
||||
records := make([]*aclrecordproto.RawACLRecordWithId, 0, len(recs))
|
||||
records := make([]*aclrecordproto.RawAclRecordWithId, 0, len(recs))
|
||||
|
||||
for _, rec := range recs {
|
||||
recId, err := cidToString(rec.Id)
|
||||
@@ -45,16 +45,16 @@ func (w *watcher) AddConsensusRecords(recs []*consensusproto.Record) {
|
||||
log.Error("received invalid id from consensus node", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
records = append(records, &aclrecordproto.RawACLRecordWithId{
|
||||
records = append(records, &aclrecordproto.RawAclRecordWithId{
|
||||
Payload: rec.Payload,
|
||||
Id: recId,
|
||||
})
|
||||
}
|
||||
|
||||
aclReq := &aclrecordproto.ACLSyncMessage{
|
||||
Content: &aclrecordproto.ACLSyncContentValue{
|
||||
Value: &aclrecordproto.ACLSyncContentValue_AddRecords{
|
||||
AddRecords: &aclrecordproto.ACLAddRecords{
|
||||
aclReq := &aclrecordproto.AclSyncMessage{
|
||||
Content: &aclrecordproto.AclSyncContentValue{
|
||||
Value: &aclrecordproto.AclSyncContentValue_AddRecords{
|
||||
AddRecords: &aclrecordproto.AclAddRecords{
|
||||
Records: records,
|
||||
},
|
||||
},
|
||||
|
||||
+10
-10
@@ -11,7 +11,7 @@ type listStorage struct {
|
||||
db *pogreb.DB
|
||||
keys aclKeys
|
||||
id string
|
||||
root *aclrecordproto.RawACLRecordWithId
|
||||
root *aclrecordproto.RawAclRecordWithId
|
||||
}
|
||||
|
||||
func newListStorage(db *pogreb.DB) (ls liststorage.ListStorage, err error) {
|
||||
@@ -21,7 +21,7 @@ func newListStorage(db *pogreb.DB) (ls liststorage.ListStorage, err error) {
|
||||
return
|
||||
}
|
||||
if rootId == nil {
|
||||
err = liststorage.ErrUnknownACLId
|
||||
err = liststorage.ErrUnknownAclId
|
||||
return
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ func newListStorage(db *pogreb.DB) (ls liststorage.ListStorage, err error) {
|
||||
return
|
||||
}
|
||||
if root == nil {
|
||||
err = liststorage.ErrUnknownACLId
|
||||
err = liststorage.ErrUnknownAclId
|
||||
return
|
||||
}
|
||||
|
||||
rootWithId := &aclrecordproto.RawACLRecordWithId{
|
||||
rootWithId := &aclrecordproto.RawAclRecordWithId{
|
||||
Payload: root,
|
||||
Id: string(rootId),
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func newListStorage(db *pogreb.DB) (ls liststorage.ListStorage, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func createListStorage(db *pogreb.DB, root *aclrecordproto.RawACLRecordWithId) (ls liststorage.ListStorage, err error) {
|
||||
func createListStorage(db *pogreb.DB, root *aclrecordproto.RawAclRecordWithId) (ls liststorage.ListStorage, err error) {
|
||||
keys := aclKeys{}
|
||||
has, err := db.Has(keys.RootIdKey())
|
||||
if err != nil {
|
||||
@@ -86,7 +86,7 @@ func (l *listStorage) Id() string {
|
||||
return l.id
|
||||
}
|
||||
|
||||
func (l *listStorage) Root() (*aclrecordproto.RawACLRecordWithId, error) {
|
||||
func (l *listStorage) Root() (*aclrecordproto.RawAclRecordWithId, error) {
|
||||
return l.root, nil
|
||||
}
|
||||
|
||||
@@ -96,14 +96,14 @@ func (l *listStorage) Head() (head string, err error) {
|
||||
return
|
||||
}
|
||||
if bytes == nil {
|
||||
err = liststorage.ErrUnknownACLId
|
||||
err = liststorage.ErrUnknownAclId
|
||||
return
|
||||
}
|
||||
head = string(bytes)
|
||||
return
|
||||
}
|
||||
|
||||
func (l *listStorage) GetRawRecord(ctx context.Context, id string) (raw *aclrecordproto.RawACLRecordWithId, err error) {
|
||||
func (l *listStorage) GetRawRecord(ctx context.Context, id string) (raw *aclrecordproto.RawAclRecordWithId, err error) {
|
||||
res, err := l.db.Get(l.keys.RawRecordKey(id))
|
||||
if err != nil {
|
||||
return
|
||||
@@ -113,7 +113,7 @@ func (l *listStorage) GetRawRecord(ctx context.Context, id string) (raw *aclreco
|
||||
return
|
||||
}
|
||||
|
||||
raw = &aclrecordproto.RawACLRecordWithId{
|
||||
raw = &aclrecordproto.RawAclRecordWithId{
|
||||
Payload: res,
|
||||
Id: id,
|
||||
}
|
||||
@@ -124,6 +124,6 @@ func (l *listStorage) SetHead(headId string) (err error) {
|
||||
return l.db.Put(l.keys.HeadIdKey(), []byte(headId))
|
||||
}
|
||||
|
||||
func (l *listStorage) AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error {
|
||||
func (l *listStorage) AddRawRecord(ctx context.Context, rec *aclrecordproto.RawAclRecordWithId) error {
|
||||
return l.db.Put(l.keys.RawRecordKey(rec.Id), rec.Payload)
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func testList(t *testing.T, store liststorage.ListStorage, root *aclrecordproto.RawACLRecordWithId, head string) {
|
||||
func testList(t *testing.T, store liststorage.ListStorage, root *aclrecordproto.RawAclRecordWithId, head string) {
|
||||
require.Equal(t, store.Id(), root.Id)
|
||||
|
||||
aclRoot, err := store.Root()
|
||||
@@ -25,7 +25,7 @@ func TestListStorage_Create(t *testing.T) {
|
||||
fx.open(t)
|
||||
defer fx.stop(t)
|
||||
|
||||
aclRoot := &aclrecordproto.RawACLRecordWithId{Payload: []byte("root"), Id: "someRootId"}
|
||||
aclRoot := &aclrecordproto.RawAclRecordWithId{Payload: []byte("root"), Id: "someRootId"}
|
||||
listStore, err := createListStorage(fx.db, aclRoot)
|
||||
require.NoError(t, err)
|
||||
testList(t, listStore, aclRoot, aclRoot.Id)
|
||||
@@ -41,7 +41,7 @@ func TestListStorage_Create(t *testing.T) {
|
||||
func TestListStorage_Methods(t *testing.T) {
|
||||
fx := newFixture(t)
|
||||
fx.open(t)
|
||||
aclRoot := &aclrecordproto.RawACLRecordWithId{Payload: []byte("root"), Id: "someRootId"}
|
||||
aclRoot := &aclrecordproto.RawAclRecordWithId{Payload: []byte("root"), Id: "someRootId"}
|
||||
_, err := createListStorage(fx.db, aclRoot)
|
||||
require.NoError(t, err)
|
||||
fx.stop(t)
|
||||
@@ -61,7 +61,7 @@ func TestListStorage_Methods(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("add raw record and get raw record", func(t *testing.T) {
|
||||
newRec := &aclrecordproto.RawACLRecordWithId{Payload: []byte("rec"), Id: "someRecId"}
|
||||
newRec := &aclrecordproto.RawAclRecordWithId{Payload: []byte("rec"), Id: "someRecId"}
|
||||
require.NoError(t, listStore.AddRawRecord(context.Background(), newRec))
|
||||
aclRec, err := listStore.GetRawRecord(context.Background(), newRec.Id)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -182,7 +182,7 @@ func (s *spaceStorage) CreateTreeStorage(payload treestorage.TreeStorageCreatePa
|
||||
return createTreeStorage(s.objDb, payload)
|
||||
}
|
||||
|
||||
func (s *spaceStorage) ACLStorage() (liststorage.ListStorage, error) {
|
||||
func (s *spaceStorage) AclStorage() (liststorage.ListStorage, error) {
|
||||
return s.aclStorage, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func spaceTestPayload() spacestorage.SpaceStorageCreatePayload {
|
||||
RawHeader: []byte("header"),
|
||||
Id: "headerId",
|
||||
}
|
||||
aclRoot := &aclrecordproto.RawACLRecordWithId{
|
||||
aclRoot := &aclrecordproto.RawAclRecordWithId{
|
||||
Payload: []byte("aclRoot"),
|
||||
Id: "aclRootId",
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func testSpace(t *testing.T, store spacestorage.SpaceStorage, payload spacestora
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, payload.SpaceHeaderWithId, header)
|
||||
|
||||
aclStorage, err := store.ACLStorage()
|
||||
aclStorage, err := store.AclStorage()
|
||||
require.NoError(t, err)
|
||||
testList(t, aclStorage, payload.AclWithId, payload.AclWithId.Id)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user