Expose Last.fm's ApiKey to UI

This commit is contained in:
Deluan
2021-06-21 17:09:34 -04:00
committed by Deluan Quintão
parent 143cde37e5
commit 1f997357a9
8 changed files with 30 additions and 22 deletions
+1
View File
@@ -45,6 +45,7 @@ func serveIndex(ds model.DataStore, fs fs.FS) http.HandlerFunc {
"enableUserEditing": conf.Server.EnableUserEditing,
"devEnableShare": conf.Server.DevEnableShare,
"devEnableScrobble": conf.Server.DevEnableScrobble,
"lastFMApiKey": conf.Server.LastFM.ApiKey,
}
auth := handleLoginFromHeaders(ds, r)
if auth != nil {
+11
View File
@@ -209,6 +209,17 @@ var _ = Describe("serveIndex", func() {
config := extractAppConfig(w.Body.String())
Expect(config).To(HaveKeyWithValue("devEnableScrobble", false))
})
It("sets the lastFMApiKey", func() {
conf.Server.LastFM.ApiKey = "APIKEY-123"
r := httptest.NewRequest("GET", "/index.html", nil)
w := httptest.NewRecorder()
serveIndex(ds, fs)(w, r)
config := extractAppConfig(w.Body.String())
Expect(config).To(HaveKeyWithValue("lastFMApiKey", "APIKEY-123"))
})
})
var appConfigRegex = regexp.MustCompile(`(?m)window.__APP_CONFIG__="([^"]*)`)