Beispiel #1
1
func (s *decodeSuite) TestDecodeCheckInvalidSignature(c *gc.C) {
	r := bytes.NewReader([]byte(invalidClearsignInput + signSuffix))
	_, err := simplestreams.DecodeCheckSignature(r, testSigningKey)
	c.Assert(err, gc.Not(gc.IsNil))
	_, ok := err.(*simplestreams.NotPGPSignedError)
	c.Assert(ok, jc.IsFalse)
}
Beispiel #2
0
func assertSignedFile(c *gc.C, filename string) {
	r, err := os.Open(filename)
	c.Assert(err, gc.IsNil)
	defer r.Close()
	data, err := simplestreams.DecodeCheckSignature(r, sstesting.SignedMetadataPublicKey)
	c.Assert(err, gc.IsNil)
	c.Assert(string(data), gc.Equals, "hello world\n")
}
Beispiel #3
0
func (s *decodeSuite) TestDecodeCheckMissingKey(c *gc.C) {
	r := bytes.NewReader([]byte(signedData))
	_, err := simplestreams.DecodeCheckSignature(r, "")
	c.Assert(err, gc.ErrorMatches, "failed to parse public key: openpgp: invalid argument: no armored data found")
}
Beispiel #4
0
func (s *decodeSuite) TestDecodeCheckMissingSignature(c *gc.C) {
	r := bytes.NewReader([]byte("foo"))
	_, err := simplestreams.DecodeCheckSignature(r, testSigningKey)
	_, ok := err.(*simplestreams.NotPGPSignedError)
	c.Assert(ok, jc.IsTrue)
}
Beispiel #5
0
func (s *decodeSuite) TestDecodeCheckValidSignature(c *gc.C) {
	r := bytes.NewReader([]byte(signedData))
	txt, err := simplestreams.DecodeCheckSignature(r, testSigningKey)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(txt, gc.DeepEquals, []byte(unsignedData[1:]))
}
Beispiel #6
0
func (s *signingSuite) TestDecodeCheckValidSignature(c *gc.C) {
	r := bytes.NewReader([]byte(validClearsignInput + testSig))
	txt, err := simplestreams.DecodeCheckSignature(r, testSigningKey)
	c.Assert(err, gc.IsNil)
	c.Assert(txt, gc.DeepEquals, []byte("Hello world\nline 2\n"))
}