test(coverart, subsonic, server): merge repeated cases into tables (#8298)
release / web (push) Successful in 1m35s
release / go (push) Successful in 1m58s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 3m0s
release / android (push) Successful in 4m26s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Publish the release image to GHCR (dispatch only) (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 5m8s
release / web (push) Successful in 1m35s
release / go (push) Successful in 1m58s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 3m0s
release / android (push) Successful in 4m26s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Publish the release image to GHCR (dispatch only) (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 5m8s
- coverart: the four providers' identity and default tests, Last.fm's five not-found-without-asking tests, the four "which artists are asked again" database tests (now one reset over four artists), and the thumbnail-only and fanart-only tests. - subsonic: getUser's six tests and decodePassword's three, one table each. Dropped TestTokenMD5Derivation: it checked crypto/md5 against a constant and called no Minstrel code. - server: the four web-app-versus-API path tests start one server, not four. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,44 +1,21 @@
|
||||
package subsonic
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
func TestDecodePasswordEnc(t *testing.T) {
|
||||
out, err := decodePassword("enc:68656c6c6f")
|
||||
if err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
if out != "hello" {
|
||||
t.Errorf("decode = %q, want hello", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodePasswordPlain(t *testing.T) {
|
||||
out, err := decodePassword("hunter2")
|
||||
if err != nil || out != "hunter2" {
|
||||
t.Errorf("plain passthrough = %q, %v", out, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodePasswordBadHex(t *testing.T) {
|
||||
if _, err := decodePassword("enc:zzzz"); err == nil {
|
||||
t.Error("expected error for malformed enc: prefix")
|
||||
}
|
||||
}
|
||||
|
||||
// TestTokenMD5Derivation documents the t = md5(password + salt) construction
|
||||
// so regressions in the auth path surface as a failing checksum rather than a
|
||||
// 40/wrong-credentials response that could be mistaken for bad inputs.
|
||||
func TestTokenMD5Derivation(t *testing.T) {
|
||||
password := "hunter2"
|
||||
salt := "NaClz"
|
||||
sum := md5.Sum([]byte(password + salt))
|
||||
want := hex.EncodeToString(sum[:])
|
||||
const expected = "91b894c3c9af9c16bec1b3f771e31462"
|
||||
if want != expected {
|
||||
t.Errorf("md5(password+salt) = %s, want %s", want, expected)
|
||||
// A Subsonic app sends its password as plain text or hex-encoded behind
|
||||
// "enc:"; malformed hex is an error rather than a wrong password.
|
||||
func TestDecodePassword(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
in, want string
|
||||
err bool
|
||||
}{
|
||||
{"enc:68656c6c6f", "hello", false},
|
||||
{"hunter2", "hunter2", false},
|
||||
{"enc:zzzz", "", true},
|
||||
} {
|
||||
out, err := decodePassword(tc.in)
|
||||
if (err != nil) != tc.err || (!tc.err && out != tc.want) {
|
||||
t.Errorf("decodePassword(%q) = %q, %v; want %q (error %v)", tc.in, out, err, tc.want, tc.err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user