Skip to content

Commit

Permalink
util/encrypt: migrate TestAESEncryptWithOFB 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 71eb265 commit 0cd802a
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 @@ -298,8 +298,7 @@ func TestAESEncryptWithCBC(t *testing.T) {
}
}

func (s *testEncryptSuite) TestAESEncryptWithOFB(c *C) {
defer testleak.AfterTest(c)()
func TestAESEncryptWithOFB(t *testing.T) {
tests := []struct {
str string
key string
Expand All @@ -317,19 +316,19 @@ func (s *testEncryptSuite) TestAESEncryptWithOFB(c *C) {
{"pingcap", "123456789012345", "1234567890123456", "", true},
}

for _, t := range tests {
str := []byte(t.str)
key := []byte(t.key)
iv := []byte(t.iv)
for _, tt := range tests {
str := []byte(tt.str)
key := []byte(tt.key)
iv := []byte(tt.iv)

crypted, err := AESEncryptWithOFB(str, key, iv)
if t.isError {
c.Assert(err, NotNil, Commentf("%v", t))
if tt.isError {
require.Errorf(t, err, "%v", tt)
continue
}
c.Assert(err, IsNil, Commentf("%v", t))
require.NoErrorf(t, err, "%v", tt)
result := toHex(crypted)
c.Assert(result, Equals, t.expect, Commentf("%v", t))
require.Equalf(t, tt.expect, result, "%v", tt)
}
}

Expand Down

0 comments on commit 0cd802a

Please sign in to comment.