mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-02 22:17:10 +08:00

* MF-1263 - Mv duplicated errors to pkg/errors Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Revert test build flags Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix merge Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
35 lines
692 B
Go
35 lines
692 B
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package mocks
|
|
|
|
import (
|
|
"github.com/mainflux/mainflux/pkg/errors"
|
|
"github.com/mainflux/mainflux/users"
|
|
)
|
|
|
|
var _ users.Hasher = (*hasherMock)(nil)
|
|
|
|
type hasherMock struct{}
|
|
|
|
// NewHasher creates "no-op" hasher for test purposes. This implementation will
|
|
// return secrets without changing them.
|
|
func NewHasher() users.Hasher {
|
|
return &hasherMock{}
|
|
}
|
|
|
|
func (hm *hasherMock) Hash(pwd string) (string, error) {
|
|
if pwd == "" {
|
|
return "", errors.ErrMalformedEntity
|
|
}
|
|
return pwd, nil
|
|
}
|
|
|
|
func (hm *hasherMock) Compare(plain, hashed string) error {
|
|
if plain != hashed {
|
|
return errors.ErrUnauthorizedAccess
|
|
}
|
|
|
|
return nil
|
|
}
|