mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
60 lines
862 B
Go
60 lines
862 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestHasNonEmptyCredentials(t *testing.T) {
|
|
tests := []struct {
|
|
auth, username, password, token string
|
|
expected bool
|
|
}{
|
|
{
|
|
"", "", "", "",
|
|
false,
|
|
},
|
|
{
|
|
"auth", "", "", "",
|
|
false,
|
|
},
|
|
{
|
|
"auth", "user", "", "",
|
|
false,
|
|
},
|
|
{
|
|
"auth", "", "pass", "",
|
|
false,
|
|
},
|
|
{
|
|
"auth", "", "pass", "tok",
|
|
true,
|
|
},
|
|
{
|
|
"auth", "user", "", "tok",
|
|
true,
|
|
},
|
|
{
|
|
"auth", "", "", "tok",
|
|
true,
|
|
},
|
|
{
|
|
"auth", "user", "pass", "tok",
|
|
true,
|
|
},
|
|
|
|
{
|
|
"auth", "user", "pass", "",
|
|
true,
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(fmt.Sprintf("%+v", test), func(t *testing.T) {
|
|
assert.Equal(t, test.expected, hasNonEmptyCredentials(test.auth, test.username, test.password, test.token))
|
|
})
|
|
}
|
|
}
|