diff --git a/algo/qmc/cipher_map_test.go b/algo/qmc/cipher_map_test.go index f3a4b98..400ef94 100644 --- a/algo/qmc/cipher_map_test.go +++ b/algo/qmc/cipher_map_test.go @@ -1,40 +1,53 @@ package qmc import ( + "fmt" "os" "reflect" "testing" ) -func loadTestMapCipherData() ([]byte, []byte, []byte, error) { - key, err := os.ReadFile("./testdata/mflac_map_key.bin") +func loadTestDataMapCipher(name string) ([]byte, []byte, []byte, error) { + key, err := os.ReadFile(fmt.Sprintf("./testdata/%s_key.bin", name)) if err != nil { return nil, nil, nil, err } - raw, err := os.ReadFile("./testdata/mflac_map_raw.bin") + raw, err := os.ReadFile(fmt.Sprintf("./testdata/%s_raw.bin", name)) if err != nil { return nil, nil, nil, err } - target, err := os.ReadFile("./testdata/mflac_map_target.bin") + target, err := os.ReadFile(fmt.Sprintf("./testdata/%s_target.bin", name)) if err != nil { return nil, nil, nil, err } return key, raw, target, nil } func Test_mapCipher_Decrypt(t *testing.T) { - key, raw, target, err := loadTestMapCipherData() - if err != nil { - t.Fatalf("load testing data failed: %s", err) + + tests := []struct { + name string + wantErr bool + }{ + {"mflac_map", false}, + {"mgg_map", false}, + } + + for _, tt := range tests { + + t.Run(tt.name, func(t *testing.T) { + key, raw, target, err := loadTestDataMapCipher(tt.name) + if err != nil { + t.Fatalf("load testing data failed: %s", err) + } + c, err := NewMapCipher(key) + if err != nil { + t.Errorf("init mapCipher failed: %s", err) + return + } + c.Decrypt(raw, 0) + if !reflect.DeepEqual(raw, target) { + t.Error("overall") + } + }) } - t.Run("overall", func(t *testing.T) { - c, err := NewMapCipher(key) - if err != nil { - t.Errorf("init mapCipher failed: %s", err) - return - } - c.Decrypt(raw, 0) - if !reflect.DeepEqual(raw, target) { - t.Error("overall") - } - }) } diff --git a/algo/qmc/qmc_test.go b/algo/qmc/qmc_test.go index f8fd0bf..6209b15 100644 --- a/algo/qmc/qmc_test.go +++ b/algo/qmc/qmc_test.go @@ -33,6 +33,7 @@ func TestMflac0Decoder_Read(t *testing.T) { }{ {"mflac0_rc4", false}, {"mflac_map", false}, + {"mgg_map", false}, {"qmc0_static", false}, } @@ -69,6 +70,7 @@ func TestMflac0Decoder_Validate(t *testing.T) { }{ {"mflac0_rc4", ".flac", false}, {"mflac_map", ".flac", false}, + {"mgg_map", ".ogg", false}, {"qmc0_static", ".mp3", false}, } diff --git a/algo/qmc/testdata/mgg_map_key.bin b/algo/qmc/testdata/mgg_map_key.bin new file mode 100644 index 0000000..fecf089 --- /dev/null +++ b/algo/qmc/testdata/mgg_map_key.bin @@ -0,0 +1 @@ +zGxNk54pKJ0hDkAo80wHE80ycSWQ7z4m4E846zVy2sqCn14F42Y5S7GqeR11WpOV75sDLbE5dFP992t88l0pHy1yAQ49YK6YX6c543drBYLo55Hc4Y0Fyic6LQPiGqu2bG31r8vaq9wS9v63kg0X5VbnOD6RhO4t0RRhk3ajrA7p0iIy027z0L70LZjtw6E18H0D41nz6ASTx71otdF9z1QNC0JmCl51xvnb39zPExEXyKkV47S6QsK5hFh884QJ \ No newline at end of file diff --git a/algo/qmc/testdata/mgg_map_key_raw.bin b/algo/qmc/testdata/mgg_map_key_raw.bin new file mode 100644 index 0000000..bea6675 --- /dev/null +++ b/algo/qmc/testdata/mgg_map_key_raw.bin @@ -0,0 +1 @@ +ekd4Tms1NHC53JEDO/AKVyF+I0bj0hHB7CZeoLDGSApaQB9Oo/pJTBGA/RO+nk5RXLXdHsffLiY4e8kt3LNo6qMl7S89vkiSFxx4Uoq4bGDJ7Jc+bYL6lLsa3M4sBvXS4XcPChrMDz+LmrJMGG6ua2fYyIz1d6TCRUBf1JJgCIkBbDAEeMVYc13qApitiz/apGAPmAnveCaDhfD5GxWsF+RfQ2OcnvrnIXe80Feh/0jx763DlsOBI3eIede6t5zYHokWkZmVEF1jMrnlvsgbQK2EzUWMblmLMsTKNILyZazEoKUyulqmyLO/c/KYE+USPOXPcbjlYFmLhSGHK7sQB5aBR153Yp+xh61ooh2NGAA= \ No newline at end of file diff --git a/algo/qmc/testdata/mgg_map_raw.bin b/algo/qmc/testdata/mgg_map_raw.bin new file mode 100644 index 0000000..fa8704d Binary files /dev/null and b/algo/qmc/testdata/mgg_map_raw.bin differ diff --git a/algo/qmc/testdata/mgg_map_suffix.bin b/algo/qmc/testdata/mgg_map_suffix.bin new file mode 100644 index 0000000..671d61e Binary files /dev/null and b/algo/qmc/testdata/mgg_map_suffix.bin differ diff --git a/algo/qmc/testdata/mgg_map_target.bin b/algo/qmc/testdata/mgg_map_target.bin new file mode 100644 index 0000000..f318eb9 Binary files /dev/null and b/algo/qmc/testdata/mgg_map_target.bin differ