Skip to content

Commit

Permalink
util/encrypt: migrate TestAESDecryptWithCBC from test-infra to testify (
Browse files Browse the repository at this point in the history
pingcap#27816)

Signed-off-by: Karuppiah Natarajan <karuppiah7890@users.noreply.github.com>
  • Loading branch information
karuppiah7890 committed Sep 13, 2021
1 parent f16114b commit d74f715
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions util/encrypt/aes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ func TestAESDecryptWithOFB(t *testing.T) {
}
}

func (s *testEncryptSuite) TestAESDecryptWithCBC(c *C) {
defer testleak.AfterTest(c)()
func TestAESDecryptWithCBC(t *testing.T) {
tests := []struct {
expect string
key string
Expand All @@ -388,18 +387,18 @@ func (s *testEncryptSuite) TestAESDecryptWithCBC(c *C) {
{"", "1234567890123456", "1234567890123456", "1122334455667711223311223344556611", true},
}

for _, t := range tests {
cryptStr, _ := hex.DecodeString(t.hexCryptStr)
key := []byte(t.key)
iv := []byte(t.iv)
for _, tt := range tests {
cryptStr, _ := hex.DecodeString(tt.hexCryptStr)
key := []byte(tt.key)
iv := []byte(tt.iv)

result, err := AESDecryptWithCBC(cryptStr, key, iv)
if t.isError {
c.Assert(err, NotNil)
if tt.isError {
require.Error(t, err)
continue
}
c.Assert(err, IsNil)
c.Assert(string(result), Equals, t.expect)
require.NoError(t, err)
require.Equal(t, tt.expect, string(result))
}
}

Expand Down

0 comments on commit d74f715

Please sign in to comment.