Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
110e3d5e69 |
@@ -2,9 +2,7 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -108,27 +106,3 @@ func TestCryptoInPlace(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, plainText, string(content))
|
require.Equal(t, plainText, string(content))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestDecryptToDescriptorOfDeletedFile checks that secret decrypt given
|
|
||||||
// /dev/fd/N as --output writes through that descriptor. A program may give
|
|
||||||
// the command a temporary file it has already deleted as stdout, pass
|
|
||||||
// /dev/stdout as --output and read the result back from that file.
|
|
||||||
func TestDecryptToDescriptorOfDeletedFile(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
cli, dir := newCryptoTest(t)
|
|
||||||
|
|
||||||
file, err := os.CreateTemp(t.TempDir(), "out")
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
defer func() { _ = file.Close() }()
|
|
||||||
|
|
||||||
require.NoError(t, os.Remove(file.Name()))
|
|
||||||
|
|
||||||
output := fmt.Sprintf("/dev/fd/%d", file.Fd())
|
|
||||||
require.NoError(t, cli.Decrypt("key", filepath.Join(dir, "plain.txt.age"), output))
|
|
||||||
|
|
||||||
content, err := io.ReadAll(file)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.Equal(t, plainText, string(content))
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user