Skip to content

Commit

Permalink
test(client): fix fixtures
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Igrychev <[email protected]>
  • Loading branch information
alexey-igrychev committed Sep 20, 2022
1 parent 4f731e3 commit 59af5a4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 75 deletions.
14 changes: 13 additions & 1 deletion e2e/tests/client/_fixtures/tuf_repo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
FROM golang:1.19 as tuf_repo

RUN go install github.com/theupdateframework/go-tuf/cmd/[email protected]

RUN mkdir /workspace
WORKDIR /workspace

ENV TUF_ROOT_PASSPHRASE="foobar" \
TUF_TARGETS_PASSPHRASE="foobar" \
TUF_SNAPSHOT_PASSPHRASE="foobar" \
TUF_TIMESTAMP_PASSPHRASE="foobar"
RUN tuf gen-key root \
&& tuf gen-key targets \
&& tuf gen-key snapshot \
&& tuf gen-key timestamp \
&& tuf sign root.json

COPY staged /workspace/staged
COPY keys /workspace/keys
RUN find staged/targets -type f -print0 | xargs -0 -n1 | sed -e "s|^staged/targets/||" | tuf add \
&& tuf snapshot \
&& tuf timestamp \
Expand Down
17 changes: 0 additions & 17 deletions e2e/tests/client/_fixtures/tuf_repo/keys/root.json

This file was deleted.

17 changes: 0 additions & 17 deletions e2e/tests/client/_fixtures/tuf_repo/keys/snapshot.json

This file was deleted.

17 changes: 0 additions & 17 deletions e2e/tests/client/_fixtures/tuf_repo/keys/targets.json

This file was deleted.

17 changes: 0 additions & 17 deletions e2e/tests/client/_fixtures/tuf_repo/keys/timestamp.json

This file was deleted.

1 change: 0 additions & 1 deletion e2e/tests/client/_fixtures/tuf_repo/staged/root.json

This file was deleted.

27 changes: 22 additions & 5 deletions e2e/tests/client/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package client

import (
"io/ioutil"
"net/http"
"os"
"strings"
"testing"
Expand All @@ -9,6 +11,7 @@ import (
. "github.com/onsi/gomega"
"github.com/prashantv/gostub"

"github.com/werf/trdl/client/pkg/util"
"github.com/werf/trdl/server/pkg/testutil"
)

Expand All @@ -21,8 +24,8 @@ var (
testRepoName = "test"

validRepoUrl string
validRootVersion = "0"
validRootSHA512 = "951ca9cd3e55162a2e990a9d291d51684e2bf4e7537003cf40649f7612ac9db7f9a73ff8ceb05ac14eba32c706b30874cf21a98d01a02293149d0cbbdb1e4f99"
validRootSHA512 string
validRootVersion string
validGroup = "0"
)

Expand All @@ -35,7 +38,7 @@ var (
)

var _ = SynchronizedBeforeSuite(func() []byte {
tufRepoUP()
initTufRepo()
return testutil.ComputeTrdlBinPath()
}, func(computedPathToTrdl []byte) {
trdlBinPath = string(computedPathToTrdl)
Expand All @@ -49,13 +52,13 @@ var _ = SynchronizedBeforeSuite(func() []byte {
trdlBinVersion = version
})

func tufRepoUP() {
func initTufRepo() {
fixturesDir := testutil.FixturePath("tuf_repo")
testutil.RunSucceedCommand(
"",
"docker-compose",
"--project-directory", fixturesDir,
"up", "--detach",
"up", "--detach", "--build",
)

output := testutil.SucceedCommandOutputString(
Expand All @@ -65,6 +68,20 @@ func tufRepoUP() {
"port", "server", "8080",
)
validRepoUrl = "http://" + strings.TrimSpace(output)

// Get root.json SHA sum.
{
rootJsonURI := validRepoUrl + "/root.json"
resp, err := http.Get(rootJsonURI)
Ω(err).ShouldNot(HaveOccurred())
defer resp.Body.Close()

data, err := ioutil.ReadAll(resp.Body)
Ω(err).ShouldNot(HaveOccurred())

validRootVersion = "0"
validRootSHA512 = util.Sha512Checksum(data)
}
}

var _ = AfterSuite(func() {
Expand Down

0 comments on commit 59af5a4

Please sign in to comment.