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, expectedCallVerifyAccount: false,
}, },
{ {
name: "not found token", // including expired name: "token not found", // including expired
token: "abcd1234abcd1234abcd1234abcd1234", token: "abcd1234abcd1234abcd1234abcd1234",
expectedStatusCode: http.StatusForbidden, expectedStatusCode: http.StatusForbidden,
expectedErrorString: http.StatusText(http.StatusForbidden) + ": Verification token not found or expired", 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) userId, err := s.store.GetUserId(authRequest.Email, authRequest.Password)
if err == store.ErrWrongCredentials { 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 return
} }
if err == store.ErrNotVerified { if err == store.ErrNotVerified {

View file

@ -65,7 +65,7 @@ func TestServerAuthHandlerErrors(t *testing.T) {
name: "login fail", name: "login fail",
email: "abc@example.com", email: "abc@example.com",
expectedStatusCode: http.StatusUnauthorized, 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}, 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 { 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 return
} }
if err == store.ErrNotVerified { if err == store.ErrNotVerified {

View file

@ -82,7 +82,7 @@ func TestServerChangePassword(t *testing.T) {
}, { }, {
name: "incorrect email with wallet", name: "incorrect email with wallet",
expectedStatusCode: http.StatusUnauthorized, 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, expectChangePasswordCall: true,
@ -96,7 +96,7 @@ func TestServerChangePassword(t *testing.T) {
}, { }, {
name: "incorrect email no wallet", name: "incorrect email no wallet",
expectedStatusCode: http.StatusUnauthorized, 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, expectChangePasswordCall: true,

View file

@ -30,7 +30,7 @@ var (
ErrDuplicateEmail = fmt.Errorf("Email already exists for this user") ErrDuplicateEmail = fmt.Errorf("Email already exists for this user")
ErrDuplicateAccount = fmt.Errorf("User already has an account") 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") 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 Got auth token: 796ea0575fe1ba5d6a43afec016f6ed2c9225a5180e76e744aad5b8857c8702b
>>> c2.get_auth_token() >>> c2.get_auth_token()
Error 401 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") >>> c2.set_local_password("eggsandwich")
Generating keys... Generating keys...
Done generating keys Done generating keys