@@ -75,9 +75,9 @@ describe("cveClient — CVE operations", () => {
7575 await client . publishcve ( "CVE-2024-1234" , { description : "test" } ) ;
7676 expect ( lastFetchUrl ) . toBe ( "https://api.example.com/cve/CVE-2024-1234/cna" ) ;
7777 expect ( lastFetchOpts . method ) . toBe ( "POST" ) ;
78- expect ( JSON . parse ( lastFetchOpts . body ) ) . toEqual ( {
79- cnaContainer : { description : "test" } ,
80- } ) ;
78+ const body = JSON . parse ( lastFetchOpts . body ) ;
79+ expect ( body . cnaContainer . description ) . toBe ( "test" ) ;
80+ expect ( body . cnaContainer . x_generator . engine ) . toMatch ( / ^ c v e C l i e n t \/ / ) ;
8181 } ) ;
8282
8383 it ( "publishcve uses PUT for update" , async ( ) => {
@@ -122,6 +122,38 @@ describe("cveClient — CVE operations", () => {
122122 } ) ;
123123} ) ;
124124
125+ describe ( "cveClient — x_generator" , ( ) => {
126+ let client ;
127+
128+ beforeEach ( ( ) => {
129+ client = new CveClient (
130+ "test-org" ,
131+ "test-user" ,
132+ "key" ,
133+ "https://api.example.com" ,
134+ ) ;
135+ } ) ;
136+
137+ it ( "injects default x_generator with cveClientlib version when not set" , async ( ) => {
138+ const cnajson = { descriptions : [ { lang : "en" , value : "test" } ] } ;
139+ await client . publishcve ( "CVE-2024-1234" , cnajson , true ) ;
140+ expect ( cnajson [ "x_generator" ] ) . toEqual ( {
141+ engine : "cveClient/" + client . _version ,
142+ } ) ;
143+ } ) ;
144+
145+ it ( "preserves caller-provided x_generator (UI path)" , async ( ) => {
146+ const cnajson = {
147+ descriptions : [ { lang : "en" , value : "test" } ] ,
148+ x_generator : { engine : "cveClient/1.0.25" } ,
149+ } ;
150+ await client . publishcve ( "CVE-2024-1234" , cnajson , true ) ;
151+ expect ( cnajson [ "x_generator" ] ) . toEqual ( {
152+ engine : "cveClient/1.0.25" ,
153+ } ) ;
154+ } ) ;
155+ } ) ;
156+
125157describe ( "cveClient — ADP operations" , ( ) => {
126158 let client ;
127159
0 commit comments