2021-04-14 14:28:21 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHasNonEmptyCredentials(t *testing.T) {
|
|
|
|
tests := []struct {
|
2021-05-24 20:05:56 +00:00
|
|
|
username, password, token string
|
|
|
|
expected bool
|
2021-04-14 14:28:21 +00:00
|
|
|
}{
|
2021-05-24 20:05:56 +00:00
|
|
|
|
2021-04-14 14:28:21 +00:00
|
|
|
{
|
2021-05-24 20:05:56 +00:00
|
|
|
"", "", "",
|
2021-04-14 14:28:21 +00:00
|
|
|
false,
|
|
|
|
},
|
|
|
|
{
|
2021-05-24 20:05:56 +00:00
|
|
|
"user", "", "",
|
2021-04-14 14:28:21 +00:00
|
|
|
false,
|
|
|
|
},
|
|
|
|
{
|
2021-05-24 20:05:56 +00:00
|
|
|
"", "pass", "",
|
2021-04-14 14:28:21 +00:00
|
|
|
false,
|
|
|
|
},
|
|
|
|
{
|
2021-05-24 20:05:56 +00:00
|
|
|
"", "pass", "tok",
|
2021-04-14 14:28:21 +00:00
|
|
|
true,
|
|
|
|
},
|
|
|
|
{
|
2021-05-24 20:05:56 +00:00
|
|
|
"user", "", "tok",
|
2021-04-14 14:28:21 +00:00
|
|
|
true,
|
|
|
|
},
|
|
|
|
{
|
2021-05-24 20:05:56 +00:00
|
|
|
"", "", "tok",
|
2021-04-14 14:28:21 +00:00
|
|
|
true,
|
|
|
|
},
|
|
|
|
{
|
2021-05-24 20:05:56 +00:00
|
|
|
"user", "pass", "tok",
|
2021-04-14 14:28:21 +00:00
|
|
|
true,
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2021-05-24 20:05:56 +00:00
|
|
|
"user", "pass", "",
|
2021-04-14 14:28:21 +00:00
|
|
|
true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
t.Run(fmt.Sprintf("%+v", test), func(t *testing.T) {
|
2021-05-24 20:05:56 +00:00
|
|
|
assert.Equal(t, test.expected, hasNonEmptyCredentials(test.username, test.password, test.token))
|
2021-04-14 14:28:21 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|