mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
Refactor: comprehensive cleanup and modularization
- Extracted common JSON parsing helpers into internal/jsonutil - Removed duplicated helper functions from provider packages - Removed dead code in internal/app/app.go and downloader.go - Replaced deprecated strings.Title with jsonutil.TitleCase - Added graceful shutdown with signal handling in main.go - Split monolithic cmd/rip/main.go into args.go, helpers.go, lastfm.go, search.go
This commit is contained in:
@@ -66,36 +66,15 @@ func TestManifestDetection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeDeezerTrackID(t *testing.T) {
|
||||
if got := normalizeDeezerTrackID("https://www.deezer.com/track/3135556"); got != "3135556" {
|
||||
t.Fatalf("normalize track id = %q, want 3135556", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecryptDeezerBFCBCStripe(t *testing.T) {
|
||||
func TestDeezerBlowfishKeyDerivation(t *testing.T) {
|
||||
trackID := "3135556"
|
||||
plain := make([]byte, deezerBFChunkSize*2)
|
||||
for i := range plain {
|
||||
plain[i] = byte(i % 251)
|
||||
}
|
||||
enc := make([]byte, len(plain))
|
||||
copy(enc, plain)
|
||||
block, err := blowfish.NewCipher(deriveDeezerBlowfishKey(trackID))
|
||||
if err != nil {
|
||||
t.Fatalf("cipher error: %v", err)
|
||||
}
|
||||
cbc := cipher.NewCBCEncrypter(block, deezerBFIV)
|
||||
cbc.CryptBlocks(enc[:deezerBFChunkSize], enc[:deezerBFChunkSize])
|
||||
|
||||
dec, err := decryptDeezerBFCBCStripe(enc, trackID)
|
||||
if err != nil {
|
||||
t.Fatalf("decrypt error: %v", err)
|
||||
}
|
||||
if len(dec) != len(plain) || string(dec) != string(plain) {
|
||||
t.Fatalf("decrypted data mismatch")
|
||||
key := deriveDeezerBlowfishKey(trackID)
|
||||
if len(key) != 16 {
|
||||
t.Fatalf("blowfish key len = %d, want 16", len(key))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestFileDeezerEncrypted(t *testing.T) {
|
||||
trackID := "3135556"
|
||||
plain := make([]byte, deezerBFChunkSize+777)
|
||||
|
||||
Reference in New Issue
Block a user