Skip to content

Commit

Permalink
Test if link metadata is generated correctly when no commands are passed
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Sirish <aditya@saky.in>
  • Loading branch information
adityasaky committed Oct 13, 2022
1 parent 5bb106f commit 3508787
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion in_toto/runlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func InTotoRun(name string, runDir string, materialPaths []string, productPaths
}

// make sure that we only run RunCommand if cmdArgs is not nil or empty
var byProducts map[string]interface{}
byProducts := map[string]interface{}{}
if len(cmdArgs) != 0 {
byProducts, err = RunCommand(cmdArgs, runDir)
if err != nil {
Expand Down
24 changes: 24 additions & 0 deletions in_toto/runlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,30 @@ func TestInTotoRun(t *testing.T) {
}},
},
},
{[]string{"alice.pub"}, []string{"foo.tar.gz"}, []string{}, validKey, []string{"sha256"}, Metablock{
Signed: Link{
Name: linkName,
Type: "link",
Materials: map[string]interface{}{
"alice.pub": map[string]interface{}{
"sha256": "f051e8b561835b7b2aa7791db7bc72f2613411b0b7d428a0ac33d45b8c518039",
},
},
Products: map[string]interface{}{
"foo.tar.gz": map[string]interface{}{
"sha256": "52947cb78b91ad01fe81cd6aef42d1f6817e92b9e6936c1e5aabb7c98514f355",
},
},
ByProducts: map[string]interface{}{},
Command: []string{},
Environment: map[string]interface{}{},
},
Signatures: []Signature{{
KeyID: "be6371bc627318218191ce0780fd3183cce6c36da02938a477d2e4dfae1804a6",
Sig: "f4a2d468965d595b4d29615fb2083ef7ac22a948e1530925612d73ba580ce9765d93db7b7ed1b9755d96f13a6a1e858c64693c2f7adcb311afb28cb57fbadc0c",
}},
},
},
}

for _, table := range tablesCorrect {
Expand Down

0 comments on commit 3508787

Please sign in to comment.