Skip to content

Commit

Permalink
util/encrypt: migrate TestPad from test-infra to testify (pingcap#27816)
Browse files Browse the repository at this point in the history
Signed-off-by: Karuppiah Natarajan <karuppiah7890@users.noreply.github.com>
  • Loading branch information
karuppiah7890 committed Sep 13, 2021
1 parent 9d3b67f commit e0fbf97
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions util/encrypt/aes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

. "github.com/pingcap/check"
"github.com/pingcap/tidb/util/testleak"
"github.com/stretchr/testify/require"
)

var _ = Suite(&testEncryptSuite{})
Expand All @@ -38,23 +39,21 @@ func toHex(buf []byte) string {
return strings.ToUpper(hex.EncodeToString(buf))
}

func (s *testEncryptSuite) TestPad(c *C) {
defer testleak.AfterTest(c)()

func TestPad(t *testing.T) {
p := []byte{0x0A, 0x0B, 0x0C, 0x0D}
p, err := PKCS7Pad(p, 8)
c.Assert(err, IsNil)
c.Assert(toHex(p), Equals, "0A0B0C0D04040404")
require.NoError(t, err)
require.Equal(t, "0A0B0C0D04040404", toHex(p))

p = []byte{0x0A, 0x0B, 0x0C, 0x0D, 0x0A, 0x0B, 0x0C, 0x0D}
p, err = PKCS7Pad(p, 8)
c.Assert(err, IsNil)
c.Assert(toHex(p), Equals, "0A0B0C0D0A0B0C0D0808080808080808")
require.NoError(t, err)
require.Equal(t, "0A0B0C0D0A0B0C0D0808080808080808", toHex(p))

p = []byte{0x0A, 0x0B, 0x0C, 0x0D}
p, err = PKCS7Pad(p, 16)
c.Assert(err, IsNil)
c.Assert(toHex(p), Equals, "0A0B0C0D0C0C0C0C0C0C0C0C0C0C0C0C")
require.NoError(t, err)
require.Equal(t, "0A0B0C0D0C0C0C0C0C0C0C0C0C0C0C0C", toHex(p))
}

func (s *testEncryptSuite) TestUnpad(c *C) {
Expand Down

0 comments on commit e0fbf97

Please sign in to comment.