status-go/protocol/requests/verify_database_password_test.go
frank 7a23ac59c4
fix_: ignore log partial API request (#5865)
* fix_: ignore log partial sensitive API request

* chore_: use validator

* chore_: rebase
2024-09-27 11:48:51 +01:00

43 lines
851 B
Go

package requests
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestVerifyDatabasePassword_Validate(t *testing.T) {
tests := []struct {
name string
request VerifyDatabasePassword
wantErr string
}{
{
name: "Empty KeyUID",
request: VerifyDatabasePassword{KeyUID: "", Password: "password"},
wantErr: "KeyUID",
},
{
name: "Empty Password",
request: VerifyDatabasePassword{KeyUID: "keyuid", Password: ""},
wantErr: "Password",
},
{
name: "Valid Request",
request: VerifyDatabasePassword{KeyUID: "keyuid", Password: "password"},
wantErr: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.request.Validate()
if tt.wantErr != "" {
require.Contains(t, err.Error(), tt.wantErr)
} else {
require.NoError(t, err)
}
})
}
}