Fix ipmi panic (#9035)

This commit is contained in:
Helen Weller 2021-03-23 10:09:51 -04:00 committed by GitHub
parent dc8e4ef62e
commit f4a51a4c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -32,8 +32,10 @@ func NewConnection(server, privilege, hexKey string) *Connection {
security := server[0:inx1]
connstr = server[inx1+1:]
up := strings.SplitN(security, ":", 2)
conn.Username = up[0]
conn.Password = up[1]
if len(up) == 2 {
conn.Username = up[0]
conn.Password = up[1]
}
}
if inx2 > 0 {

View File

@ -33,6 +33,18 @@ func TestNewConnection(t *testing.T) {
HexKey: "0001",
},
},
// test connection doesn't panic if incorrect symbol used
{
"USERID@PASSW0RD@lan(192.168.1.1)",
&Connection{
Hostname: "192.168.1.1",
Username: "",
Password: "",
Interface: "lan",
Privilege: "USER",
HexKey: "0001",
},
},
}
for _, v := range testData {