forked from baron/baron-sso
조직도 M2M조회 추가, 자동로그인 보완
This commit is contained in:
@@ -117,15 +117,15 @@ func TestNewErrorHandler_MapsUnauthorizedCode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldEnableDocs_DisabledInProductionLikeEnv(t *testing.T) {
|
||||
func TestShouldEnableDocs_DisabledOnlyInProduction(t *testing.T) {
|
||||
testCases := []struct {
|
||||
appEnv string
|
||||
want bool
|
||||
}{
|
||||
{appEnv: "production", want: false},
|
||||
{appEnv: "prod", want: false},
|
||||
{appEnv: "stage", want: false},
|
||||
{appEnv: "staging", want: false},
|
||||
{appEnv: "stage", want: true},
|
||||
{appEnv: "staging", want: true},
|
||||
{appEnv: "dev", want: true},
|
||||
{appEnv: "development", want: true},
|
||||
}
|
||||
|
||||
@@ -80,7 +80,8 @@ func normalizeDocsPrefix(prefix string) string {
|
||||
}
|
||||
|
||||
func shouldEnableDocs(appEnv string) bool {
|
||||
return !logger.IsProductionLikeEnv(appEnv)
|
||||
env := strings.ToLower(strings.TrimSpace(appEnv))
|
||||
return env != "prod" && env != "production"
|
||||
}
|
||||
|
||||
func registerDocsRoutes(app *fiber.App, prefix string) {
|
||||
@@ -622,6 +623,10 @@ func main() {
|
||||
api.Post("/tenants/registration", tenantHandler.RegisterTenantPublic)
|
||||
api.Get("/admin/worksmobile/oauth/callback", worksmobileHandler.OAuthCallback)
|
||||
|
||||
integrationsAPI := api.Group("/integrations")
|
||||
integrationsAPI.Use(middleware.ApiKeyAuth(middleware.ApiKeyAuthConfig{DB: db}))
|
||||
integrationsAPI.Get("/org-context", tenantHandler.GetOrgContext)
|
||||
|
||||
// Tenant Context Middleware (identifies tenant from Host header)
|
||||
api.Use(middleware.TenantContextMiddleware(middleware.TenantContextConfig{
|
||||
TenantService: tenantService,
|
||||
|
||||
39
backend/cmd/server/openapi_static_test.go
Normal file
39
backend/cmd/server/openapi_static_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestOpenAPIDocumentsExternalAPIs(t *testing.T) {
|
||||
data, err := os.ReadFile("../../docs/openapi.yaml")
|
||||
require.NoError(t, err)
|
||||
spec := string(data)
|
||||
var parsed map[string]any
|
||||
require.NoError(t, yaml.Unmarshal(data, &parsed))
|
||||
|
||||
required := []string{
|
||||
"/.well-known/baron-rp-manifest.json:",
|
||||
"/.well-known/baron-rp-manifest.schema.json:",
|
||||
"/api/v1/public/orgchart:",
|
||||
"/api/v1/tenants/registration:",
|
||||
"/api/v1/integrations/org-context:",
|
||||
"/api/v1/admin/api-keys:",
|
||||
"/api/v1/admin/api-keys/{id}:",
|
||||
"BaronApiKeyId:",
|
||||
"BaronApiKeySecret:",
|
||||
"X-Baron-Key-ID",
|
||||
"X-Baron-Key-Secret",
|
||||
"API Key 인증이 필요한 요청의 header에 자동으로 포함됩니다.",
|
||||
"OrgContextResponse:",
|
||||
}
|
||||
for _, expected := range required {
|
||||
require.Contains(t, spec, expected)
|
||||
}
|
||||
|
||||
require.False(t, strings.Contains(spec, "/api/v1/orgfront/org-context:"))
|
||||
}
|
||||
Reference in New Issue
Block a user