mirror of https://github.com/poanetwork/gecko.git
Merge pull request #224 from tbrunain/fix/import_user_empty_username_check
fix: Add a check on username in importUser Thanks for pointing this out!
This commit is contained in:
commit
49730eaac0
|
@ -266,6 +266,10 @@ func (ks *Keystore) ImportUser(r *http.Request, args *ImportUserArgs, reply *Imp
|
|||
|
||||
ks.log.Verbo("ImportUser called for %s", args.Username)
|
||||
|
||||
if args.Username == "" {
|
||||
return errEmptyUsername
|
||||
}
|
||||
|
||||
if usr, err := ks.getUser(args.Username); err == nil || usr != nil {
|
||||
return fmt.Errorf("user already exists: %s", args.Username)
|
||||
}
|
||||
|
|
|
@ -266,6 +266,17 @@ func TestServiceExportImport(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
reply := ImportUserReply{}
|
||||
if err := newKS.ImportUser(nil, &ImportUserArgs{
|
||||
Username: "",
|
||||
Password: "strongPassword",
|
||||
User: exportReply.User,
|
||||
}, &reply); err == nil {
|
||||
t.Fatal("Should have errored due to empty username")
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
reply := ImportUserReply{}
|
||||
if err := newKS.ImportUser(nil, &ImportUserArgs{
|
||||
|
|
Loading…
Reference in New Issue