2020-12-29 23:02:35 +01:00
|
|
|
// Copyright (c) Mainflux
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
|
|
"github.com/mainflux/mainflux"
|
2022-01-27 17:03:57 +01:00
|
|
|
"github.com/mainflux/mainflux/pkg/errors"
|
2020-12-29 23:02:35 +01:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ mainflux.AuthServiceClient = (*authServiceClient)(nil)
|
|
|
|
|
|
|
|
type authServiceClient struct {
|
|
|
|
users map[string]string
|
|
|
|
}
|
|
|
|
|
2021-11-19 16:32:38 +03:00
|
|
|
func (svc authServiceClient) ListPolicies(ctx context.Context, in *mainflux.ListPoliciesReq, opts ...grpc.CallOption) (*mainflux.ListPoliciesRes, error) {
|
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
2020-12-29 23:02:35 +01:00
|
|
|
// NewAuthServiceClient creates mock of auth service.
|
|
|
|
func NewAuthServiceClient(users map[string]string) mainflux.AuthServiceClient {
|
|
|
|
return &authServiceClient{users}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (svc authServiceClient) Identify(ctx context.Context, in *mainflux.Token, opts ...grpc.CallOption) (*mainflux.UserIdentity, error) {
|
|
|
|
if id, ok := svc.users[in.Value]; ok {
|
|
|
|
return &mainflux.UserIdentity{Id: id, Email: id}, nil
|
|
|
|
}
|
2022-02-01 17:33:23 +01:00
|
|
|
return nil, errors.ErrAuthentication
|
2020-12-29 23:02:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (svc *authServiceClient) Issue(ctx context.Context, in *mainflux.IssueReq, opts ...grpc.CallOption) (*mainflux.Token, error) {
|
|
|
|
return new(mainflux.Token), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (svc *authServiceClient) Authorize(ctx context.Context, req *mainflux.AuthorizeReq, _ ...grpc.CallOption) (r *mainflux.AuthorizeRes, err error) {
|
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
2021-10-27 00:38:28 +02:00
|
|
|
func (svc authServiceClient) AddPolicy(ctx context.Context, in *mainflux.AddPolicyReq, opts ...grpc.CallOption) (*mainflux.AddPolicyRes, error) {
|
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (svc authServiceClient) DeletePolicy(ctx context.Context, in *mainflux.DeletePolicyReq, opts ...grpc.CallOption) (*mainflux.DeletePolicyRes, error) {
|
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
2020-12-29 23:02:35 +01:00
|
|
|
func (svc *authServiceClient) Members(ctx context.Context, req *mainflux.MembersReq, _ ...grpc.CallOption) (r *mainflux.MembersRes, err error) {
|
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (svc *authServiceClient) Assign(ctx context.Context, req *mainflux.Assignment, _ ...grpc.CallOption) (r *empty.Empty, err error) {
|
|
|
|
panic("not implemented")
|
|
|
|
}
|