mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +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,
|
||||
ModifiedS: 1234567890, // Sat Feb 14 00:31:30 CET 2009
|
||||
Deleted: fi.Deleted,
|
||||
RawInvalid: fi.IsInvalid(),
|
||||
Version: version,
|
||||
Sequence: fi.Sequence,
|
||||
RawBlockSize: fi.RawBlockSize + blockOverhead,
|
||||
|
@ -113,9 +113,8 @@ func TestEnDecryptBytes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnDecryptFileInfo(t *testing.T) {
|
||||
var key [32]byte
|
||||
fi := FileInfo{
|
||||
func encFileInfo() FileInfo {
|
||||
return FileInfo{
|
||||
Name: "hello",
|
||||
Size: 45,
|
||||
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)
|
||||
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) {
|
||||
comp := rand.String(maxPathComponent)
|
||||
cases := []struct {
|
||||
|
Loading…
Reference in New Issue
Block a user