Skip to content

Commit

Permalink
When copying test binary, delete first (hashicorp#19331)
Browse files Browse the repository at this point in the history
For plugin tests, we copy the test binary. On macOS, if the
destination binary already exists, then copying over it will result
in an invalid signature.

The easiest workaround is to delete the file before copying.
  • Loading branch information
Christopher Swenson authored Feb 23, 2023
1 parent f2a47b0 commit 794eb8b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vault/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ func TestAddTestPlugin(t testing.T, c *Core, name string, pluginType consts.Plug

// Copy over the file to the temp dir
dst := filepath.Join(tempDir, fileName)

// delete the file first to avoid notary failures in macOS
_ = os.Remove(dst) // ignore error
out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode())
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 794eb8b

Please sign in to comment.