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) }
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 *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") }
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) }
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:])) }
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")) }