mirror of
https://github.com/anchore/syft
synced 2024-11-15 00:27:07 +00:00
17bbf840cf
* Allow registry auth config without authority value Signed-off-by: Dan Luhring <dan.luhring@anchore.com> * Update CLI tests for new stereoscope log output Signed-off-by: Dan Luhring <dan.luhring@anchore.com>
56 lines
738 B
Go
56 lines
738 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestHasNonEmptyCredentials(t *testing.T) {
|
|
tests := []struct {
|
|
username, password, token string
|
|
expected bool
|
|
}{
|
|
|
|
{
|
|
"", "", "",
|
|
false,
|
|
},
|
|
{
|
|
"user", "", "",
|
|
false,
|
|
},
|
|
{
|
|
"", "pass", "",
|
|
false,
|
|
},
|
|
{
|
|
"", "pass", "tok",
|
|
true,
|
|
},
|
|
{
|
|
"user", "", "tok",
|
|
true,
|
|
},
|
|
{
|
|
"", "", "tok",
|
|
true,
|
|
},
|
|
{
|
|
"user", "pass", "tok",
|
|
true,
|
|
},
|
|
|
|
{
|
|
"user", "pass", "",
|
|
true,
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(fmt.Sprintf("%+v", test), func(t *testing.T) {
|
|
assert.Equal(t, test.expected, hasNonEmptyCredentials(test.username, test.password, test.token))
|
|
})
|
|
}
|
|
}
|