Skip to content

Commit 92fa20c

Browse files
vtgdanielnelson
authored andcommitted
ipmi_sensor: allow @ symbol in password (#2633)
1 parent c9f8308 commit 92fa20c

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ be deprecated eventually.
6767

6868
### Bugfixes
6969

70+
- [#2633](https://github.com/influxdata/telegraf/pull/2633): ipmi_sensor: allow @ symbol in password
7071
- [#2077](https://github.com/influxdata/telegraf/issues/2077): SQL Server Input - Arithmetic overflow error converting numeric to data type int.
7172
- [#2262](https://github.com/influxdata/telegraf/issues/2262): Flush jitter can inhibit metric collection.
7273
- [#2318](https://github.com/influxdata/telegraf/issues/2318): haproxy input - Add missing fields.

plugins/inputs/ipmi_sensor/connection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Connection struct {
1818

1919
func NewConnection(server string) *Connection {
2020
conn := &Connection{}
21-
inx1 := strings.Index(server, "@")
21+
inx1 := strings.LastIndex(server, "@")
2222
inx2 := strings.Index(server, "(")
2323
inx3 := strings.Index(server, ")")
2424

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package ipmi_sensor
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
type conTest struct {
10+
Got string
11+
Want *Connection
12+
}
13+
14+
func TestNewConnection(t *testing.T) {
15+
testData := []struct {
16+
addr string
17+
con *Connection
18+
}{
19+
{
20+
"USERID:PASSW0RD@lan(192.168.1.1)",
21+
&Connection{
22+
Hostname: "192.168.1.1",
23+
Username: "USERID",
24+
Password: "PASSW0RD",
25+
Interface: "lan",
26+
},
27+
},
28+
{
29+
"USERID:PASS:!@#$%^&*(234)_+W0RD@lan(192.168.1.1)",
30+
&Connection{
31+
Hostname: "192.168.1.1",
32+
Username: "USERID",
33+
Password: "PASS:!@#$%^&*(234)_+W0RD",
34+
Interface: "lan",
35+
},
36+
},
37+
}
38+
39+
for _, v := range testData {
40+
assert.Equal(t, v.con, NewConnection(v.addr))
41+
}
42+
}

0 commit comments

Comments
 (0)