File: keys_test.go

package info (click to toggle)
golang-github-theupdateframework-go-tuf 2.0.2%2B0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,908 kB
  • sloc: python: 164; makefile: 89; sh: 37
file content (39 lines) | stat: -rw-r--r-- 923 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package keys

import (
	"testing"

	"github.com/theupdateframework/go-tuf/data"
	. "gopkg.in/check.v1"
)

// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }

type KeysSuite struct{}

var _ = Suite(&KeysSuite{})

func (KeysSuite) TestSignerKeyIDs(c *C) {
	_, err := GenerateEd25519Key()
	c.Assert(err, IsNil)

	// If we have a TUF-0.9 key, we won't have a scheme.
	signer, err := GenerateEd25519Key()
	c.Assert(err, IsNil)
	privKey, err := signer.MarshalPrivateKey()
	c.Assert(err, IsNil)
	privKey.Scheme = ""
	err = signer.UnmarshalPrivateKey(privKey)
	c.Assert(err, IsNil)

	// Make sure we preserve ids if we don't have any
	// keyid_hash_algorithms.
	signer, err = GenerateEd25519Key()
	c.Assert(err, IsNil)
	privKey, err = signer.MarshalPrivateKey()
	c.Assert(err, IsNil)
	privKey.Algorithms = []data.HashAlgorithm{}
	err = signer.UnmarshalPrivateKey(privKey)
	c.Assert(err, IsNil)
}