Skip to content

Commit

Permalink
pass down error with message instead of nil (#1560)
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Callaway <[email protected]>
  • Loading branch information
bobcallaway authored Jun 23, 2023
1 parent ffdd884 commit c2e3149
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions cmd/rekor-cli/logproof_e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright 2023 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build e2e

package main

import (
"testing"

"github.com/sigstore/rekor/pkg/util"
)

// TestLogProofLastSizeBiggerThanCurrentLog tests that asking for a consistency proof for a size greater than the current log
func TestLogProofLastSizeBiggerThanCurrentLog(t *testing.T) {
out := util.RunCliErr(t, "logproof", "--last-size", "14212414124124124")
util.OutputContains(t, out, "400")
}
3 changes: 2 additions & 1 deletion pkg/api/tlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ func GetLogProofHandler(params tlog.GetLogProofParams) middleware.Responder {
// The proof field may be empty if the requested tree_size was larger than that available at the server
// (e.g. because there is skew between server instances, and an earlier client request was processed by
// a more up-to-date instance). root.TreeSize is the maximum size currently observed
return handleRekorAPIError(params, http.StatusBadRequest, nil, fmt.Sprintf(lastSizeGreaterThanKnown, params.LastSize, root.TreeSize))
err := fmt.Errorf(lastSizeGreaterThanKnown, params.LastSize, root.TreeSize)
return handleRekorAPIError(params, http.StatusBadRequest, err, err.Error())
}

consistencyProof := models.ConsistencyProof{
Expand Down

0 comments on commit c2e3149

Please sign in to comment.