| 1 |
package keys |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/theupdateframework/go-tuf/data" |
| 7 |
. "gopkg.in/check.v1" |
| 8 |
) |
| 9 |
|
| 10 |
// Hook up gocheck into the "go test" runner. |
| 11 |
func Test(t *testing.T) { TestingT(t) } |
| 12 |
|
| 13 |
type KeysSuite struct{} |
| 14 |
|
| 15 |
var _ = Suite(&KeysSuite{}) |
| 16 |
|
| 17 |
func (KeysSuite) TestSignerKeyIDs(c *C) { |
| 18 |
_, err := GenerateEd25519Key() |
| 19 |
c.Assert(err, IsNil) |
| 20 |
|
| 21 |
// If we have a TUF-0.9 key, we won't have a scheme. |
| 22 |
signer, err := GenerateEd25519Key() |
| 23 |
c.Assert(err, IsNil) |
| 24 |
privKey, err := signer.MarshalPrivateKey() |
| 25 |
c.Assert(err, IsNil) |
| 26 |
privKey.Scheme = "" |
| 27 |
err = signer.UnmarshalPrivateKey(privKey) |
| 28 |
c.Assert(err, IsNil) |
| 29 |
|
| 30 |
// Make sure we preserve ids if we don't have any |
| 31 |
// keyid_hash_algorithms. |
| 32 |
signer, err = GenerateEd25519Key() |
| 33 |
c.Assert(err, IsNil) |
| 34 |
privKey, err = signer.MarshalPrivateKey() |
| 35 |
c.Assert(err, IsNil) |
| 36 |
privKey.Algorithms = []data.HashAlgorithm{} |
| 37 |
err = signer.UnmarshalPrivateKey(privKey) |
| 38 |
c.Assert(err, IsNil) |
| 39 |
} |