Skip to content

test(server-nestjs): cas limites du client Vault (mapping d'erreurs, approle, secrets) - #2585

Draft
shikanime wants to merge 2 commits into
mainfrom
test/adv-vault
Draft

test(server-nestjs): cas limites du client Vault (mapping d'erreurs, approle, secrets)#2585
shikanime wants to merge 2 commits into
mainfrom
test/adv-vault

Conversation

@shikanime

Copy link
Copy Markdown
Member

Issues liées

#2574


Quel est le comportement actuel ?

vault-client.service.ts était à ~35% de lignes couvertes : le mapping des statuts HTTP vers VaultError, les cas limites approle et la liste récursive des secrets de projet n'étaient pas verrouillés.

Quel est le nouveau comportement ?

+523 lignes / +40 tests :

  • mapping VaultError (NotFound/HttpError/InvalidResponse) sur 400/403/404/409/500/503 et corps malformés ;
  • formes limite approle/token (policies vides, wrapper data absent) ;
  • fallback tune-400, suppression partielle en batch ;
  • parcours récursif depth-first des secrets projet (contrat d'ordre verrouillé).

Comportement actuel verrouillé ; 59/59 tests verts sur Node 24.

Cette PR introduit-elle un breaking change ?

Non.

Co-authored-by: Automata <automata@shikanime.studio>
@github-actions github-actions Bot added the built label Aug 25, 2026
@shikanime shikanime changed the title test(server-nestjs): couverture adversariale du client Vault (mapping d'erreurs, approle, secrets) test(server-nestjs): cas limites du client Vault (mapping d'erreurs, approle, secrets) Aug 26, 2026
…al delete

Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I56e495e65be7a940ef89bcb60863b7a56a6a6964
@cloud-pi-native-sonarqube

Copy link
Copy Markdown

@shikanime shikanime left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict : Approuvé — la PR reste en draft dans l'attente de la décision d'atterrissage.

Couverture adversariale solide : mapping VaultError exhaustif, cas limites approle/token, ordre du parcours récursif verrouillé. Le second commit fix(...) (wrap non-JSON + fail-fast delete partiel) est vérifié pertinent et absent de main — rien à retirer. Écart à harmoniser avant le passage ready : le titre dit test(...) mais la PR embarque un fix. Recommandation : atterrir celle-ci puis restacker #2670 (migration MSW qui réécrit ce spec).

try {
responseBody = await response.json()
} catch {
// A non-JSON error body (proxy HTML page) must not escape the VaultError contract.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ Éloge — le try/catch sur le corps d'erreur garde le contrat VaultError intact face à un corps non-JSON (page HTML de proxy) : l'échec reste typé au lieu de fuiter en SyntaxError.

}
}))
const rejected = results.find(result => result.status === 'rejected')
if (rejected) throw rejected.reason

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ Éloge — le fail-fast après allSettled ré-élève la première erreur réelle au lieu de l'avaler : une suppression partielle ne passe plus inaperçue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant