mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-29 13:49:28 +08:00

* Use per-service URL in SDK Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com> * Fix CLI Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix CLI messaging Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix message tests Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Simplify Bootstrap Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Update API doc and responses Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * fix failing certs, bootstrap tests Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix failing certs, bootstrap tests Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * Fix tests and rename to auth service Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Clean the code Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Remove unnecessary Repository logs Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Always return error in case of repo failure Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Cleanup SDK and CLI Update tests, remove linter warnings, remove dead code. Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Clean the code Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Undo Bootstrap changes Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix tests Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix linter Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> Co-authored-by: mteodor <mirko.teodorovic@gmail.com> Co-authored-by: dusanb94 <dusan.borovcanin@mainflux.com>
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package mocks
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
"github.com/mainflux/mainflux"
|
|
"github.com/mainflux/mainflux/users"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
var _ mainflux.AuthServiceClient = (*serviceMock)(nil)
|
|
|
|
type serviceMock struct {
|
|
users map[string]string
|
|
}
|
|
|
|
// NewAuthClient creates mock of users service.
|
|
func NewAuthClient(users map[string]string) mainflux.AuthServiceClient {
|
|
return &serviceMock{users}
|
|
}
|
|
|
|
func (svc serviceMock) Identify(ctx context.Context, in *mainflux.Token, opts ...grpc.CallOption) (*mainflux.UserIdentity, error) {
|
|
if id, ok := svc.users[in.Value]; ok {
|
|
return &mainflux.UserIdentity{Email: id, Id: id}, nil
|
|
}
|
|
return nil, users.ErrUnauthorizedAccess
|
|
}
|
|
|
|
func (svc serviceMock) Issue(ctx context.Context, in *mainflux.IssueReq, opts ...grpc.CallOption) (*mainflux.Token, error) {
|
|
if id, ok := svc.users[in.GetEmail()]; ok {
|
|
switch in.Type {
|
|
default:
|
|
return &mainflux.Token{Value: id}, nil
|
|
}
|
|
}
|
|
return nil, users.ErrUnauthorizedAccess
|
|
}
|
|
|
|
func (svc serviceMock) Authorize(ctx context.Context, req *mainflux.AuthorizeReq, _ ...grpc.CallOption) (r *mainflux.AuthorizeRes, err error) {
|
|
panic("not implemented")
|
|
}
|
|
|
|
func (svc serviceMock) Members(ctx context.Context, req *mainflux.MembersReq, _ ...grpc.CallOption) (r *mainflux.MembersRes, err error) {
|
|
panic("not implemented")
|
|
}
|
|
|
|
func (svc serviceMock) Assign(ctx context.Context, req *mainflux.Assignment, _ ...grpc.CallOption) (r *empty.Empty, err error) {
|
|
panic("not implemented")
|
|
}
|