Adds mediaauth/mediacore/carriernodeclient/syncsocket packages under backend/, extracting everything genuinely cross-service (auth, shared media/tags/playlists/sync/profile routes, the CarrierNode HTTP client, the playback-sync websocket hub) out of the old media-backend monolith. The 7 media-family services (CarrierNode, ContentScanner, CraftStudio, MediaViewer, MediaKiosk, ModerationHub, ProjectConfigurator) each now have their own independent frontend and backend built on this library, instead of sharing one generic multi-flavor webui/media-backend selected by a MEDIA_SERVICE/VITE_MEDIA_APP flag. That generic app and binary (webui/, media-backend/) are now dead and removed here, along with their dedicated CI workflows. sync-consumers.ps1 and README.md updated to describe the new architecture. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
29 lines
866 B
Go
29 lines
866 B
Go
package mediaauth
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeCredentials(t *testing.T) {
|
|
email, username, password, err := normalizeCredentials(" User@Example.com ", "user", "correct horse battery staple")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if email != "user@example.com" || username != "user" || password == "" {
|
|
t.Fatalf("normalized credentials = %q, %q, %q", email, username, password)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeCredentialsAllowsAdminEmailOnly(t *testing.T) {
|
|
if _, _, _, err := normalizeCredentials("admin@example.com", "", "correct horse battery staple"); err != nil {
|
|
t.Fatalf("empty optional username rejected: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeRole(t *testing.T) {
|
|
if normalizeRole("MODERATOR") != "moderator" {
|
|
t.Fatal("moderator role was not normalized")
|
|
}
|
|
if normalizeRole("unknown") != "user" {
|
|
t.Fatal("unknown role was not reduced to user")
|
|
}
|
|
}
|