@@ -188,8 +188,92 @@ describe('Testing Get CVE-ID endpoint', () => {
188188 expect ( cveIdObject . requested_by . user ) . to . equal ( constants . nonSecretariatUserHeaders [ 'CVE-API-USER' ] )
189189 } )
190190 } )
191+ it ( 'For Secretariat users, should return full information when getting a single RESERVED CVE ID' , async ( ) => {
192+ const cveId = await helpers . cveIdReserveHelper ( 1 , '2023' , constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] , 'non-sequential' )
193+
194+ await chai . request ( app )
195+ . get ( `/api/cve-id/${ cveId } ` )
196+ . set ( constants . headers )
197+ . then ( async ( res , err ) => {
198+ expect ( err ) . to . be . undefined
199+ expect ( res ) . to . have . status ( 200 )
200+ expect ( res . body . cve_id ) . to . equal ( cveId )
201+ expect ( res . body . state ) . to . equal ( 'RESERVED' )
202+ // Secretariat user should see owning org details
203+ expect ( res . body . owning_cna ) . to . equal ( constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] )
204+ } )
205+ } )
206+
207+ it ( 'For owning CNA users, should return full information when getting a single RESERVED CVE ID' , async ( ) => {
208+ const cveId = await helpers . cveIdReserveHelper ( 1 , '2023' , constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] , 'non-sequential' )
209+
210+ await chai . request ( app )
211+ . get ( `/api/cve-id/${ cveId } ` )
212+ . set ( constants . nonSecretariatUserHeaders )
213+ . then ( async ( res , err ) => {
214+ expect ( err ) . to . be . undefined
215+ expect ( res ) . to . have . status ( 200 )
216+ expect ( res . body . cve_id ) . to . equal ( cveId )
217+ expect ( res . body . state ) . to . equal ( 'RESERVED' )
218+ // Non-secretariat user from owning org should see owning org details
219+ expect ( res . body . owning_cna ) . to . equal ( constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] )
220+ } )
221+ } )
222+
223+ it ( 'For non-owning CNA users, should return partial information and redacted owning_cna when getting a single RESERVED CVE ID' , async function ( ) {
224+ const cveId = await helpers . cveIdReserveHelper ( 1 , '2023' , constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] , 'non-sequential' )
225+
226+ await chai . request ( app )
227+ . get ( `/api/cve-id/${ cveId } ` )
228+ . set ( constants . nonSecretariatUserHeaders3 ) // evidence_15
229+ . then ( async ( res , err ) => {
230+ expect ( err ) . to . be . undefined
231+ expect ( res ) . to . have . status ( 200 )
232+ expect ( res . body . cve_id ) . to . equal ( cveId )
233+ expect ( res . body . state ) . to . equal ( 'RESERVED' )
234+ expect ( res . body . owning_cna ) . to . equal ( '[REDACTED]' )
235+ expect ( res . body ) . to . not . have . property ( 'requested_by' )
236+ } )
237+ } )
191238 } )
192239 context ( 'negative tests' , ( ) => {
240+ it ( 'An inactive user should be treated as unauthenticated for optionallyValidateUser endpoints (GET /api/cve-id/:id)' , async function ( ) {
241+ const cveId = await helpers . cveIdReserveHelper ( 1 , '2023' , constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] , 'non-sequential' )
242+
243+ // Deactivate user
244+ await helpers . userDeactivateAsSecHelper ( constants . nonSecretariatUserHeaders [ 'CVE-API-USER' ] , constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] )
245+
246+ await chai . request ( app )
247+ . get ( `/api/cve-id/${ cveId } ` )
248+ . set ( constants . nonSecretariatUserHeaders )
249+ . then ( async ( res , err ) => {
250+ expect ( err ) . to . be . undefined
251+ expect ( res ) . to . have . status ( 200 )
252+ expect ( res . body . cve_id ) . to . equal ( cveId )
253+ expect ( res . body . owning_cna ) . to . equal ( '[REDACTED]' ) // Should be redacted because user is treated as unauthenticated
254+
255+ // Reactivate user for other tests
256+ await helpers . userReactivateAsSecHelper ( constants . nonSecretariatUserHeaders [ 'CVE-API-USER' ] , constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] )
257+ } )
258+ } )
259+
260+ it ( 'An inactive user should be denied access for validateUser endpoints (GET /api/cve-id)' , async function ( ) {
261+ // Deactivate user
262+ await helpers . userDeactivateAsSecHelper ( constants . nonSecretariatUserHeaders [ 'CVE-API-USER' ] , constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] )
263+
264+ await chai . request ( app )
265+ . get ( '/api/cve-id' )
266+ . set ( constants . nonSecretariatUserHeaders )
267+ . then ( async ( res , err ) => {
268+ expect ( err ) . to . be . undefined
269+ expect ( res ) . to . have . status ( 401 )
270+ expect ( res . body . error ) . to . equal ( 'UNAUTHORIZED' )
271+
272+ // Reactivate user for other tests
273+ await helpers . userReactivateAsSecHelper ( constants . nonSecretariatUserHeaders [ 'CVE-API-USER' ] , constants . nonSecretariatUserHeaders [ 'CVE-API-ORG' ] )
274+ } )
275+ } )
276+
193277 it ( 'Feb 29 2100 should not be valid' , async ( ) => {
194278 await chai . request ( app )
195279 . get ( '/api/cve-id?time_modified.gt=2100-02-29T00:00:00Z' )
0 commit comments