修复恢复页静态资源嵌入
This commit is contained in:
parent
fb78b0c762
commit
eff9e79da3
@ -28,7 +28,7 @@ import (
|
||||
olog "log"
|
||||
)
|
||||
|
||||
//go:embed dist/*
|
||||
//go:embed all:dist/*
|
||||
var local embed.FS
|
||||
|
||||
var httpsServer *http.Server
|
||||
|
||||
@ -2,6 +2,7 @@ package http_server
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
@ -63,6 +64,33 @@ func TestPublicRecoveryPageIsServedOnlyFromMailDomain(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicRecoveryServesUnderscorePrefixedBuildAssets(t *testing.T) {
|
||||
configurePublicRecoveryRouteTest(t)
|
||||
handler, err := newPublicRecoveryHandler()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
recoveryHandler, ok := handler.(*publicRecoveryHandler)
|
||||
if !ok {
|
||||
t.Fatalf("unexpected public recovery handler type %T", handler)
|
||||
}
|
||||
|
||||
matches, err := fs.Glob(recoveryHandler.frontend, "assets/_plugin-vue_export-helper-*.js")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(matches) == 0 {
|
||||
t.Fatal("embedded frontend does not contain the Vue export helper asset")
|
||||
}
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
request := publicRecoveryRequest(http.MethodGet, "https://mx.example.com/"+matches[0])
|
||||
handler.ServeHTTP(recorder, request)
|
||||
if recorder.Code != http.StatusOK {
|
||||
t.Fatalf("underscore-prefixed asset returned %d, want %d", recorder.Code, http.StatusOK)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicRecoveryPageRequiresConfiguredHTTPSPort(t *testing.T) {
|
||||
configurePublicRecoveryRouteTest(t)
|
||||
config.Instance.HttpsPort = 8443
|
||||
|
||||
Loading…
Reference in New Issue
Block a user