ipmi_sensor: allow @ symbol in password (#2633)
This commit is contained in:
committed by
Daniel Nelson
parent
c9f8308f27
commit
92fa20cef2
@@ -18,7 +18,7 @@ type Connection struct {
|
||||
|
||||
func NewConnection(server string) *Connection {
|
||||
conn := &Connection{}
|
||||
inx1 := strings.Index(server, "@")
|
||||
inx1 := strings.LastIndex(server, "@")
|
||||
inx2 := strings.Index(server, "(")
|
||||
inx3 := strings.Index(server, ")")
|
||||
|
||||
|
||||
42
plugins/inputs/ipmi_sensor/connection_test.go
Normal file
42
plugins/inputs/ipmi_sensor/connection_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package ipmi_sensor
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type conTest struct {
|
||||
Got string
|
||||
Want *Connection
|
||||
}
|
||||
|
||||
func TestNewConnection(t *testing.T) {
|
||||
testData := []struct {
|
||||
addr string
|
||||
con *Connection
|
||||
}{
|
||||
{
|
||||
"USERID:PASSW0RD@lan(192.168.1.1)",
|
||||
&Connection{
|
||||
Hostname: "192.168.1.1",
|
||||
Username: "USERID",
|
||||
Password: "PASSW0RD",
|
||||
Interface: "lan",
|
||||
},
|
||||
},
|
||||
{
|
||||
"USERID:PASS:!@#$%^&*(234)_+W0RD@lan(192.168.1.1)",
|
||||
&Connection{
|
||||
Hostname: "192.168.1.1",
|
||||
Username: "USERID",
|
||||
Password: "PASS:!@#$%^&*(234)_+W0RD",
|
||||
Interface: "lan",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, v := range testData {
|
||||
assert.Equal(t, v.con, NewConnection(v.addr))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user