-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
226 additions
and
325 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
routers/auth/testdata/login_test.TestLoginErrors.Invalid_email.approved.json
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
routers/auth/testdata/login_test.TestLoginErrors.Invalid_password.approved.json
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
routers/auth/testdata/register_test.TestRegister.approved.json
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
routers/auth/testdata/register_test.TestRegisterErrors.Invalid_email.approved.json
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
routers/auth/testdata/register_test.TestRegisterErrors.too_long_name.approved.json
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
routers/auth/testdata/register_test.TestRegisterErrors.too_long_password.approved.json
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
routers/auth/testdata/register_test.TestRegisterErrors.too_short_password.approved.json
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package auth | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/karngyan/maek/domains/auth" | ||
"github.com/karngyan/maek/ui_api/models" | ||
"github.com/karngyan/maek/ui_api/web" | ||
) | ||
|
||
func info(ctx web.Context) error { | ||
return ctx.JSON(http.StatusOK, models.ModelForAuthBundle(&auth.Bundle{ | ||
User: ctx.User, | ||
Session: ctx.Session, | ||
Workspaces: ctx.AllWorkspaces, | ||
})) | ||
} |
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 |
---|---|---|
|
@@ -23,3 +23,42 @@ func TestLogin(t *testing.T) { | |
approvals.VerifyJSONBytes(t, rr.Body.Bytes()) | ||
assert.Contains(t, rr.Header().Get("Set-Cookie"), "HttpOnly; Secure; SameSite=Strict") | ||
} | ||
|
||
func TestLoginErrors(t *testing.T) { | ||
defer testutil.TruncateTables() | ||
cs := testutil.NewClientStateWithUser(t) | ||
|
||
type testCase struct { | ||
name string | ||
body map[string]any | ||
expectedCode int | ||
} | ||
|
||
tcs := []testCase{ | ||
{ | ||
name: "Invalid email", | ||
body: map[string]any{ | ||
"email": "wrong-email", | ||
"password": "test-password", | ||
}, | ||
expectedCode: 400, | ||
}, | ||
{ | ||
name: "Invalid password", | ||
body: map[string]any{ | ||
"email": "[email protected]", | ||
"password": "wrong-password", | ||
}, | ||
expectedCode: 400, | ||
}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
t.Run(tc.name, func(t *testing.T) { | ||
rr, err := cs.Post("/v1/auth/login", tc.body) | ||
assert.Nil(t, err) | ||
assert.Equal(t, tc.expectedCode, rr.Code) | ||
approvals.VerifyJSONBytes(t, rr.Body.Bytes()) | ||
}) | ||
} | ||
} |
Oops, something went wrong.