Skip to content

Commit

Permalink
Move twofish example to test files
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischo committed Apr 19, 2024
1 parent c50c154 commit 299869c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
22 changes: 22 additions & 0 deletions decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ func TestDecodeFile(t *testing.T) {
title string
dbFilePath string
newCredentials func() (*DBCredentials, error)
testContent bool
}{
{
title: "Database Format v3.1, password credentials",
dbFilePath: "tests/kdbx3/example.kdbx",
newCredentials: func() (*DBCredentials, error) {
return NewPasswordCredentials("abcdefg12345678"), nil
},
testContent: true,
},
{
title: "Database Format v3.1, password+key credentials",
Expand All @@ -28,6 +30,7 @@ func TestDecodeFile(t *testing.T) {
"tests/kdbx3/example-key.key",
)
},
testContent: true,
},
{
title: "Database Format v3.1, password+keydata credentials",
Expand All @@ -48,13 +51,15 @@ func TestDecodeFile(t *testing.T) {
keyData,
)
},
testContent: true,
},
{
title: "Database Format v4, password credentials",
dbFilePath: "tests/kdbx4/example.kdbx",
newCredentials: func() (*DBCredentials, error) {
return NewPasswordCredentials("abcdefg12345678"), nil
},
testContent: true,
},
{
title: "Database Format v4, password+key credentials",
Expand All @@ -65,6 +70,7 @@ func TestDecodeFile(t *testing.T) {
"tests/kdbx4/example-key.key",
)
},
testContent: true,
},
{
title: "Database Format v4, password+keydata credentials",
Expand All @@ -85,20 +91,23 @@ func TestDecodeFile(t *testing.T) {
keyData,
)
},
testContent: true,
},
{
title: "Database Format v4, without compression, password credentials",
dbFilePath: "tests/kdbx4/example-nocompression.kdbx",
newCredentials: func() (*DBCredentials, error) {
return NewPasswordCredentials("abcdefg12345678"), nil
},
testContent: true,
},
{
title: "Database Format v4, chacha encryption, password credentials",
dbFilePath: "tests/kdbx4/example-chacha.kdbx",
newCredentials: func() (*DBCredentials, error) {
return NewPasswordCredentials("abcdefg12345678"), nil
},
testContent: true,
},
{
title: "Database Format v4, chacha encryption, " +
Expand All @@ -107,6 +116,15 @@ func TestDecodeFile(t *testing.T) {
newCredentials: func() (*DBCredentials, error) {
return NewPasswordCredentials("abcdefg12345678"), nil
},
testContent: true,
},
{
title: "Database Format v4, twofish encryption, password credentials",
dbFilePath: "tests/kdbx4/example-twofish.kdbx",
newCredentials: func() (*DBCredentials, error) {
return NewPasswordCredentials("test1234test"), nil
},
testContent: false,
},
}

Expand All @@ -131,6 +149,10 @@ func TestDecodeFile(t *testing.T) {
t.Fatalf("Failed to decode file: %s", err)
}

if !c.testContent {
return
}

// Test binary file matching
binary := db.FindBinary(db.Content.Root.Groups[0].Groups[1].Entries[0].Binaries[0].Value.ID)
if binary == nil {
Expand Down
29 changes: 0 additions & 29 deletions examples/twofish/example.go

This file was deleted.

File renamed without changes.

0 comments on commit 299869c

Please sign in to comment.