mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 04:20:17 +00:00
a0c40ba462
* chore(license): update copyright notices Add CI check for non go files to check that the files contain a license Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com> * fix(ci): log failed files When the CI fails during check for license header, log the failed file to console so that someone can check on the actual file. Also simplify the grep check to make it more human readable and understandable Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com> --------- Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
157 lines
4.0 KiB
Go
157 lines
4.0 KiB
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package mocks
|
|
|
|
import (
|
|
context "context"
|
|
|
|
auth "github.com/absmach/magistrala/auth"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
var (
|
|
_ auth.Authz = (*Authz)(nil)
|
|
_ auth.PolicyAgent = (*PolicyAgent)(nil)
|
|
)
|
|
|
|
type Authz struct {
|
|
mock.Mock
|
|
}
|
|
|
|
func (m *Authz) AddPolicies(ctx context.Context, prs []auth.PolicyReq) error {
|
|
ret := m.Called(ctx, prs)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *Authz) AddPolicy(ctx context.Context, pr auth.PolicyReq) error {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *Authz) Authorize(ctx context.Context, pr auth.PolicyReq) error {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *Authz) CountObjects(ctx context.Context, pr auth.PolicyReq) (int, error) {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Get(0).(int), ret.Error(1)
|
|
}
|
|
|
|
func (m *Authz) CountSubjects(ctx context.Context, pr auth.PolicyReq) (int, error) {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Get(0).(int), ret.Error(1)
|
|
}
|
|
|
|
func (m *Authz) DeletePolicies(ctx context.Context, prs []auth.PolicyReq) error {
|
|
ret := m.Called(ctx, prs)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *Authz) DeletePolicy(ctx context.Context, pr auth.PolicyReq) error {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *Authz) ListAllObjects(ctx context.Context, pr auth.PolicyReq) (auth.PolicyPage, error) {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Get(0).(auth.PolicyPage), ret.Error(1)
|
|
}
|
|
|
|
func (m *Authz) ListAllSubjects(ctx context.Context, pr auth.PolicyReq) (auth.PolicyPage, error) {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Get(0).(auth.PolicyPage), ret.Error(1)
|
|
}
|
|
|
|
func (m *Authz) ListObjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) (auth.PolicyPage, error) {
|
|
ret := m.Called(ctx, pr, nextPageToken, limit)
|
|
|
|
return ret.Get(0).(auth.PolicyPage), ret.Error(1)
|
|
}
|
|
|
|
func (m *Authz) ListSubjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) (auth.PolicyPage, error) {
|
|
ret := m.Called(ctx, pr, nextPageToken, limit)
|
|
|
|
return ret.Get(0).(auth.PolicyPage), ret.Error(1)
|
|
}
|
|
|
|
type PolicyAgent struct {
|
|
mock.Mock
|
|
}
|
|
|
|
func (m *PolicyAgent) AddPolicies(ctx context.Context, prs []auth.PolicyReq) error {
|
|
ret := m.Called(ctx, prs)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *PolicyAgent) AddPolicy(ctx context.Context, pr auth.PolicyReq) error {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *PolicyAgent) CheckPolicy(ctx context.Context, pr auth.PolicyReq) error {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *PolicyAgent) DeletePolicies(ctx context.Context, pr []auth.PolicyReq) error {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *PolicyAgent) DeletePolicy(ctx context.Context, pr auth.PolicyReq) error {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Error(0)
|
|
}
|
|
|
|
func (m *PolicyAgent) RetrieveAllObjects(ctx context.Context, pr auth.PolicyReq) ([]auth.PolicyRes, error) {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Get(0).([]auth.PolicyRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *PolicyAgent) RetrieveAllObjectsCount(ctx context.Context, pr auth.PolicyReq) (int, error) {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Get(0).(int), ret.Error(1)
|
|
}
|
|
|
|
func (m *PolicyAgent) RetrieveAllSubjects(ctx context.Context, pr auth.PolicyReq) ([]auth.PolicyRes, error) {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Get(0).([]auth.PolicyRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *PolicyAgent) RetrieveAllSubjectsCount(ctx context.Context, pr auth.PolicyReq) (int, error) {
|
|
ret := m.Called(ctx, pr)
|
|
|
|
return ret.Get(0).(int), ret.Error(1)
|
|
}
|
|
|
|
func (m *PolicyAgent) RetrieveObjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) ([]auth.PolicyRes, string, error) {
|
|
ret := m.Called(ctx, pr, nextPageToken, limit)
|
|
|
|
return ret.Get(0).([]auth.PolicyRes), ret.String(1), ret.Error(2)
|
|
}
|
|
|
|
func (m *PolicyAgent) RetrieveSubjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) ([]auth.PolicyRes, string, error) {
|
|
ret := m.Called(ctx, pr, nextPageToken, limit)
|
|
|
|
return ret.Get(0).([]auth.PolicyRes), ret.String(1), ret.Error(2)
|
|
}
|