1import { runTestsWithProgress, createTestCollector } from '../../deployF/testsF/runTestsHelperAI.mts'2import { addCommonHardeningTests } from './commonHardeningTestsAI.mts'3import { getKlusterCtx } from '../../deployF/k8sF/ctxF/klusterCtxF.mts'4import { eptKubeCli, noOutCmdCtx } from '../../deployF/k8sF/cliF/eptKubeCliF.mts'5import { ptenvTestprod, type Ptenv } from '../../sharedF/ptenvF.mts'7export const runHardeningTests = async ({baseUrl, singleTestName, ptenv}: {baseUrl: string, singleTestName?: string, ptenv?: Ptenv}) => {8 const {tests, test} = createTestCollector()9 addCommonHardeningTests(test, baseUrl)11 test('stickySessionAnnotation', async () => {12 if (ptenv !== ptenvTestprod) return {passed: true, msg: 'skipped (testlocal)'}13 const {cluster_name, name} = getKlusterCtx()14 const result = await (noOutCmdCtx as any).run(true, () => 15 eptKubeCli([cluster_name, 'get', 'ingress', name, '-o', 'jsonpath={.metadata.annotations.nginx\\.ingress\\.kubernetes\\.io/upstream-hash-by}'])16 )17 const annotation = result?.stdout?.trim()18 if (annotation) {19 return {passed: true, msg: annotation}20 }21 return {passed: false, msg: 'missing upstream-hash-by annotation for multi-pod routing'}22 })24 return runTestsWithProgress({tests, suiteName: 'hardening', singleTestName})25}