Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
87
plugins/inputs/ipmi_sensor/connection_test.go
Normal file
87
plugins/inputs/ipmi_sensor/connection_test.go
Normal file
|
@ -0,0 +1,87 @@
|
|||
package ipmi_sensor
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
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",
|
||||
intf: "lan",
|
||||
privilege: "USER",
|
||||
hexKey: "0001",
|
||||
},
|
||||
},
|
||||
{
|
||||
"USERID:PASS:!@#$%^&*(234)_+W0RD@lan(192.168.1.1)",
|
||||
&connection{
|
||||
hostname: "192.168.1.1",
|
||||
username: "USERID",
|
||||
password: "PASS:!@#$%^&*(234)_+W0RD",
|
||||
intf: "lan",
|
||||
privilege: "USER",
|
||||
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: "",
|
||||
intf: "lan",
|
||||
privilege: "USER",
|
||||
hexKey: "0001",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, v := range testData {
|
||||
require.EqualValues(t, v.con, newConnection(v.addr, "USER", "0001"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCommandOptions(t *testing.T) {
|
||||
testData := []struct {
|
||||
connection *connection
|
||||
options []string
|
||||
}{
|
||||
{
|
||||
&connection{
|
||||
hostname: "192.168.1.1",
|
||||
username: "user",
|
||||
password: "password",
|
||||
intf: "lan",
|
||||
privilege: "USER",
|
||||
hexKey: "0001",
|
||||
},
|
||||
[]string{"-H", "192.168.1.1", "-U", "user", "-P", "password", "-I", "lan", "-y", "0001", "-L", "USER"},
|
||||
},
|
||||
{
|
||||
&connection{
|
||||
hostname: "192.168.1.1",
|
||||
username: "user",
|
||||
password: "password",
|
||||
intf: "lan",
|
||||
privilege: "USER",
|
||||
hexKey: "",
|
||||
},
|
||||
[]string{"-H", "192.168.1.1", "-U", "user", "-P", "password", "-I", "lan", "-L", "USER"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, data := range testData {
|
||||
require.EqualValues(t, data.options, data.connection.options())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue