Skip to content

Commit

Permalink
Moved the server tests to server folder
Browse files Browse the repository at this point in the history
- Moved the server tests to server folder.

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan committed Dec 4, 2022
1 parent fa1106c commit 1a2c4fc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ jobs:

- name: CLI
run: ./tests/e2e-test.sh
- name: PKG-CLI # this will a WIP to move all the CLI tests to the pkg repo
run: ./pkg/e2e-test.sh
- name: Refactor-e2e # this will a WIP to move all the tests to respective packages
run: ./e2e-test.sh
- name: Upload logs if they exist
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
if: failure()
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ logid
!rekor-cli/
rekor-cli
rekor-server
!rekor-server/
/tests/rekor-server
/server
swagger
Expand Down
52 changes: 52 additions & 0 deletions cmd/rekor-server/e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Copyright 2022 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 (
"io/ioutil"
"path/filepath"
"testing"

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

func TestDuplicates(t *testing.T) {
artifactPath := filepath.Join(t.TempDir(), "artifact")
sigPath := filepath.Join(t.TempDir(), "signature.asc")

util.CreatedPGPSignedArtifact(t, artifactPath, sigPath)

// Write the public key to a file
pubPath := filepath.Join(t.TempDir(), "pubKey.asc")
if err := ioutil.WriteFile(pubPath, []byte(util.PubKey), 0644); err != nil {
t.Fatal(err)
}

// Now upload to rekor!
out := util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath, "--public-key", pubPath)
util.OutputContains(t, out, "Created entry at")

// Now upload the same one again, we should get a dupe entry.
out = util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath, "--public-key", pubPath)
util.OutputContains(t, out, "Entry already exists")

// Now do a new one, we should get a new entry
util.CreatedPGPSignedArtifact(t, artifactPath, sigPath)
out = util.RunCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath, "--public-key", pubPath)
util.OutputContains(t, out, "Created entry at")
}
2 changes: 1 addition & 1 deletion pkg/e2e-test.sh → e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ REKORTMPDIR="$(mktemp -d -t rekor_test.XXXXXX)"
cp $dir/rekor-cli $REKORTMPDIR/rekor-cli
touch $REKORTMPDIR.rekor.yaml
trap "rm -rf $REKORTMPDIR" EXIT
if ! REKORTMPDIR=$REKORTMPDIR go test -tags=e2e ./pkg/...; then
if ! REKORTMPDIR=$REKORTMPDIR go test -tags=e2e $(go list ./... | grep -v ./tests) ; then
docker-compose logs --no-color > /tmp/docker-compose.log
exit 1
fi
Expand Down

0 comments on commit 1a2c4fc

Please sign in to comment.