Admin 쓰기 관문 강화 — 원장 · 지표 · 감사 기록과 서버 산출 필드 차단 · 마스터 전용 문서 · 거부 기록 · 권한 경계 시험

This commit is contained in:
Sn-Kinos
2026-09-26 20:46:41 +09:00
parent bb316c99e5
commit 65ba44a1d1
3 changed files with 161 additions and 7 deletions
+25
View File
@@ -0,0 +1,25 @@
import { initializeApp, deleteApp, getApps, type App } from 'firebase-admin/app';
import { getFirestore } from 'firebase-admin/firestore';
/**
* 에뮬레이터 전용 테스트 환경.
*
* `FIRESTORE_EMULATOR_HOST` 가 없으면 **실 프로젝트로 붙을 위험**이 있으므로
* 바로 실패시킨다. 테스트가 운영 데이터를 건드리는 사고는 한 번이면 치명적이다.
*/
export const PROJECT_ID = 'demo-fanuzu';
export function bootAdmin(): App {
if (!process.env.FIRESTORE_EMULATOR_HOST) {
throw new Error(
'FIRESTORE_EMULATOR_HOST 가 없습니다. `npm run test:emulator` 로 실행하십시오.',
);
}
const existing = getApps()[0];
if (existing) return existing;
return initializeApp({ projectId: PROJECT_ID });
}
export async function shutdownAdmin(): Promise<void> {
for (const app of getApps()) await deleteApp(app);
}