Skip to content

Commit

Permalink
✅ Add login test case
Browse files Browse the repository at this point in the history
  • Loading branch information
tosone committed Jul 7, 2024
1 parent 7a1b18a commit 79a4fd2
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 235 deletions.
32 changes: 32 additions & 0 deletions pkg/handlers/apidocs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4599,6 +4599,17 @@ const docTemplate = `{
"User"
],
"summary": "Login user",
"parameters": [
{
"description": "User login object",
"name": "message",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/types.PostUserLoginRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
Expand Down Expand Up @@ -7120,6 +7131,27 @@ const docTemplate = `{
}
}
},
"types.PostUserLoginRequest": {
"type": "object",
"required": [
"password",
"username"
],
"properties": {
"password": {
"type": "string",
"maxLength": 20,
"minLength": 5,
"example": "Admin@123"
},
"username": {
"type": "string",
"maxLength": 20,
"minLength": 2,
"example": "sigma"
}
}
},
"types.PostUserLoginResponse": {
"type": "object",
"properties": {
Expand Down
32 changes: 32 additions & 0 deletions pkg/handlers/apidocs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4591,6 +4591,17 @@
"User"
],
"summary": "Login user",
"parameters": [
{
"description": "User login object",
"name": "message",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/types.PostUserLoginRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
Expand Down Expand Up @@ -7112,6 +7123,27 @@
}
}
},
"types.PostUserLoginRequest": {
"type": "object",
"required": [
"password",
"username"
],
"properties": {
"password": {
"type": "string",
"maxLength": 20,
"minLength": 5,
"example": "Admin@123"
},
"username": {
"type": "string",
"maxLength": 20,
"minLength": 2,
"example": "sigma"
}
}
},
"types.PostUserLoginResponse": {
"type": "object",
"properties": {
Expand Down
23 changes: 23 additions & 0 deletions pkg/handlers/apidocs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,22 @@ definitions:
example: 21911
type: integer
type: object
types.PostUserLoginRequest:
properties:
password:
example: Admin@123
maxLength: 20
minLength: 5
type: string
username:
example: sigma
maxLength: 20
minLength: 2
type: string
required:
- password
- username
type: object
types.PostUserLoginResponse:
properties:
email:
Expand Down Expand Up @@ -4725,6 +4741,13 @@ paths:
post:
consumes:
- application/json
parameters:
- description: User login object
in: body
name: message
required: true
schema:
$ref: '#/definitions/types.PostUserLoginRequest'
produces:
- application/json
responses:
Expand Down
7 changes: 4 additions & 3 deletions pkg/handlers/users/users_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ import (
// @Accept json
// @Produce json
// @Router /users/login [post]
// @Failure 500 {object} xerrors.ErrCode
// @Failure 401 {object} xerrors.ErrCode
// @Success 200 {object} types.PostUserLoginResponse
// @Param message body types.PostUserLoginRequest true "User login object"
// @Failure 500 {object} xerrors.ErrCode
// @Failure 401 {object} xerrors.ErrCode
// @Success 200 {object} types.PostUserLoginResponse
func (h *handler) Login(c echo.Context) error {
ctx := log.Logger.WithContext(c.Request().Context())

Expand Down
Loading

0 comments on commit 79a4fd2

Please sign in to comment.