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}:",
		"/api/v1/admin/api-keys/{id}/secret/rotate:",
		"ApiKeyUpdateScopesRequest:",
		"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:"))
}
