feat(platform): expose amap server readiness
This commit is contained in:
@@ -52,12 +52,13 @@ func NewServer(cfg config.Config) http.Handler {
|
||||
}
|
||||
}
|
||||
api := platform.NewHandler(platform.NewServiceWithRuntime(store, platform.RuntimeInfo{
|
||||
RequestTimeoutMs: int(cfg.RequestTimeout / time.Millisecond),
|
||||
AMapWebJSConfigured: strings.TrimSpace(cfg.AMapWebJSKey) != "",
|
||||
AMapSecurityProxyEnabled: strings.TrimSpace(cfg.AMapSecurityCode) != "" && strings.TrimSpace(cfg.AMapServiceHost) != "",
|
||||
AMapSecurityCodeExposed: exposedAMapSecurityCode(cfg) != "",
|
||||
AMapSecurityServiceHost: strings.TrimSpace(cfg.AMapServiceHost),
|
||||
PlatformRelease: strings.TrimSpace(cfg.PlatformRelease),
|
||||
RequestTimeoutMs: int(cfg.RequestTimeout / time.Millisecond),
|
||||
AMapWebJSConfigured: strings.TrimSpace(cfg.AMapWebJSKey) != "",
|
||||
AMapAPIConfigured: strings.TrimSpace(cfg.AMapAPIKey) != "",
|
||||
AMapSecurityProxyEnabled: strings.TrimSpace(cfg.AMapSecurityCode) != "" && strings.TrimSpace(cfg.AMapServiceHost) != "",
|
||||
AMapSecurityCodeExposed: exposedAMapSecurityCode(cfg) != "",
|
||||
AMapSecurityServiceHost: strings.TrimSpace(cfg.AMapServiceHost),
|
||||
PlatformRelease: strings.TrimSpace(cfg.PlatformRelease),
|
||||
}))
|
||||
handler := static.Handler(cfg.StaticDir, api)
|
||||
handler = withAppConfig(handler, cfg)
|
||||
|
||||
@@ -62,6 +62,7 @@ func TestWithRequestTimeoutReturnsEnvelopeWithTraceID(t *testing.T) {
|
||||
func TestAppConfigScriptIsRuntimeRendered(t *testing.T) {
|
||||
handler := withAppConfig(http.NotFoundHandler(), config.Config{
|
||||
AMapWebJSKey: "web-key",
|
||||
AMapAPIKey: "server-api-key",
|
||||
AMapSecurityCode: "security-code",
|
||||
AMapServiceHost: "/_AMapService",
|
||||
})
|
||||
@@ -82,8 +83,8 @@ func TestAppConfigScriptIsRuntimeRendered(t *testing.T) {
|
||||
t.Fatalf("app config script missing %q: %s", want, body)
|
||||
}
|
||||
}
|
||||
if strings.Contains(body, "security-code") || strings.Contains(body, "amapSecurityJsCode") {
|
||||
t.Fatalf("app config script should not expose AMap security code: %s", body)
|
||||
if strings.Contains(body, "security-code") || strings.Contains(body, "server-api-key") || strings.Contains(body, "amapSecurityJsCode") || strings.Contains(body, "amapApiKey") {
|
||||
t.Fatalf("app config script should not expose server-side AMap secrets: %s", body)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user