Beispiel #1
0
 def test_get_component_analyses_with_disable_unknown_package_flow(
         self, _sensitive, _request, _analyses, _bookkeeping, _session, _g):
     """No Analyses Data found, with DISABLE_UNKNOWN_PACKAGE_FLOW flag, returns 202."""
     with patch.dict('os.environ', {'DISABLE_UNKNOWN_PACKAGE_FLOW': '1'}):
         ca = ComponentAnalysesApi()
         response = ca.get('npm', 'pkg', 'ver')
         self.assertEqual(response.status, 202)
         self.assertIsInstance(response, tuple)
 def test_get_component_analyses_with_result_not_none(
         self, _vendor_analyses, _sensitive, _request, _session):
     """CA GET: with VALID result."""
     result = 'my_package_analyses_result'
     _vendor_analyses.return_value = result
     ca = ComponentAnalysesApi()
     analyses_result = ca.get('npm', 'pkg', 'ver')
     self.assertEqual(analyses_result, result)
Beispiel #3
0
 def test_get_component_analyses_with_invoke_api_workers(
         self, _vendor, _sensitive, _request, _analyses, _bookkeeping,
         _session, _g):
     """CA GET: No Analyses Data found with API worker flag."""
     ca = ComponentAnalysesApi()
     with patch.dict('os.environ', {'INVOKE_API_WORKERS': '1'}):
         response = ca.get('npm', 'pkg', 'ver')
         self.assertEqual(response.status, 202)
         self.assertIsInstance(response, tuple)
     self.assertNotIn('INVOKE_API_WORKERS', os.environ)
 def test_get_component_analyses(self, _vendor_analyses, _sensitive,
                                 _request, _session, _unknown):
     """CA GET: No Analyses Data found."""
     eco, package, version = 'maven', \
                             'com.netease.ysf.architecture:qiyu-es-spring-boot-starter', '1.1.0'
     returned = {
         "message": f"No data found for {eco} package {package}/{version}"
     }
     _vendor_analyses.return_value = returned
     ca = ComponentAnalysesApi()
     response = ca.get(eco, package, version)
     self.assertEqual(response, returned)
Beispiel #5
0
 def test_get_component_analyses(self, _sensitive, _request, _analyses,
                                 _bookkeeping, _session, _g):
     """CA GET: No Analyses Data found, without INVOKE_API_WORKERS flag, Raises HTTP Error."""
     ca = ComponentAnalysesApi()
     self.assertRaises(HTTPError, ca.get, 'npm', 'pkg', 'ver')
Beispiel #6
0
 def test_get_component_analyses(self, _sensitive, _request, _session,
                                 _unknown):
     """CA GET: No Analyses Data found, Raises HTTP Error."""
     ca = ComponentAnalysesApi()
     self.assertRaises(HTTPError, ca.get, 'npm', 'pkg', 'ver')