Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

Add tests for reveal functions

Andres Alvarezc1f5add049f9
diff --git a/fs/config/obscure/obscure_test.go b/fs/config/obscure/obscure_test.go
index a2d465cde..ff9dedb04 100644
--- a/fs/config/obscure/obscure_test.go
+++ b/fs/config/obscure/obscure_test.go
@@ -36,3 +36,25 @@ func TestObscure(t *testing.T) {
}
}
+
+func TestReveal(t *testing.T) {
+ for _, test := range []struct {
+ in string
+ want string
+ iv string
+ }{
+ {"YWFhYWFhYWFhYWFhYWFhYQ", "", "aaaaaaaaaaaaaaaa"},
+ {"YWFhYWFhYWFhYWFhYWFhYXMaGgIlEQ", "potato", "aaaaaaaaaaaaaaaa"},
+ {"YmJiYmJiYmJiYmJiYmJiYp3gcEWbAw", "potato", "bbbbbbbbbbbbbbbb"},
+ } {
+ cryptRand = bytes.NewBufferString(test.iv)
+ got, err := Reveal(test.in)
+ assert.NoError(t, err)
+ assert.Equal(t, test.want, got)
+ // Now the Must variants
+ cryptRand = bytes.NewBufferString(test.iv)
+ got = MustReveal(test.in)
+ assert.Equal(t, test.want, got)
+
+ }
+}