G3: Generate TUF 1.0 metadata
This patch completes the transition to generating TUF 1.0 compatible
metadata, which entails lowercasing the "_type" field, and advancing
the "spec_version" to "1.0".
Note: While go-tuf is producing TUF 1.0 metadata, it does not yet
implement the TUF 1.0 workflow.
Change-Id: I6a5f2d38f41668d217add56a1314080d26e12cac
diff --git a/client/python_interop/python_interop_test.go b/client/python_interop/python_interop_test.go
index 9f534a9..c565777 100644
--- a/client/python_interop/python_interop_test.go
+++ b/client/python_interop/python_interop_test.go
@@ -26,8 +26,8 @@
var _ = Suite(&InteropSuite{})
var pythonTargets = map[string][]byte{
- "/file1.txt": []byte("file1.txt"),
- "/dir/file2.txt": []byte("file2.txt"),
+ "file1.txt": []byte("file1.txt"),
+ "dir/file2.txt": []byte("file2.txt"),
}
// Hook up gocheck into the "go test" runner.
@@ -47,7 +47,7 @@
// start file server
cwd, err := os.Getwd()
c.Assert(err, IsNil)
- testDataDir := filepath.Join(cwd, "testdata", "python-tuf-v0.9.9")
+ testDataDir := filepath.Join(cwd, "testdata", "python-tuf-v0.11.1")
addr, cleanup := startFileServer(c, testDataDir)
defer cleanup()
@@ -119,13 +119,14 @@
// clone the Python client if necessary
cwd, err := os.Getwd()
c.Assert(err, IsNil)
- tufDir := filepath.Join(cwd, "testdata", "python-tuf-v0.9.9", "tuf")
+ tufDir := filepath.Join(cwd, "testdata", "python-tuf-v0.11.1", "tuf")
if _, err := os.Stat(tufDir); os.IsNotExist(err) {
c.Assert(exec.Command(
"git",
"clone",
"--quiet",
- "--branch=v0.9.9",
+ "--branch=v0.11.1",
+ "--single-branch",
"--depth=1",
"https://github.com/theupdateframework/tuf.git",
tufDir,
@@ -162,16 +163,25 @@
// create initial files for Python client
clientDir := filepath.Join(dir, "client")
- currDir := filepath.Join(clientDir, "metadata", "current")
- prevDir := filepath.Join(clientDir, "metadata", "previous")
+ currDir := filepath.Join(clientDir, "tufrepo", "metadata", "current")
+ 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"))
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"),
+ "--repo=http://" + addr + "/" + name,
+ "--verbose=5",
+ }
+ for path := range files {
+ args = append(args, path)
+ }
+
// run Python client update
- cmd := exec.Command("python", filepath.Join(cwd, "testdata", "python-tuf-v0.9.9", "client.py"), "--repo=http://"+addr+"/"+name)
+ cmd := exec.Command("python", args...)
cmd.Env = pythonEnv
cmd.Dir = clientDir
cmd.Stdout = os.Stdout
@@ -180,7 +190,7 @@
// check the target files got downloaded
for path, expected := range files {
- actual, err := ioutil.ReadFile(filepath.Join(clientDir, "targets", path))
+ actual, err := ioutil.ReadFile(filepath.Join(clientDir, "tuftargets", path))
c.Assert(err, IsNil)
c.Assert(actual, DeepEquals, expected)
}
diff --git a/data/types.go b/data/types.go
index 7eda908..265f7af 100644
--- a/data/types.go
+++ b/data/types.go
@@ -110,8 +110,8 @@
func NewRoot() *Root {
return &Root{
- Type: "Root",
- SpecVersion: "0.9",
+ Type: "root",
+ SpecVersion: "1.0",
Expires: DefaultExpires("root"),
Keys: make(map[string]*Key),
Roles: make(map[string]*Role),
@@ -190,8 +190,8 @@
func NewSnapshot() *Snapshot {
return &Snapshot{
- Type: "Snapshot",
- SpecVersion: "0.9",
+ Type: "snapshot",
+ SpecVersion: "1.0",
Expires: DefaultExpires("snapshot"),
Meta: make(SnapshotFiles),
}
@@ -217,8 +217,8 @@
func NewTargets() *Targets {
return &Targets{
- Type: "Targets",
- SpecVersion: "0.9",
+ Type: "targets",
+ SpecVersion: "1.0",
Expires: DefaultExpires("targets"),
Targets: make(TargetFiles),
}
@@ -241,8 +241,8 @@
func NewTimestamp() *Timestamp {
return &Timestamp{
- Type: "Timestamp",
- SpecVersion: "0.9",
+ Type: "timestamp",
+ SpecVersion: "1.0",
Expires: DefaultExpires("timestamp"),
Meta: make(TimestampFiles),
}