func (s *signingSuite) TestDecodeCheckInvalidSignature(c *gc.C) { r := bytes.NewReader([]byte(invalidClearsignInput + testSig)) _, err := simplestreams.DecodeCheckSignature(r, testSigningKey) c.Assert(err, gc.Not(gc.IsNil)) _, ok := err.(*simplestreams.NotPGPSignedError) c.Assert(ok, jc.IsFalse) }
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") }
func (s *signingSuite) TestDecodeCheckMissingSignature(c *gc.C) { r := bytes.NewReader([]byte("foo")) _, err := simplestreams.DecodeCheckSignature(r, testSigningKey) _, ok := err.(*simplestreams.NotPGPSignedError) c.Assert(ok, jc.IsTrue) }
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")) }