@@ -44,11 +44,11 @@ def _mock_response(self, data=None, status_code=200):
4444 # Dependencies endpoints
4545 def test_dependencies_post_unit (self ):
4646 """Test dependencies post with proper file handling."""
47- expected_data = {"packages" : [{"name" : "lodash" , "version" : "4.17.21 " }]}
47+ expected_data = {"packages" : [{"name" : "lodash" , "version" : "4.18.1 " }]}
4848 self ._mock_response (expected_data )
4949
5050 with tempfile .NamedTemporaryFile (mode = 'w' , suffix = '.json' , delete = False ) as f :
51- json .dump ({"name" : "test-package" , "dependencies" : {"lodash" : "4.17.21 " }}, f )
51+ json .dump ({"name" : "test-package" , "dependencies" : {"lodash" : "4.18.1 " }}, f )
5252 f .flush ()
5353
5454 try :
@@ -72,12 +72,12 @@ def test_dependencies_get_unit(self):
7272 expected_data = {"dependencies" : [{"name" : "sub-dependency" , "version" : "1.0.0" }]}
7373 self ._mock_response (expected_data )
7474
75- result = self .sdk .dependencies .get ("test-org" , "npm" , "lodash" , "4.17.21 " )
75+ result = self .sdk .dependencies .get ("test-org" , "npm" , "lodash" , "4.18.1 " )
7676
7777 self .assertEqual (result , expected_data )
7878 call_args = self .mock_requests .request .call_args
7979 self .assertEqual (call_args [0 ][0 ], "GET" )
80- self .assertIn ("/orgs/test-org/dependencies/npm/lodash/4.17.21 " , call_args [0 ][1 ])
80+ self .assertIn ("/orgs/test-org/dependencies/npm/lodash/4.18.1 " , call_args [0 ][1 ])
8181
8282 # DiffScans endpoints
8383 def test_diffscans_list_unit (self ):
@@ -305,24 +305,24 @@ def test_npm_issues_unit(self):
305305 expected_data = [{"type" : "security" , "severity" : "high" , "title" : "Test issue" }]
306306 self ._mock_response (expected_data )
307307
308- result = self .sdk .npm .issues ("lodash" , "4.17.21 " )
308+ result = self .sdk .npm .issues ("lodash" , "4.18.1 " )
309309
310310 self .assertEqual (result , expected_data )
311311 call_args = self .mock_requests .request .call_args
312312 self .assertEqual (call_args [0 ][0 ], "GET" )
313- self .assertIn ("/npm/lodash/4.17.21 /issues" , call_args [0 ][1 ])
313+ self .assertIn ("/npm/lodash/4.18.1 /issues" , call_args [0 ][1 ])
314314
315315 def test_npm_score_unit (self ):
316316 """Test npm score endpoint."""
317317 expected_data = [{"category" : "security" , "value" : 85 }]
318318 self ._mock_response (expected_data )
319319
320- result = self .sdk .npm .score ("lodash" , "4.17.21 " )
320+ result = self .sdk .npm .score ("lodash" , "4.18.1 " )
321321
322322 self .assertEqual (result , expected_data )
323323 call_args = self .mock_requests .request .call_args
324324 self .assertEqual (call_args [0 ][0 ], "GET" )
325- self .assertIn ("/npm/lodash/4.17.21 /score" , call_args [0 ][1 ])
325+ self .assertIn ("/npm/lodash/4.18.1 /score" , call_args [0 ][1 ])
326326
327327 # OpenAPI endpoints
328328 def test_openapi_get_unit (self ):
@@ -352,22 +352,22 @@ def test_org_get_unit(self):
352352
353353 # PURL endpoints
354354 def test_purl_post_unit (self ):
355- """Test PURL validation endpoint."""
355+ """Test org-scoped PURL validation endpoint."""
356356 # Expected final result after deduplication - should match what the dedupe function produces
357357 expected_data = [{
358- "inputPurl" : "pkg:npm/lodash@4.17.21 " ,
359- "purl" : "pkg:npm/lodash@4.17.21 " ,
358+ "inputPurl" : "pkg:npm/lodash@4.18.1 " ,
359+ "purl" : "pkg:npm/lodash@4.18.1 " ,
360360 "type" : "npm" ,
361361 "name" : "lodash" ,
362- "version" : "4.17.21 " ,
362+ "version" : "4.18.1 " ,
363363 "valid" : True ,
364364 "alerts" : [],
365365 "releases" : ["npm" ]
366366 }]
367367
368368 # Mock the NDJSON response that would come from the actual API
369369 # This simulates what the API returns: newline-delimited JSON with SocketArtifact objects
370- mock_ndjson_response = '{"inputPurl": "pkg:npm/lodash@4.17.21 ", "purl": "pkg:npm/lodash@4.17.21 ", "type": "npm", "name": "lodash", "version": "4.17.21 ", "valid": true, "alerts": []}'
370+ mock_ndjson_response = '{"inputPurl": "pkg:npm/lodash@4.18.1 ", "purl": "pkg:npm/lodash@4.18.1 ", "type": "npm", "name": "lodash", "version": "4.18.1 ", "valid": true, "alerts": []}'
371371
372372 # Mock the response with NDJSON format
373373 mock_response = Mock ()
@@ -376,13 +376,30 @@ def test_purl_post_unit(self):
376376 mock_response .text = mock_ndjson_response
377377 self .mock_requests .request .return_value = mock_response
378378
379- components = [{"purl" : "pkg:npm/lodash@4.17.21 " }]
380- result = self .sdk .purl .post ("false" , components )
379+ components = [{"purl" : "pkg:npm/lodash@4.18.1 " }]
380+ result = self .sdk .purl .post ("false" , components , org_slug = "test-org" )
381381
382382 self .assertEqual (result , expected_data )
383+ call_args = self .mock_requests .request .call_args
384+ self .assertEqual (call_args [0 ][0 ], "POST" )
385+ self .assertIn ("/orgs/test-org/purl" , call_args [0 ][1 ])
386+
387+ def test_purl_post_unit_legacy_path (self ):
388+ """Test legacy PURL validation endpoint remains available for compatibility."""
389+ mock_ndjson_response = '{"inputPurl": "pkg:npm/lodash@4.18.1", "purl": "pkg:npm/lodash@4.18.1", "type": "npm", "name": "lodash", "version": "4.18.1", "valid": true, "alerts": []}'
390+
391+ mock_response = Mock ()
392+ mock_response .status_code = 200
393+ mock_response .headers = {'content-type' : 'application/x-ndjson' }
394+ mock_response .text = mock_ndjson_response
395+ self .mock_requests .request .return_value = mock_response
396+
397+ self .sdk .purl .post ("false" , [{"purl" : "pkg:npm/lodash@4.18.1" }])
398+
383399 call_args = self .mock_requests .request .call_args
384400 self .assertEqual (call_args [0 ][0 ], "POST" )
385401 self .assertIn ("/purl" , call_args [0 ][1 ])
402+ self .assertNotIn ("/orgs/" , call_args [0 ][1 ])
386403
387404 # Quota endpoints
388405 def test_quota_get_unit (self ):
0 commit comments