mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
This commit is contained in:
parent
a12ede3bbe
commit
f80ee472c2
@ -314,6 +314,7 @@ func encryptFileInfo(fi FileInfo, folderKey *[keySize]byte) FileInfo {
|
|||||||
Permissions: 0644,
|
Permissions: 0644,
|
||||||
ModifiedS: 1234567890, // Sat Feb 14 00:31:30 CET 2009
|
ModifiedS: 1234567890, // Sat Feb 14 00:31:30 CET 2009
|
||||||
Deleted: fi.Deleted,
|
Deleted: fi.Deleted,
|
||||||
|
RawInvalid: fi.IsInvalid(),
|
||||||
Version: version,
|
Version: version,
|
||||||
Sequence: fi.Sequence,
|
Sequence: fi.Sequence,
|
||||||
RawBlockSize: fi.RawBlockSize + blockOverhead,
|
RawBlockSize: fi.RawBlockSize + blockOverhead,
|
||||||
|
@ -113,9 +113,8 @@ func TestEnDecryptBytes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnDecryptFileInfo(t *testing.T) {
|
func encFileInfo() FileInfo {
|
||||||
var key [32]byte
|
return FileInfo{
|
||||||
fi := FileInfo{
|
|
||||||
Name: "hello",
|
Name: "hello",
|
||||||
Size: 45,
|
Size: 45,
|
||||||
Permissions: 0755,
|
Permissions: 0755,
|
||||||
@ -133,6 +132,11 @@ func TestEnDecryptFileInfo(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEnDecryptFileInfo(t *testing.T) {
|
||||||
|
var key [32]byte
|
||||||
|
fi := encFileInfo()
|
||||||
|
|
||||||
enc := encryptFileInfo(fi, &key)
|
enc := encryptFileInfo(fi, &key)
|
||||||
if bytes.Equal(enc.Blocks[0].Hash, enc.Blocks[1].Hash) {
|
if bytes.Equal(enc.Blocks[0].Hash, enc.Blocks[1].Hash) {
|
||||||
@ -155,6 +159,21 @@ func TestEnDecryptFileInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEncryptedFileInfoConsistency(t *testing.T) {
|
||||||
|
var key [32]byte
|
||||||
|
files := []FileInfo{
|
||||||
|
encFileInfo(),
|
||||||
|
encFileInfo(),
|
||||||
|
}
|
||||||
|
files[1].SetIgnored()
|
||||||
|
for i, f := range files {
|
||||||
|
enc := encryptFileInfo(f, &key)
|
||||||
|
if err := checkFileInfoConsistency(enc); err != nil {
|
||||||
|
t.Errorf("%v: %v", i, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestIsEncryptedParent(t *testing.T) {
|
func TestIsEncryptedParent(t *testing.T) {
|
||||||
comp := rand.String(maxPathComponent)
|
comp := rand.String(maxPathComponent)
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user