diff --git a/restapi/user_account_test.go b/restapi/user_account_test.go index d75171dc7..3f0f988b0 100644 --- a/restapi/user_account_test.go +++ b/restapi/user_account_test.go @@ -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 {