-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Carlos A Becker <[email protected]>
- Loading branch information
Showing
7 changed files
with
109 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
-----BEGIN OPENSSH PRIVATE KEY----- | ||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz | ||
c2gtZWQyNTUxOQAAACAV84f5iFg4YcIW0NpDTxEFhU98BsACUQgKJia4yhGU+AAA | ||
AIiaywRCmssEQgAAAAtzc2gtZWQyNTUxOQAAACAV84f5iFg4YcIW0NpDTxEFhU98 | ||
AIgb2DVoG9g1aAAAAAtzc2gtZWQyNTUxOQAAACAV84f5iFg4YcIW0NpDTxEFhU98 | ||
BsACUQgKJia4yhGU+AAAAECOnIiVlopOI+nd/IWGdpjm6+ggY8zwdWDMccQKrZk0 | ||
2xXzh/mIWDhhwhbQ2kNPEQWFT3wGwAJRCAomJrjKEZT4AAAAAAECAwQF | ||
-----END OPENSSH PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1 @@ | ||
package melt | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/matryer/is" | ||
) | ||
|
||
func TestBackupRestoreKnownKey(t *testing.T) { | ||
const expectedMnemonic = ` | ||
model tone century code pilot | ||
ball polar sauce machine crisp | ||
plate soccer salon awake monkey | ||
own install all broccoli marine | ||
print smart square impact | ||
` | ||
const expectedSum = "4ec2b1e65bb86ef635991c3e31341c3bdaf6862e9b1efcde0a9c0307081ffc4c" | ||
|
||
t.Run("backup", func(t *testing.T) { | ||
is := is.New(t) | ||
mnemonic, sum, err := Backup("testdata/test_ed25519") | ||
is.NoErr(err) | ||
is.Equal(mnemonic, strings.Join(strings.Fields(expectedMnemonic), " ")) | ||
is.Equal(sum, expectedSum) | ||
}) | ||
|
||
t.Run("restore", func(t *testing.T) { | ||
is := is.New(t) | ||
path := filepath.Join(t.TempDir(), "key") | ||
sum, err := Restore(path, expectedMnemonic, "ed25519") | ||
is.NoErr(err) | ||
is.Equal(sum, expectedSum) | ||
}) | ||
} | ||
|
||
func TestRestore(t *testing.T) { | ||
t.Run("invalid arg", func(t *testing.T) { | ||
_, err := Restore(t.TempDir(), "does not matter", "rsa") | ||
is.New(t).True(err != nil) | ||
}) | ||
} |