File: token_test.go

package info (click to toggle)
coyim 0.3.7-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,064 kB
  • ctags: 4,528
  • sloc: xml: 5,120; sh: 328; python: 286; makefile: 235; ruby: 51
file content (28 lines) | stat: -rw-r--r-- 768 bytes parent folder | download
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
package sasl

import . "gopkg.in/check.v1"

type TokenSuite struct{}

var _ = Suite(&TokenSuite{})

func (s *TokenSuite) Test_Token_String_returnsTheStringValue(c *C) {
	result := Token("foo bar").String()
	c.Assert(result, DeepEquals, "foo bar")
}

func (s *TokenSuite) Test_Token_Encode_willEncode(c *C) {
	result := Token("foo bar").Encode()
	c.Assert(string(result), DeepEquals, "Zm9vIGJhcg==")
}

func (s *TokenSuite) Test_DecodeToken_willDecode(c *C) {
	result, err := DecodeToken([]byte("Zm9vIGJhcg=="))
	c.Assert(err, IsNil)
	c.Assert(result.String(), DeepEquals, "foo bar")
}

func (s *TokenSuite) Test_DecodeToken_willReturnErrorOnFailure(c *C) {
	_, err := DecodeToken([]byte("****"))
	c.Assert(err.Error(), Equals, "illegal base64 data at input byte 0")
}