def test_process_gitlab_projects_with_ignore_project(
         self, mock_gptp, mock_commitmanager):
     # given
     scanner = GitLabScanner('url',
                             'token',
                             None, [], [1],
                             annotate_latest_commit_id=True)
     projects = assemble_projects()
     self.prepare_gitlab_commitlist_mock(mock_gptp, mock_commitmanager)
     # when
     findings = scanner._process_projects(projects)
     # then
     self.assertEqual(2,
                      len(findings),
                      msg='There should be exactly 2 findings')
     self.assertEqual(findings[0]['attributes']['web_url'],
                      'url2',
                      msg=self.wrong_output_msg)
     self.assertEqual(findings[1]['attributes']['web_url'],
                      'url3',
                      msg=self.wrong_output_msg)
     self.assertEqual(findings[0]['attributes']["last_commit_id"],
                      "deadbeef")
     mock_gptp.assert_called()
     mock_commitmanager.assert_called()
 def test_process_gitlab_projects_without_annotating_commit_id(
         self, mock_gptp, mock_commitmanager):
     # given
     scanner = GitLabScanner('url',
                             'token',
                             None, [], [],
                             annotate_latest_commit_id=False)
     projects = assemble_projects()
     self.prepare_gitlab_commitlist_mock(mock_gptp, mock_commitmanager)
     # when
     findings = scanner._process_projects(projects)
     # then
     self.assertEqual(3,
                      len(findings),
                      msg='There should be exactly 3 findings')
     self.assertEqual(findings[0]['name'],
                      'GitLab Repo',
                      msg=self.wrong_output_msg)
     self.assertEqual(findings[0]['attributes']['web_url'],
                      'url1',
                      msg=self.wrong_output_msg)
     self.assertEqual(findings[1]['attributes']['web_url'],
                      'url2',
                      msg=self.wrong_output_msg)
     self.assertEqual(findings[2]['attributes']['web_url'],
                      'url3',
                      msg=self.wrong_output_msg)
     self.assertFalse("last_commit_id" in findings[0]['attributes'])
     mock_gptp.assert_not_called()
     mock_commitmanager.assert_not_called()
Beispiel #3
0
 def test_process_gitlab_projects_with_ignore_project(self):
     # given
     scanner = GitLabScanner('url', 'token', None, [], [1])
     projects = assemble_projects()
     # when
     findings = scanner._process_projects(projects)
     # then
     self.assertEqual(2, len(findings), msg='There should be exactly 2 findings')
     self.assertEqual(findings[0]['attributes']['web_url'], 'url2', msg=self.wrong_output_msg)
     self.assertEqual(findings[1]['attributes']['web_url'], 'url3', msg=self.wrong_output_msg)