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

* MF-325 - Add SPDX license and copyright headers Signed-off-by: Ivan Milošević <iva@blokovi.com> * MF-325 - Add SPDX license and copyright headers Signed-off-by: Ivan Milošević <iva@blokovi.com> * MF-325 - Add SPDX license and copyright headers Signed-off-by: Ivan Milošević <iva@blokovi.com> * MF-325 - Add SPDX license and copyright headers Signed-off-by: Ivan Milošević <iva@blokovi.com> * MF-325 - Change mainflux version from 0.4.0 to 0.5.0 Signed-off-by: Ivan Milošević <iva@blokovi.com>
36 lines
659 B
Go
36 lines
659 B
Go
//
|
|
// Copyright (c) 2018
|
|
// Mainflux
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package mocks
|
|
|
|
import "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 "", users.ErrMalformedEntity
|
|
}
|
|
return pwd, nil
|
|
}
|
|
|
|
func (hm *hasherMock) Compare(plain, hashed string) error {
|
|
if plain != hashed {
|
|
return users.ErrUnauthorizedAccess
|
|
}
|
|
|
|
return nil
|
|
}
|