mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +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>
127 lines
4.5 KiB
Go
127 lines
4.5 KiB
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package mocks
|
|
|
|
import (
|
|
context "context"
|
|
|
|
"github.com/absmach/magistrala"
|
|
"github.com/absmach/magistrala/pkg/errors"
|
|
"github.com/stretchr/testify/mock"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
const InvalidValue = "invalid"
|
|
|
|
var _ magistrala.AuthServiceClient = (*Service)(nil)
|
|
|
|
type Service struct {
|
|
mock.Mock
|
|
}
|
|
|
|
func (m *Service) Issue(ctx context.Context, in *magistrala.IssueReq, opts ...grpc.CallOption) (*magistrala.Token, error) {
|
|
ret := m.Called(ctx, in)
|
|
if in.GetUserId() == InvalidValue || in.GetUserId() == "" {
|
|
return &magistrala.Token{}, errors.ErrAuthentication
|
|
}
|
|
if in.GetDomainId() == InvalidValue || in.GetDomainId() == "" {
|
|
return &magistrala.Token{}, errors.ErrAuthentication
|
|
}
|
|
|
|
return ret.Get(0).(*magistrala.Token), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) Refresh(ctx context.Context, in *magistrala.RefreshReq, opts ...grpc.CallOption) (*magistrala.Token, error) {
|
|
ret := m.Called(ctx, in)
|
|
if in.GetRefreshToken() == InvalidValue || in.GetRefreshToken() == "" {
|
|
return &magistrala.Token{}, errors.ErrAuthentication
|
|
}
|
|
if in.GetDomainId() == InvalidValue || in.GetDomainId() == "" {
|
|
return &magistrala.Token{}, errors.ErrAuthentication
|
|
}
|
|
|
|
return ret.Get(0).(*magistrala.Token), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) Identify(ctx context.Context, in *magistrala.IdentityReq, opts ...grpc.CallOption) (*magistrala.IdentityRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
if in.GetToken() == InvalidValue || in.GetToken() == "" {
|
|
return &magistrala.IdentityRes{}, errors.ErrAuthentication
|
|
}
|
|
|
|
return ret.Get(0).(*magistrala.IdentityRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) Authorize(ctx context.Context, in *magistrala.AuthorizeReq, opts ...grpc.CallOption) (*magistrala.AuthorizeRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
if in.GetSubject() == InvalidValue || in.GetSubject() == "" {
|
|
return &magistrala.AuthorizeRes{Authorized: false}, errors.ErrAuthorization
|
|
}
|
|
if in.GetObject() == InvalidValue || in.GetObject() == "" {
|
|
return &magistrala.AuthorizeRes{Authorized: false}, errors.ErrAuthorization
|
|
}
|
|
|
|
return ret.Get(0).(*magistrala.AuthorizeRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) AddPolicy(ctx context.Context, in *magistrala.AddPolicyReq, opts ...grpc.CallOption) (*magistrala.AddPolicyRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.AddPolicyRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) AddPolicies(ctx context.Context, in *magistrala.AddPoliciesReq, opts ...grpc.CallOption) (*magistrala.AddPoliciesRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.AddPoliciesRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) DeletePolicy(ctx context.Context, in *magistrala.DeletePolicyReq, opts ...grpc.CallOption) (*magistrala.DeletePolicyRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.DeletePolicyRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) DeletePolicies(ctx context.Context, in *magistrala.DeletePoliciesReq, opts ...grpc.CallOption) (*magistrala.DeletePoliciesRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.DeletePoliciesRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) ListObjects(ctx context.Context, in *magistrala.ListObjectsReq, opts ...grpc.CallOption) (*magistrala.ListObjectsRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.ListObjectsRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) ListAllObjects(ctx context.Context, in *magistrala.ListObjectsReq, opts ...grpc.CallOption) (*magistrala.ListObjectsRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.ListObjectsRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) CountObjects(ctx context.Context, in *magistrala.CountObjectsReq, opts ...grpc.CallOption) (*magistrala.CountObjectsRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.CountObjectsRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) ListSubjects(ctx context.Context, in *magistrala.ListSubjectsReq, opts ...grpc.CallOption) (*magistrala.ListSubjectsRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.ListSubjectsRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) ListAllSubjects(ctx context.Context, in *magistrala.ListSubjectsReq, opts ...grpc.CallOption) (*magistrala.ListSubjectsRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.ListSubjectsRes), ret.Error(1)
|
|
}
|
|
|
|
func (m *Service) CountSubjects(ctx context.Context, in *magistrala.CountSubjectsReq, opts ...grpc.CallOption) (*magistrala.CountSubjectsRes, error) {
|
|
ret := m.Called(ctx, in)
|
|
|
|
return ret.Get(0).(*magistrala.CountSubjectsRes), ret.Error(1)
|
|
}
|