cb89496569
- also updated ping chore to pick up trust changes - fixed small typo in blueprint - fixed flags for storj-sim - wired up changes to testplanet Change-Id: I02982f3a63a1b4150b82a009ee126b25ed51917d
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package trust_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"storj.io/storj/storagenode/trust"
|
|
)
|
|
|
|
func TestStaticURLSource(t *testing.T) {
|
|
url := makeSatelliteURL("domain.test")
|
|
|
|
for _, tt := range []struct {
|
|
name string
|
|
url string
|
|
err string
|
|
entries []trust.Entry
|
|
}{
|
|
{
|
|
name: "incomplete satellite URL",
|
|
url: "domain.test:7777",
|
|
err: "static source: invalid satellite URL: must contain an ID",
|
|
},
|
|
{
|
|
name: "good satellite URL",
|
|
url: url.String(),
|
|
entries: []trust.Entry{
|
|
{
|
|
SatelliteURL: url,
|
|
Authoritative: true,
|
|
},
|
|
},
|
|
},
|
|
} {
|
|
tt := tt // quiet linting
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
source, err := trust.NewStaticURLSource(tt.url)
|
|
if tt.err != "" {
|
|
require.EqualError(t, err, tt.err)
|
|
return
|
|
}
|
|
require.NoError(t, err)
|
|
|
|
require.True(t, source.Static(), "static source is not static")
|
|
require.Equal(t, tt.url, source.String(), "static source string should match url")
|
|
|
|
entries, err := source.FetchEntries(context.Background())
|
|
require.NoError(t, err)
|
|
assert.Equal(t, tt.entries, entries)
|
|
})
|
|
}
|
|
}
|