From 95584f922331b3ba7e4ca81cecf974d029c9261e Mon Sep 17 00:00:00 2001 From: William Phetsinorath Date: Wed, 9 Sep 2026 14:32:31 +0200 Subject: [PATCH] fix(server-nestjs): make the gitlab mirror rotation test deterministic The rotation test seeded the vault secret with faker.date.past({ years: 2 }), a uniform draw over [0; 730] days. With the default 250-day rotation threshold, roughly one draw in three lands inside the threshold window: the rotation branch never fires, revokeProjectToken ends up with zero calls and the assertion fails. This is the intermittent unit-tests job failure seen on recent PRs. Draw the secret age with faker.date.birthdate({ min: 1, max: 2, mode: 'age' }): the value stays fully randomized and relative to now, but the draw always lands one to two years in the past, safely beyond the rotation threshold, so the rotation branch is exercised deterministically. Refs #2706 Co-authored-by: Automata Signed-off-by: William Phetsinorath Change-Id: I00684d9367006f164ab2d86d642544336a6a6964 --- apps/server-nestjs/src/modules/gitlab/gitlab.service.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/server-nestjs/src/modules/gitlab/gitlab.service.spec.ts b/apps/server-nestjs/src/modules/gitlab/gitlab.service.spec.ts index 33b81f4f48..860c72e50e 100644 --- a/apps/server-nestjs/src/modules/gitlab/gitlab.service.spec.ts +++ b/apps/server-nestjs/src/modules/gitlab/gitlab.service.spec.ts @@ -589,7 +589,10 @@ describe('gitlabService', () => { const staleSecret = makeVaultSecret({ data: { MIRROR_USER: accessToken.name, MIRROR_TOKEN: accessToken.token }, metadata: { - created_time: faker.date.past({ years: 2 }).toISOString(), + // faker.date.past() alone can draw inside the 250-day rotation + // threshold and silently skip the rotation branch; a birthdate draw + // aged 1–2 years always lands past it. + created_time: faker.date.birthdate({ min: 1, max: 2, mode: 'age' }).toISOString(), custom_metadata: null, deletion_time: '', destroyed: false,