Adds unit testing for jws

This commit is contained in:
2015-08-18 18:34:23 +02:00
parent 00c5853b45
commit abe3cbab1f
6 changed files with 187 additions and 23 deletions

View File

@@ -86,3 +86,18 @@ func (s *JOSESuite) TestHandlesPrivateHeaders(c *C) {
c.Assert(res, DeepEquals, j)
}
}
func (s *JOSESuite) TestEncodingIsCompact(c *C) {
j := &JOSE{
Algorithm: "none",
Critical: []string{"exp", "foo"},
}
// it does not print empty fields.
data, err := j.EncodeJSON()
c.Check(err, IsNil)
c.Check(string(data), Equals, `{"alg":"none","crit":["exp","foo"]}`)
b64, err := j.EncodeBase64()
c.Check(err, IsNil)
c.Check(len(b64), Equals, 47)
}