Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect proto copying for client multilog config. #558

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/multilog.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ type TemporalLogClient struct {

// NewTemporalLogClient builds a new client for interacting with a temporal log.
// The provided config should be contiguous and chronological.
func NewTemporalLogClient(cfg configpb.TemporalLogConfig, hc *http.Client) (*TemporalLogClient, error) {
if len(cfg.Shard) == 0 {
func NewTemporalLogClient(cfg *configpb.TemporalLogConfig, hc *http.Client) (*TemporalLogClient, error) {
if len(cfg.GetShard()) == 0 {
return nil, errors.New("empty config")
}

Expand Down
60 changes: 30 additions & 30 deletions client/multilog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ func TestNewTemporalLogClient(t *testing.T) {
ts4, _ := ptypes.TimestampProto(time.Date(2014, 9, 19, 11, 00, 00, 00, time.UTC))

tests := []struct {
cfg configpb.TemporalLogConfig
cfg *configpb.TemporalLogConfig
wantErr string
}{
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: nil, NotAfterLimit: nil},
},
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts0, NotAfterLimit: ts1},
{Uri: "two", NotAfterStart: ts1, NotAfterLimit: ts2},
Expand All @@ -63,7 +63,7 @@ func TestNewTemporalLogClient(t *testing.T) {
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: nil, NotAfterLimit: ts1},
{Uri: "two", NotAfterStart: ts1, NotAfterLimit: ts2},
Expand All @@ -73,7 +73,7 @@ func TestNewTemporalLogClient(t *testing.T) {
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: nil, NotAfterLimit: ts1},
{Uri: "two", NotAfterStart: ts1, NotAfterLimit: ts2},
Expand All @@ -83,7 +83,7 @@ func TestNewTemporalLogClient(t *testing.T) {
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts0, NotAfterLimit: ts1},
{Uri: "two", NotAfterStart: ts1, NotAfterLimit: ts2},
Expand All @@ -93,7 +93,7 @@ func TestNewTemporalLogClient(t *testing.T) {
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts0, NotAfterLimit: ts1},
{Uri: "two", NotAfterStart: ts1, NotAfterLimit: ts2},
Expand All @@ -105,7 +105,7 @@ func TestNewTemporalLogClient(t *testing.T) {
wantErr: "previous interval ended at",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts0, NotAfterLimit: ts1},
{Uri: "three", NotAfterStart: ts2, NotAfterLimit: ts3},
Expand All @@ -116,7 +116,7 @@ func TestNewTemporalLogClient(t *testing.T) {
wantErr: "previous interval ended at",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: nil, NotAfterLimit: ts1},
{Uri: "two", NotAfterStart: ts1, NotAfterLimit: ts1},
Expand All @@ -127,7 +127,7 @@ func TestNewTemporalLogClient(t *testing.T) {
wantErr: "inverted",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts0, NotAfterLimit: ts1},
{Uri: "two", NotAfterStart: ts1, NotAfterLimit: nil},
Expand All @@ -138,7 +138,7 @@ func TestNewTemporalLogClient(t *testing.T) {
wantErr: "no upper bound",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts0, NotAfterLimit: ts1},
{Uri: "two", NotAfterStart: ts1, NotAfterLimit: ts2},
Expand All @@ -152,43 +152,43 @@ func TestNewTemporalLogClient(t *testing.T) {
wantErr: "empty",
},
{
cfg: configpb.TemporalLogConfig{Shard: []*configpb.LogShardConfig{}},
cfg: &configpb.TemporalLogConfig{Shard: []*configpb.LogShardConfig{}},
wantErr: "empty",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts1, NotAfterLimit: ts1},
},
},
wantErr: "inverted",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts2, NotAfterLimit: ts1},
},
},
wantErr: "inverted",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: &tspb.Timestamp{Seconds: -1, Nanos: -1}, NotAfterLimit: ts2},
},
},
wantErr: "failed to parse",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "one", NotAfterStart: ts1, NotAfterLimit: &tspb.Timestamp{Seconds: -1, Nanos: -1}},
},
},
wantErr: "failed to parse",
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{
Uri: "one",
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestIndexByDate(t *testing.T) {
ts3, _ := ptypes.TimestampProto(time3)
ts4, _ := ptypes.TimestampProto(time4)

allCfg := configpb.TemporalLogConfig{
allCfg := &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "zero", NotAfterStart: nil, NotAfterLimit: ts0},
{Uri: "one", NotAfterStart: ts0, NotAfterLimit: ts1},
Expand All @@ -242,7 +242,7 @@ func TestIndexByDate(t *testing.T) {
{Uri: "five", NotAfterStart: ts4, NotAfterLimit: nil},
},
}
uptoCfg := configpb.TemporalLogConfig{
uptoCfg := &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "zero", NotAfterStart: nil, NotAfterLimit: ts0},
{Uri: "one", NotAfterStart: ts0, NotAfterLimit: ts1},
Expand All @@ -252,7 +252,7 @@ func TestIndexByDate(t *testing.T) {
},
}
fromCfg :=
configpb.TemporalLogConfig{
&configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "zero", NotAfterStart: ts0, NotAfterLimit: ts1},
{Uri: "one", NotAfterStart: ts1, NotAfterLimit: ts2},
Expand All @@ -262,7 +262,7 @@ func TestIndexByDate(t *testing.T) {
},
}
boundedCfg :=
configpb.TemporalLogConfig{
&configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: "zero", NotAfterStart: ts0, NotAfterLimit: ts1},
{Uri: "one", NotAfterStart: ts1, NotAfterLimit: ts2},
Expand All @@ -272,7 +272,7 @@ func TestIndexByDate(t *testing.T) {
}

tests := []struct {
cfg configpb.TemporalLogConfig
cfg *configpb.TemporalLogConfig
when time.Time
want int
wantErr bool
Expand Down Expand Up @@ -374,47 +374,47 @@ func TestTemporalAddChain(t *testing.T) {
}

tests := []struct {
cfg configpb.TemporalLogConfig
cfg *configpb.TemporalLogConfig
wantErr bool
}{
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: hs.URL, NotAfterStart: nil, NotAfterLimit: nil, PublicKeyDer: p.Bytes},
},
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: hs.URL, NotAfterStart: nil, NotAfterLimit: ts2, PublicKeyDer: p.Bytes},
},
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: hs.URL, NotAfterStart: ts1, NotAfterLimit: nil, PublicKeyDer: p.Bytes},
},
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: hs.URL, NotAfterStart: ts1, NotAfterLimit: ts2, PublicKeyDer: p.Bytes},
},
},
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: hs.URL, NotAfterStart: nil, NotAfterLimit: ts1, PublicKeyDer: p.Bytes},
},
},
wantErr: true,
},
{
cfg: configpb.TemporalLogConfig{
cfg: &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{Uri: hs.URL, NotAfterStart: ts2, NotAfterLimit: nil, PublicKeyDer: p.Bytes},
},
Expand Down Expand Up @@ -455,7 +455,7 @@ func TestTemporalAddChainErrors(t *testing.T) {
hs := serveSCTAt(t, "/ct/v1/add-chain", testdata.TestCertProof)
defer hs.Close()

cfg := configpb.TemporalLogConfig{
cfg := &configpb.TemporalLogConfig{
Shard: []*configpb.LogShardConfig{
{
Uri: hs.URL,
Expand Down
2 changes: 1 addition & 1 deletion preload/preloader/preloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func main() {
if err != nil {
glog.Exitf("Failed to load temporal log config: %v", err)
}
submitLogClient, err = client.NewTemporalLogClient(*cfg, &http.Client{Transport: transport})
submitLogClient, err = client.NewTemporalLogClient(cfg, &http.Client{Transport: transport})
if err != nil {
glog.Exitf("Failed to create client for destination temporal log: %v", err)
}
Expand Down