Change ACL to Acl

This commit is contained in:
mcrakhman committed 2022-12-26 17:52:39 +01:00
1 parent d35d5c9437
commit 9da4e0e7e9
51 files changed
+1039 -1039

No files matched your search

+6 -6
View File
@@ -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
}
+7 -7
View File
@@ -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
View File
@@ -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,
},
},