Make error message more accurate. Rename test.

This commit is contained in:
Daniel Krol 2022-07-29 15:52:23 -04:00
parent e6f5628a94
commit 19396e9797
7 changed files with 8 additions and 8 deletions

View file

@ -366,7 +366,7 @@ func TestServerVerifyAccountErrors(t *testing.T) {
expectedCallVerifyAccount: false,
},
{
name: "not found token", // including expired
name: "token not found", // including expired
token: "abcd1234abcd1234abcd1234abcd1234",
expectedStatusCode: http.StatusForbidden,
expectedErrorString: http.StatusText(http.StatusForbidden) + ": Verification token not found or expired",

View file

@ -38,7 +38,7 @@ func (s *Server) getAuthToken(w http.ResponseWriter, req *http.Request) {
userId, err := s.store.GetUserId(authRequest.Email, authRequest.Password)
if err == store.ErrWrongCredentials {
errorJson(w, http.StatusUnauthorized, "No match for email and password")
errorJson(w, http.StatusUnauthorized, "No match for email and/or password")
return
}
if err == store.ErrNotVerified {

View file

@ -65,7 +65,7 @@ func TestServerAuthHandlerErrors(t *testing.T) {
name: "login fail",
email: "abc@example.com",
expectedStatusCode: http.StatusUnauthorized,
expectedErrorString: http.StatusText(http.StatusUnauthorized) + ": No match for email and password",
expectedErrorString: http.StatusText(http.StatusUnauthorized) + ": No match for email and/or password",
storeErrors: TestStoreFunctionsErrors{GetUserId: store.ErrWrongCredentials},
},

View file

@ -95,7 +95,7 @@ func (s *Server) changePassword(w http.ResponseWriter, req *http.Request) {
}
}
if err == store.ErrWrongCredentials {
errorJson(w, http.StatusUnauthorized, "No match for email and password")
errorJson(w, http.StatusUnauthorized, "No match for email and/or password")
return
}
if err == store.ErrNotVerified {

View file

@ -82,7 +82,7 @@ func TestServerChangePassword(t *testing.T) {
}, {
name: "incorrect email with wallet",
expectedStatusCode: http.StatusUnauthorized,
expectedErrorString: http.StatusText(http.StatusUnauthorized) + ": No match for email and password",
expectedErrorString: http.StatusText(http.StatusUnauthorized) + ": No match for email and/or password",
expectChangePasswordCall: true,
@ -96,7 +96,7 @@ func TestServerChangePassword(t *testing.T) {
}, {
name: "incorrect email no wallet",
expectedStatusCode: http.StatusUnauthorized,
expectedErrorString: http.StatusText(http.StatusUnauthorized) + ": No match for email and password",
expectedErrorString: http.StatusText(http.StatusUnauthorized) + ": No match for email and/or password",
expectChangePasswordCall: true,

View file

@ -30,7 +30,7 @@ var (
ErrDuplicateEmail = fmt.Errorf("Email already exists for this user")
ErrDuplicateAccount = fmt.Errorf("User already has an account")
ErrWrongCredentials = fmt.Errorf("No match for email and password")
ErrWrongCredentials = fmt.Errorf("No match for email and/or password")
ErrNotVerified = fmt.Errorf("User account is not verified")
)

View file

@ -274,7 +274,7 @@ The client that changed its password can easily get a new token because it has t
Got auth token: 796ea0575fe1ba5d6a43afec016f6ed2c9225a5180e76e744aad5b8857c8702b
>>> c2.get_auth_token()
Error 401
b'{"error":"Unauthorized: No match for email and password"}\n'
b'{"error":"Unauthorized: No match for email and/or password"}\n'
>>> c2.set_local_password("eggsandwich")
Generating keys...
Done generating keys