diff --git a/CHANGELOG.md b/CHANGELOG.md index 043a51a69dea0..333963bd59f85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ be deprecated eventually. ### Bugfixes +- [#2633](https://github.com/influxdata/telegraf/pull/2633): ipmi_sensor: allow @ symbol in password - [#2077](https://github.com/influxdata/telegraf/issues/2077): SQL Server Input - Arithmetic overflow error converting numeric to data type int. - [#2262](https://github.com/influxdata/telegraf/issues/2262): Flush jitter can inhibit metric collection. - [#2318](https://github.com/influxdata/telegraf/issues/2318): haproxy input - Add missing fields. diff --git a/plugins/inputs/ipmi_sensor/connection.go b/plugins/inputs/ipmi_sensor/connection.go index 432b4aa02aad3..b93cda7d4763f 100644 --- a/plugins/inputs/ipmi_sensor/connection.go +++ b/plugins/inputs/ipmi_sensor/connection.go @@ -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, ")") diff --git a/plugins/inputs/ipmi_sensor/connection_test.go b/plugins/inputs/ipmi_sensor/connection_test.go new file mode 100644 index 0000000000000..13a62061daa6a --- /dev/null +++ b/plugins/inputs/ipmi_sensor/connection_test.go @@ -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)) + } +}