Mainflux.mainflux/sdk/go/users_test.go

158 lines
3.8 KiB
Go
Raw Normal View History

// Copyright (c) Mainflux
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
// SPDX-License-Identifier: Apache-2.0
package sdk_test
import (
MF-932 - User API keys (#941) * Add inital Auth implementation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract IssuedAt on transport layer Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add token type Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Auth service URL in Things service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add User Keys revocation check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update tests Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused tracing methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Key retrival and parsing Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused code Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix compose files Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Simplify tests. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos and remove useless comments Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename Auth to Authn Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename database.go to tracin.go A new name (`tracing.go`) describes better the purpose of the file. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Fix typo. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove token from Users service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix identify login keys Rename token parsing method. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract tokenizer to interface Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove pointer time Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use pointer for expiration time in response Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use uppercase N Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unnecessary email check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Cleanup unused code and env vars Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename tokenizer field Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use slices and named fields in test cases Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update AuthN keys naming Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove package-lock.json changes Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove Secret from issuing request Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2019-12-16 23:22:09 +08:00
"context"
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
"fmt"
"net/http/httptest"
"os"
"testing"
MF-932 - User API keys (#941) * Add inital Auth implementation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract IssuedAt on transport layer Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add token type Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Auth service URL in Things service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add User Keys revocation check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update tests Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused tracing methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Key retrival and parsing Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused code Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix compose files Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Simplify tests. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos and remove useless comments Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename Auth to Authn Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename database.go to tracin.go A new name (`tracing.go`) describes better the purpose of the file. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Fix typo. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove token from Users service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix identify login keys Rename token parsing method. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract tokenizer to interface Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove pointer time Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use pointer for expiration time in response Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use uppercase N Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unnecessary email check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Cleanup unused code and env vars Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename tokenizer field Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use slices and named fields in test cases Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update AuthN keys naming Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove package-lock.json changes Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove Secret from issuing request Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2019-12-16 23:22:09 +08:00
"github.com/mainflux/mainflux"
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
log "github.com/mainflux/mainflux/logger"
sdk "github.com/mainflux/mainflux/sdk/go"
2019-07-18 21:01:09 +08:00
"github.com/opentracing/opentracing-go/mocktracer"
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
"github.com/stretchr/testify/assert"
MF-932 - User API keys (#941) * Add inital Auth implementation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract IssuedAt on transport layer Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add token type Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Auth service URL in Things service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add User Keys revocation check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update tests Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused tracing methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Key retrival and parsing Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused code Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix compose files Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Simplify tests. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos and remove useless comments Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename Auth to Authn Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename database.go to tracin.go A new name (`tracing.go`) describes better the purpose of the file. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Fix typo. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove token from Users service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix identify login keys Rename token parsing method. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract tokenizer to interface Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove pointer time Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use pointer for expiration time in response Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use uppercase N Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unnecessary email check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Cleanup unused code and env vars Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename tokenizer field Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use slices and named fields in test cases Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update AuthN keys naming Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove package-lock.json changes Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove Secret from issuing request Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2019-12-16 23:22:09 +08:00
"github.com/mainflux/mainflux/users/api"
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
"github.com/mainflux/mainflux/users"
"github.com/mainflux/mainflux/users/mocks"
)
const (
invalidEmail = "userexample.com"
)
func newUserService() users.Service {
repo := mocks.NewUserRepository()
hasher := mocks.NewHasher()
MF-932 - User API keys (#941) * Add inital Auth implementation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract IssuedAt on transport layer Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add token type Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Auth service URL in Things service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add User Keys revocation check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update tests Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused tracing methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Key retrival and parsing Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused code Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix compose files Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Simplify tests. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos and remove useless comments Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename Auth to Authn Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename database.go to tracin.go A new name (`tracing.go`) describes better the purpose of the file. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Fix typo. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove token from Users service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix identify login keys Rename token parsing method. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract tokenizer to interface Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove pointer time Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use pointer for expiration time in response Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use uppercase N Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unnecessary email check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Cleanup unused code and env vars Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename tokenizer field Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use slices and named fields in test cases Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update AuthN keys naming Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove package-lock.json changes Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove Secret from issuing request Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2019-12-16 23:22:09 +08:00
auth := mocks.NewAuthService(map[string]string{"user@example.com": "user@example.com"})
MF-532 - Password reset (#873) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize mailing code Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change struct members to private Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint token and mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix error reporting Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add trusted certificates Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add endpoint for password change of currently authenticated user Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving some style comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor fixes due to bad merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename to email.go Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove debug bin Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add driver conf for mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix failing tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add testify Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token conf Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * configurable email template Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix missing var Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert to master Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove dev container Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fixes, typos, namings Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typo Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * return err from email New() Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change MF_TOKEN_RESET_ENDPOINT Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add and remove env vars Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * separate password logic into two methods Change and Reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove blank line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update docs Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * dont use camel case Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-10-22 20:53:14 +08:00
emailer := mocks.NewEmailer()
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
MF-932 - User API keys (#941) * Add inital Auth implementation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract IssuedAt on transport layer Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add token type Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Auth service URL in Things service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add User Keys revocation check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update tests Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused tracing methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Key retrival and parsing Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused code Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix compose files Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Simplify tests. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos and remove useless comments Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename Auth to Authn Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename database.go to tracin.go A new name (`tracing.go`) describes better the purpose of the file. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Fix typo. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove token from Users service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix identify login keys Rename token parsing method. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract tokenizer to interface Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove pointer time Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use pointer for expiration time in response Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use uppercase N Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unnecessary email check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Cleanup unused code and env vars Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename tokenizer field Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use slices and named fields in test cases Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update AuthN keys naming Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove package-lock.json changes Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove Secret from issuing request Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2019-12-16 23:22:09 +08:00
return users.New(repo, hasher, auth, emailer)
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
}
func newUserServer(svc users.Service) *httptest.Server {
logger, _ := log.New(os.Stdout, log.Info.String())
MF-932 - User API keys (#941) * Add inital Auth implementation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract IssuedAt on transport layer Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add token type Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Auth service URL in Things service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add User Keys revocation check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update tests Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused tracing methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Key retrival and parsing Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused code Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix compose files Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Simplify tests. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos and remove useless comments Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename Auth to Authn Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename database.go to tracin.go A new name (`tracing.go`) describes better the purpose of the file. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Fix typo. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove token from Users service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix identify login keys Rename token parsing method. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract tokenizer to interface Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove pointer time Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use pointer for expiration time in response Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use uppercase N Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unnecessary email check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Cleanup unused code and env vars Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename tokenizer field Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use slices and named fields in test cases Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update AuthN keys naming Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove package-lock.json changes Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove Secret from issuing request Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2019-12-16 23:22:09 +08:00
mux := api.MakeHandler(svc, mocktracer.New(), logger)
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
return httptest.NewServer(mux)
}
func TestCreateUser(t *testing.T) {
svc := newUserService()
ts := newUserServer(svc)
defer ts.Close()
sdkConf := sdk.Config{
BaseURL: ts.URL,
UsersPrefix: "",
ThingsPrefix: "",
HTTPAdapterPrefix: "",
MsgContentType: contentType,
TLSVerification: false,
}
mainfluxSDK := sdk.NewSDK(sdkConf)
user := sdk.User{Email: "user@example.com", Password: "password"}
cases := []struct {
desc string
user sdk.User
err error
}{
{
desc: "register new user",
user: user,
err: nil,
},
{
desc: "register existing user",
user: user,
err: sdk.ErrConflict,
},
{
desc: "register user with invalid email address",
user: sdk.User{Email: invalidEmail, Password: "password"},
err: sdk.ErrInvalidArgs,
},
{
desc: "register user with empty password",
user: sdk.User{Email: "user2@example.com", Password: ""},
err: sdk.ErrInvalidArgs,
},
{
desc: "register user without password",
user: sdk.User{Email: "user2@example.com"},
err: sdk.ErrInvalidArgs,
},
{
desc: "register user without email",
user: sdk.User{Password: "password"},
err: sdk.ErrInvalidArgs,
},
{
desc: "register empty user",
user: sdk.User{},
err: sdk.ErrInvalidArgs,
},
}
for _, tc := range cases {
err := mainfluxSDK.CreateUser(tc.user)
assert.Equal(t, tc.err, err, fmt.Sprintf("%s: unexpected error %s", tc.desc, err))
}
}
func TestCreateToken(t *testing.T) {
svc := newUserService()
ts := newUserServer(svc)
defer ts.Close()
sdkConf := sdk.Config{
BaseURL: ts.URL,
UsersPrefix: "",
ThingsPrefix: "",
HTTPAdapterPrefix: "",
MsgContentType: contentType,
TLSVerification: false,
}
mainfluxSDK := sdk.NewSDK(sdkConf)
user := sdk.User{Email: "user@example.com", Password: "password"}
MF-932 - User API keys (#941) * Add inital Auth implementation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract IssuedAt on transport layer Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add token type Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Auth service URL in Things service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add User Keys revocation check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update tests Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused tracing methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Key retrival and parsing Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unused code Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix compose files Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Simplify tests. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos and remove useless comments Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename Auth to Authn Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename database.go to tracin.go A new name (`tracing.go`) describes better the purpose of the file. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Fix typo. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Increase test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove token from Users service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix identify login keys Rename token parsing method. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Extract tokenizer to interface Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove pointer time Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use pointer for expiration time in response Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use uppercase N Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove unnecessary email check Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Cleanup unused code and env vars Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename tokenizer field Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Use slices and named fields in test cases Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update AuthN keys naming Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove package-lock.json changes Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove Secret from issuing request Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2019-12-16 23:22:09 +08:00
auth := mocks.NewAuthService(map[string]string{user.Email: user.Email})
tkn, _ := auth.Issue(context.Background(), &mainflux.IssueReq{Issuer: user.Email, Type: 0})
token := tkn.GetValue()
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
mainfluxSDK.CreateUser(user)
cases := []struct {
desc string
user sdk.User
token string
err error
}{
{
desc: "create token for user",
user: user,
MF-532 - Password reset (#873) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize mailing code Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change struct members to private Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint token and mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix error reporting Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add trusted certificates Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add endpoint for password change of currently authenticated user Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving some style comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor fixes due to bad merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename to email.go Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove debug bin Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add driver conf for mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix failing tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add testify Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token conf Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * configurable email template Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix missing var Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert to master Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove dev container Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fixes, typos, namings Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typo Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * return err from email New() Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change MF_TOKEN_RESET_ENDPOINT Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add and remove env vars Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * separate password logic into two methods Change and Reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove blank line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update docs Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * dont use camel case Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-10-22 20:53:14 +08:00
token: token,
MF-417 - Implement SDK tests (#438) * Add SKD tests for creating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for Channel function Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add list channels over SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for updating channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK tests for deleting channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add users service SDK tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * SDK things tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for connecting and disconnecting things from channel Signed-off-by: Ivan Milošević <iva@blokovi.com> * testing SDK sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * add tests for SDK func SetContentType Signed-off-by: Ivan Milošević <iva@blokovi.com> * add all test cases for sending messages Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling StatusBadRequest when deleting thing over SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Update error responses when deleting channel and thing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Removed unused Unauthorized response when creating user Signed-off-by: Ivan Milošević <iva@blokovi.com> * update testing CreateChannel, tests if response is some string Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add bad request case in testing CreateToken Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove response error conflict from things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix definition of sdk.ErrFailedDisconnect and return error in test cases for disconnecting things Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add handling errors and formatting code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Defined new ErrFailedPublish error in SDK Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add SDK test for version Signed-off-by: Ivan Milošević <iva@blokovi.com> * Delete unused http response status in sdk.DeleteChannel Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-11-20 04:27:01 +08:00
err: nil,
},
{
desc: "create token for non existing user",
user: sdk.User{Email: "user2@example.com", Password: "password"},
token: "",
err: sdk.ErrUnauthorized,
},
{
desc: "create user with empty email",
user: sdk.User{Email: "", Password: "password"},
token: "",
err: sdk.ErrInvalidArgs,
},
}
for _, tc := range cases {
token, err := mainfluxSDK.CreateToken(tc.user)
assert.Equal(t, tc.err, err, fmt.Sprintf("%s: expected error %s, got %s", tc.desc, tc.err, err))
assert.Equal(t, tc.token, token, fmt.Sprintf("%s: expected response: %s, got: %s", tc.desc, token, tc.token))
}
}