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

test: Update Python interop tests to python-tuf v1.0.0 #228

Merged
merged 8 commits into from
Aug 26, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions client/python_interop/python_interop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"net"
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -43,11 +44,11 @@ func (InteropSuite) TestGoClientPythonGenerated(c *C) {
// start file server
cwd, err := os.Getwd()
c.Assert(err, IsNil)
testDataDir := filepath.Join(cwd, "testdata", "python-tuf-v0.11.1")
testDataDir := filepath.Join(cwd, "testdata", "python-tuf-v1.0.0")
addr, cleanup := startFileServer(c, testDataDir)
defer cleanup()

for _, dir := range []string{"with-consistent-snapshot", "without-consistent-snapshot"} {
for _, dir := range []string{"without-consistent-snapshot", "with-consistent-snapshot"} {
remote, err := client.HTTPRemoteStore(
fmt.Sprintf("http://%s/%s/repository", addr, dir),
&client.HTTPRemoteOptions{MetadataPath: "metadata", TargetsPath: "targets"},
Expand All @@ -57,7 +58,7 @@ func (InteropSuite) TestGoClientPythonGenerated(c *C) {

// initiate a client with the root metadata
client := client.NewClient(client.MemoryLocalStore(), remote)
rootJSON, err := ioutil.ReadFile(filepath.Join(testDataDir, dir, "repository", "metadata", "root.json"))
rootJSON, err := ioutil.ReadFile(filepath.Join(testDataDir, dir, "repository", "metadata", "1.root.json"))
c.Assert(err, IsNil)
c.Assert(client.Init(rootJSON), IsNil)

Expand Down Expand Up @@ -112,18 +113,17 @@ func (InteropSuite) TestPythonClientGoGenerated(c *C) {
cwd, err := os.Getwd()
c.Assert(err, IsNil)

tmp := c.MkDir()
files := map[string][]byte{
"foo.txt": []byte("foo"),
"bar/baz.txt": []byte("baz"),
}

// start file server
addr, cleanup := startFileServer(c, tmp)
defer cleanup()

for _, consistentSnapshot := range []bool{false, true} {
// generate repository
tmp := c.MkDir()
// start file server
addr, cleanup := startFileServer(c, tmp)
defer cleanup()
name := fmt.Sprintf("consistent-snapshot-%t", consistentSnapshot)
dir := filepath.Join(tmp, name)
generateRepoFS(c, dir, files, consistentSnapshot)
Expand All @@ -134,14 +134,13 @@ func (InteropSuite) TestPythonClientGoGenerated(c *C) {
prevDir := filepath.Join(clientDir, "tufrepo", "metadata", "previous")
c.Assert(os.MkdirAll(currDir, 0755), IsNil)
c.Assert(os.MkdirAll(prevDir, 0755), IsNil)
rootJSON, err := ioutil.ReadFile(filepath.Join(dir, "repository", "root.json"))
rootJSON, err := ioutil.ReadFile(filepath.Join(dir, "repository", "1.root.json"))
c.Assert(err, IsNil)
c.Assert(ioutil.WriteFile(filepath.Join(currDir, "root.json"), rootJSON, 0644), IsNil)

args := []string{
filepath.Join(cwd, "testdata", "python-tuf-v0.11.1", "client.py"),
filepath.Join(cwd, "testdata", "python-tuf-v1.0.0", "client.py"),
"--repo=http://" + addr + "/" + name,
"--verbose=5",
}
for path := range files {
args = append(args, path)
Expand All @@ -156,7 +155,7 @@ func (InteropSuite) TestPythonClientGoGenerated(c *C) {

// check the target files got downloaded
for path, expected := range files {
actual, err := ioutil.ReadFile(filepath.Join(clientDir, "tuftargets", path))
actual, err := ioutil.ReadFile(filepath.Join(clientDir, "tuftargets", url.QueryEscape(path)))
c.Assert(err, IsNil)
c.Assert(actual, DeepEquals, expected)
}
Expand Down
8 changes: 5 additions & 3 deletions client/python_interop/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
PYTHON_TUF=python-tuf-v1.0.0

all:
docker build -t tuf-gen ./generate
docker run tuf-gen | tar x
docker build -t tuf-gen ./$(PYTHON_TUF)
docker run tuf-gen | tar x -C $(PYTHON_TUF)

clean:
rm -rf python-tuf-0.9/with{,out}-consistent-snapshot
rm -rf $(PYTHON_TUF)/with{,out}-consistent-snapshot

.PHONY: all clean

This file was deleted.

12 changes: 0 additions & 12 deletions client/python_interop/testdata/python-tuf-v0.11.1/Dockerfile

This file was deleted.

244 changes: 0 additions & 244 deletions client/python_interop/testdata/python-tuf-v0.11.1/client.py

This file was deleted.

Loading