Skip to content
Snippets Groups Projects
Commit fbaa3ff8 authored by Dan Lorenc's avatar Dan Lorenc
Browse files

Add a second test to make sure duplicates are detected.

parent b4faddc4
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ limitations under the License.
package app
import (
"fmt"
"os"
"github.com/projectrekor/rekor/pkg/generated/client/entries"
......@@ -57,10 +58,16 @@ var uploadCmd = &cobra.Command{
resp, err := rekorClient.Entries.CreateLogEntry(params)
if err != nil {
log.Fatal(err)
switch err.(type) {
case *entries.CreateLogEntryConflict:
fmt.Println("Entry already exists.")
return
default:
log.Fatal(err)
}
}
log.Infof("Created entry at: %v%v", viper.GetString("rekor_server"), resp.Location)
fmt.Printf("Created entry at: %v%v\n", viper.GetString("rekor_server"), resp.Location)
},
}
......
......@@ -6,6 +6,19 @@ docker-compose up -d
# Node
nodedir=${testdir}/node
go run ./cmd/cli/ upload \
# First time we should get "Created entry"
out=$(go run ./cmd/cli/ upload \
--artifact $(< ${nodedir}/url) --sha $(< ${nodedir}/sha) \
--signature=${nodedir}/sig --public-key=${nodedir}/key)
if [[ $out != *"Created entry at"* ]]; then
echo "Expected 'Created entry at', got $out"
fi
# Second time we should get "Entry already exists"
out=$(go run ./cmd/cli/ upload \
--artifact $(< ${nodedir}/url) --sha $(< ${nodedir}/sha) \
--signature=${nodedir}/sig --public-key=${nodedir}/key
\ No newline at end of file
--signature=${nodedir}/sig --public-key=${nodedir}/key)
if [[ $out != *"Entry already exists"* ]]; then
echo "Expected 'Created entry at', got $out"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment