forked from absmach/supermq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NOISSUE - Add Secret Validation on Registration (absmach#2109)
Signed-off-by: Rodney Osodo <[email protected]>
- Loading branch information
1 parent
3bf5968
commit fbec74b
Showing
15 changed files
with
163 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,14 +43,14 @@ func setupUsers() (*httptest.Server, *umocks.Repository, *gmocks.Repository, *au | |
gRepo := new(gmocks.Repository) | ||
|
||
auth := new(authmocks.AuthClient) | ||
csvc := users.NewService(crepo, auth, emailer, phasher, idProvider, passRegex, true) | ||
csvc := users.NewService(crepo, auth, emailer, phasher, idProvider, true) | ||
gsvc := groups.NewService(gRepo, idProvider, auth) | ||
|
||
logger := mglog.NewMock() | ||
mux := chi.NewRouter() | ||
provider := new(oauth2mocks.Provider) | ||
provider.On("Name").Return("test") | ||
api.MakeHandler(csvc, gsvc, mux, logger, "", provider) | ||
api.MakeHandler(csvc, gsvc, mux, logger, "", passRegex, provider) | ||
|
||
return httptest.NewServer(mux), crepo, gRepo, auth | ||
} | ||
|
@@ -62,7 +62,7 @@ func TestCreateClient(t *testing.T) { | |
user := sdk.User{ | ||
Name: "clientname", | ||
Tags: []string{"tag1", "tag2"}, | ||
Credentials: sdk.Credentials{Identity: "[email protected]", Secret: "secret"}, | ||
Credentials: sdk.Credentials{Identity: "[email protected]", Secret: "12345678"}, | ||
Status: mgclients.EnabledStatus.String(), | ||
} | ||
conf := sdk.Config{ | ||
|
@@ -96,7 +96,7 @@ func TestCreateClient(t *testing.T) { | |
client: sdk.User{}, | ||
response: sdk.User{}, | ||
token: token, | ||
err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, errors.ErrMalformedEntity), http.StatusBadRequest), | ||
err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingIdentity), http.StatusBadRequest), | ||
}, | ||
{ | ||
desc: "register a user that can't be marshalled", | ||
|
@@ -135,7 +135,7 @@ func TestCreateClient(t *testing.T) { | |
}, | ||
response: sdk.User{}, | ||
token: token, | ||
err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, errors.ErrMalformedEntity), http.StatusBadRequest), | ||
err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingIdentity), http.StatusBadRequest), | ||
}, | ||
{ | ||
desc: "register user with empty identity", | ||
|
@@ -147,14 +147,7 @@ func TestCreateClient(t *testing.T) { | |
}, | ||
response: sdk.User{}, | ||
token: token, | ||
err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, errors.ErrMalformedEntity), http.StatusBadRequest), | ||
}, | ||
{ | ||
desc: "register empty user", | ||
client: sdk.User{}, | ||
response: sdk.User{}, | ||
token: token, | ||
err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, errors.ErrMalformedEntity), http.StatusBadRequest), | ||
err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingIdentity), http.StatusBadRequest), | ||
}, | ||
{ | ||
desc: "register user with every field defined", | ||
|
@@ -828,7 +821,7 @@ func TestUpdateClientSecret(t *testing.T) { | |
newSecret: "newSecret", | ||
token: validToken, | ||
response: sdk.User{}, | ||
repoErr: apiutil.ErrInvalidSecret, | ||
repoErr: apiutil.ErrMissingSecret, | ||
err: errors.NewSDKErrorWithStatus(errors.Wrap(svcerr.ErrNotFound, repoerr.ErrMissingSecret), http.StatusBadRequest), | ||
}, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.