2018-08-08 11:55:48 -04:00
|
|
|
package trust
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/cli/cli/trust"
|
|
|
|
"github.com/theupdateframework/notary/client"
|
|
|
|
"github.com/theupdateframework/notary/tuf/data"
|
2020-02-22 12:12:14 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
is "gotest.tools/v3/assert/cmp"
|
2018-08-08 11:55:48 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMatchReleasedSignaturesSortOrder(t *testing.T) {
|
2022-09-29 11:21:51 -04:00
|
|
|
releasesRole := data.DelegationRole{BaseRole: data.BaseRole{Name: trust.ReleasesRole}}
|
2018-08-08 11:55:48 -04:00
|
|
|
targets := []client.TargetSignedStruct{
|
|
|
|
{Target: client.Target{Name: "target10-foo"}, Role: releasesRole},
|
|
|
|
{Target: client.Target{Name: "target1-foo"}, Role: releasesRole},
|
|
|
|
{Target: client.Target{Name: "target2-foo"}, Role: releasesRole},
|
|
|
|
}
|
|
|
|
|
|
|
|
rows := matchReleasedSignatures(targets)
|
|
|
|
|
2022-09-03 14:07:29 -04:00
|
|
|
targetNames := make([]string, 0, len(rows))
|
2018-08-08 11:55:48 -04:00
|
|
|
for _, r := range rows {
|
|
|
|
targetNames = append(targetNames, r.SignedTag)
|
|
|
|
}
|
|
|
|
expected := []string{
|
|
|
|
"target1-foo",
|
|
|
|
"target2-foo",
|
|
|
|
"target10-foo",
|
|
|
|
}
|
|
|
|
assert.Check(t, is.DeepEqual(expected, targetNames))
|
|
|
|
}
|