MCPcopy
hub / github.com/rclone/rclone / testStandardDecryptFileName

Function testStandardDecryptFileName

backend/crypt/cipher_test.go:430–458  ·  view source on GitHub ↗
(t *testing.T, encoding string, testCases []EncodingTestCase, caseInsensitive bool)

Source from the content-addressed store, hash-verified

428}
429
430func testStandardDecryptFileName(t *testing.T, encoding string, testCases []EncodingTestCase, caseInsensitive bool) {
431 enc, _ := NewNameEncoding(encoding)
432 for _, test := range testCases {
433 // Test when dirNameEncrypt=true
434 c, _ := newCipher(NameEncryptionStandard, "", "", true, enc)
435 actual, actualErr := c.DecryptFileName(test.in)
436 assert.NoError(t, actualErr)
437 assert.Equal(t, test.expected, actual)
438 if caseInsensitive {
439 c, _ := newCipher(NameEncryptionStandard, "", "", true, enc)
440 actual, actualErr := c.DecryptFileName(strings.ToUpper(test.in))
441 assert.NoError(t, actualErr)
442 assert.Equal(t, test.expected, actual)
443 }
444 // Add a character should raise ErrorNotAMultipleOfBlocksize
445 actual, actualErr = c.DecryptFileName(enc.EncodeToString([]byte("1")) + test.in)
446 assert.Equal(t, ErrorNotAMultipleOfBlocksize, actualErr)
447 assert.Equal(t, "", actual)
448 // Test when dirNameEncrypt=false
449 noDirEncryptIn := test.in
450 if strings.LastIndex(test.expected, "/") != -1 {
451 noDirEncryptIn = test.expected[:strings.LastIndex(test.expected, "/")] + test.in[strings.LastIndex(test.in, "/"):]
452 }
453 c, _ = newCipher(NameEncryptionStandard, "", "", false, enc)
454 actual, actualErr = c.DecryptFileName(noDirEncryptIn)
455 assert.NoError(t, actualErr)
456 assert.Equal(t, test.expected, actual)
457 }
458}
459
460func TestStandardDecryptFileNameBase32(t *testing.T) {
461 testStandardDecryptFileName(t, "base32", []EncodingTestCase{

Calls 5

NewNameEncodingFunction · 0.85
newCipherFunction · 0.85
EncodeToStringMethod · 0.65
DecryptFileNameMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…