diff --git a/.golangci.yml b/.golangci.yml index f9da797..e59794c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -89,7 +89,7 @@ linters: - gocritic - gocognit - dupl - - goconst + - golint issues: max-ame-issues: 50 diff --git a/decoder_test.go b/decoder_test.go index 41c6cb5..e535ae3 100644 --- a/decoder_test.go +++ b/decoder_test.go @@ -152,7 +152,7 @@ func TestDecodeFile(t *testing.T) { // Test password matching pw := db.Content.Root.Groups[0].Groups[0].Entries[0].GetPassword() - if pw != "Password" { + if pw != password { t.Fatalf( "Failed to decode password: should be 'Password' not '%s'", pw, @@ -161,7 +161,7 @@ func TestDecodeFile(t *testing.T) { // Test secondary password matching pw = db.Content.Root.Groups[0].Groups[0].Entries[1].GetPassword() - if pw != "AnotherPassword" { + if pw != anotherPassword { t.Fatalf( "Failed to decode password: should be 'AnotherPassword' not '%s'", pw, diff --git a/encoder_test.go b/encoder_test.go index 9f85541..f935698 100644 --- a/encoder_test.go +++ b/encoder_test.go @@ -56,10 +56,7 @@ func TestEncodeFile31(t *testing.T) { 0xed, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, }, - "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + - "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + - "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + - "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC", + encodedIcon, }, } @@ -99,7 +96,7 @@ func TestEncodeFile31(t *testing.T) { // Test password matching pw := db.Content.Root.Groups[0].Groups[0].Entries[0].GetPassword() - if pw != "Password" { + if pw != password { t.Fatalf( "Failed to decode password: should be 'Password' not '%s'", pw, @@ -135,10 +132,7 @@ func TestEncodeFile31(t *testing.T) { 0xed, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, }, - "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + - "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + - "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + - "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC", + encodedIcon, }, ) { t.Fatal("Failed to properly store a custom icon in the Meta block") @@ -192,10 +186,7 @@ func TestEncodeFile4(t *testing.T) { 0xed, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, }, - "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + - "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + - "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + - "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC", + encodedIcon, }, } @@ -235,7 +226,7 @@ func TestEncodeFile4(t *testing.T) { // Test password matching pw := db.Content.Root.Groups[0].Groups[0].Entries[0].GetPassword() - if pw != "Password" { + if pw != password { t.Fatalf( "Failed to decode password: should be 'Password' not '%s'", pw, @@ -270,10 +261,7 @@ func TestEncodeFile4(t *testing.T) { 0xed, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, }, - "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + - "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + - "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + - "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC", + encodedIcon, }, ) { t.Fatal("Failed to properly store a custom icon in the Meta block") @@ -350,7 +338,7 @@ func TestEncodeFile4_NoCompression(t *testing.T) { // Test password matching pw := db.Content.Root.Groups[0].Groups[0].Entries[0].GetPassword() - if pw != "Password" { + if pw != password { t.Fatalf( "Failed to decode password: should be 'Password' not '%s'", pw, diff --git a/meta_data_test.go b/meta_data_test.go index 4f2a066..97683e2 100644 --- a/meta_data_test.go +++ b/meta_data_test.go @@ -52,10 +52,7 @@ func TestNewMetaData(t *testing.T) { 0xed, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, }, - "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + - "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + - "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + - "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC", + encodedIcon, }, { UUID{ @@ -64,10 +61,7 @@ func TestNewMetaData(t *testing.T) { 0xed, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, }, - "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + - "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + - "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + - "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC", + encodedIcon, }, } }, @@ -86,10 +80,7 @@ func TestNewMetaData(t *testing.T) { 0xed, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, }, - "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + - "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + - "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + - "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC", + encodedIcon2, }, { UUID{ @@ -98,10 +89,7 @@ func TestNewMetaData(t *testing.T) { 0xed, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, }, - "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + - "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + - "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + - "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC", + encodedIcon2, }, }, }, diff --git a/shared_for_test.go b/shared_for_test.go new file mode 100644 index 0000000..0e9c885 --- /dev/null +++ b/shared_for_test.go @@ -0,0 +1,15 @@ +package gokeepasslib + +const ( + password = "Password" + anotherPassword = "AnotherPassword" + + encodedIcon = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + + "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + + "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + + "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC" + encodedIcon2 = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" + + "rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" + + "gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" + + "QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC" +)