Skip to content

Commit

Permalink
MF-249 - Change names
Browse files Browse the repository at this point in the history
Signed-off-by: zzokki81 <zoran.rebic@outlook.com>
  • Loading branch information
zzokki81 committed Aug 4, 2023
1 parent 0c659a6 commit 907d77d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pkg/sdk/go/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ var (
passRegex = regexp.MustCompile("^.{8,}$")
user = users.User{Email: userEmail, ID: "574106f7-030e-4881-8ab0-151195c29f94", Password: validPass, Status: "enabled"}
admin = users.User{Email: adminEmail, ID: "371106m2-131g-5286-2mc1-540295c29f95", Password: validPass, Status: "enabled"}
usr = []users.User{admin, user}
usersList = []users.User{admin, user}
)

func newUserService() users.Service {
usersRepo := mocks.NewUserRepository(usr)
usersRepo := mocks.NewUserRepository(usersList)
hasher := mocks.NewHasher()
idProvider := uuid.New()
admin.ID, _ = idProvider.ID()
auth := mocks.NewAuthService(admin.ID, usr)
auth := mocks.NewAuthService(admin.ID, usersList)
emailer := mocks.NewEmailer()

return users.New(usersRepo, hasher, auth, emailer, idProvider, passRegex)
Expand Down
3 changes: 2 additions & 1 deletion readers/api/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var (

user = users.User{Email: userEmail, Password: validPass}
admin = users.User{ID: adminID, Email: adminEmail, Password: validPass, Status: "enabled"}
usersList = []users.User{user, admin}
)

func newServer(repo readers.MessageRepository, tc mainflux.ThingsServiceClient, ac mainflux.AuthServiceClient) *httptest.Server {
Expand Down Expand Up @@ -89,7 +90,7 @@ func (tr testRequest) make() (*http.Response, error) {
return tr.client.Do(req)
}
func newAuthService() mainflux.AuthServiceClient {
return authmocks.NewAuthService(admin.ID, map[string]users.User{admin.Email: admin, user.Email: user})
return authmocks.NewAuthService(admin.ID, usersList)
}

func TestListChannelMessages(t *testing.T) {
Expand Down
18 changes: 9 additions & 9 deletions users/api/http/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var (
user = users.User{Email: validEmail, ID: "574106f7-030e-4881-8ab0-151195c29f94", Password: validPass, Status: "enabled"}
admin = users.User{Email: adminEmail, ID: "371106m2-131g-5286-2mc1-540295c29f95", Password: validPass, Status: "enabled"}
newUser = users.User{Email: "newuser@example.com", Password: validPass, Status: "enabled"}
usr = []users.User{admin, user}
usersList = []users.User{admin, user}
notFoundRes = toJSON(apiutil.ErrorRes{Err: errors.ErrNotFound.Error()})
unauthRes = toJSON(apiutil.ErrorRes{Err: errors.ErrAuthentication.Error()})
weakPassword = toJSON(apiutil.ErrorRes{Err: users.ErrPasswordFormat.Error()})
Expand Down Expand Up @@ -85,9 +85,9 @@ func (tr testRequest) make() (*http.Response, error) {
}

func newService() users.Service {
usersRepo := mocks.NewUserRepository(usr)
usersRepo := mocks.NewUserRepository(usersList)
hasher := mocks.NewHasher()
auth := mocks.NewAuthService(admin.ID, usr)
auth := mocks.NewAuthService(admin.ID, usersList)
email := mocks.NewEmailer()
return users.New(usersRepo, hasher, auth, email, idProvider, passRegex)
}
Expand Down Expand Up @@ -198,7 +198,7 @@ func TestLogin(t *testing.T) {
defer ts.Close()
client := ts.Client()

auth := mocks.NewAuthService("", usr)
auth := mocks.NewAuthService("", usersList)

data := toJSON(user)
invalidEmailData := toJSON(users.User{
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestUser(t *testing.T) {
defer ts.Close()
client := ts.Client()

auth := mocks.NewAuthService("", usr)
auth := mocks.NewAuthService("", usersList)

tkn, err := auth.Issue(context.Background(), &mainflux.IssueReq{Id: user.ID, Email: user.Email, Type: 0})
require.Nil(t, err, fmt.Sprintf("issue token got unexpected error: %s", err))
Expand Down Expand Up @@ -315,10 +315,10 @@ func TestListUsers(t *testing.T) {
Password: "password",
Status: "enabled",
}
usr, err := svc.Register(context.Background(), token, user)
usersList, err := svc.Register(context.Background(), token, user)
require.Nil(t, err, fmt.Sprintf("unexpected error: %s", err))

data = append(data, viewUserRes{usr, email})
data = append(data, viewUserRes{usersList, email})
}

sort.Slice(data, func(i, j int) bool {
Expand Down Expand Up @@ -519,7 +519,7 @@ func TestPasswordReset(t *testing.T) {
ConfPass string `json:"confirm_password,omitempty"`
}{}

auth := mocks.NewAuthService("", usr)
auth := mocks.NewAuthService("", usersList)

tkn, err := auth.Issue(context.Background(), &mainflux.IssueReq{Id: user.ID, Email: user.Email, Type: 0})
require.Nil(t, err, fmt.Sprintf("issue user token error: %s", err))
Expand Down Expand Up @@ -587,7 +587,7 @@ func TestPasswordChange(t *testing.T) {
defer ts.Close()
client := ts.Client()

auth := mocks.NewAuthService("", usr)
auth := mocks.NewAuthService("", usersList)

reqData := struct {
Token string `json:"token,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions users/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
selfRegister = users.User{Email: "selfRegister@example.com", Password: "password", Metadata: map[string]interface{}{"role": "user"}}
user = users.User{Email: "user@example.com", ID: "574106f7-030e-4881-8ab0-151195c29f95", Password: "password", Metadata: map[string]interface{}{"role": "user"}}
nonExistingUser = users.User{Email: "non-ex-user@example.com", Password: "password", Metadata: map[string]interface{}{"role": "user"}}
usr = []users.User{admin, user, unauthUser}
usersList = []users.User{admin, user, unauthUser}
host = "example.com"

idProvider = uuid.New()
Expand All @@ -39,8 +39,8 @@ var (

func newService() users.Service {
hasher := mocks.NewHasher()
userRepo := mocks.NewUserRepository(usr)
authSvc := mocks.NewAuthService(admin.ID, usr)
userRepo := mocks.NewUserRepository(usersList)
authSvc := mocks.NewAuthService(admin.ID, usersList)
e := mocks.NewEmailer()

return users.New(userRepo, hasher, authSvc, e, idProvider, passRegex)
Expand Down

0 comments on commit 907d77d

Please sign in to comment.