Test change password response (#1877)

This commit is contained in:
Cesar Celis Hernandez
2022-04-20 14:38:49 -04:00
committed by GitHub
parent 74ba1c80a9
commit 3291b3ca45

View File

@@ -22,10 +22,32 @@ import (
"testing"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations/user_api"
"github.com/stretchr/testify/assert"
)
var minioChangePasswordMock func(ctx context.Context, accessKey, secretKey string) error
func Test_getChangePasswordResponse(t *testing.T) {
assert := assert.New(t)
session := &models.Principal{
AccountAccessKey: "TESTTEST",
}
CurrentSecretKey := "string"
NewSecretKey := "string"
changePasswordParameters := user_api.AccountChangePasswordParams{
Body: &models.AccountChangePasswordRequest{
CurrentSecretKey: &CurrentSecretKey,
NewSecretKey: &NewSecretKey,
},
}
loginResponse, actualError := getChangePasswordResponse(session, changePasswordParameters)
expected := (*models.LoginResponse)(nil)
assert.Equal(expected, loginResponse)
expectedError := "error please check your current password" // errChangePassword
assert.Equal(expectedError, *actualError.DetailedMessage)
}
func Test_changePassword(t *testing.T) {
client := adminClientMock{}
type args struct {