MCPcopy
hub / github.com/rclone/rclone / TestDecryptSegmentBase64

Function TestDecryptSegmentBase64

backend/crypt/cipher_test.go:297–319  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

295}
296
297func TestDecryptSegmentBase64(t *testing.T) {
298 // We've tested the forwards above, now concentrate on the errors
299 longName := make([]byte, 2816)
300 for i := range longName {
301 longName[i] = 'a'
302 }
303 enc, _ := NewNameEncoding("base64")
304 c, _ := newCipher(NameEncryptionStandard, "", "", true, enc)
305 for _, test := range []struct {
306 in string
307 expectedErr error
308 }{
309 {"6H=", base64.CorruptInputError(2)},
310 {"!", base64.CorruptInputError(0)},
311 {string(longName), ErrorTooLongAfterDecode},
312 {enc.EncodeToString([]byte("a")), ErrorNotAMultipleOfBlocksize},
313 {enc.EncodeToString([]byte("123456789abcdef")), ErrorNotAMultipleOfBlocksize},
314 {enc.EncodeToString([]byte("123456789abcdef0")), pkcs7.ErrorPaddingTooLong},
315 } {
316 actual, actualErr := c.decryptSegment(test.in)
317 assert.Equal(t, test.expectedErr, actualErr, fmt.Sprintf("in=%q got actual=%q, err = %v %T", test.in, actual, actualErr, actualErr))
318 }
319}
320
321func TestDecryptSegmentBase32768(t *testing.T) {
322 // We've tested the forwards above, now concentrate on the errors

Callers

nothing calls this directly

Calls 5

NewNameEncodingFunction · 0.85
newCipherFunction · 0.85
decryptSegmentMethod · 0.80
EncodeToStringMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…