def test_process_github_repos_without_annotating_commit_ids( self, github_mock, org_mock, pag_mock): # given scanner = GitHubScanner('url', 'token', 'org', [], False, annotate_latest_commit_id=False) repos = assemble_repos() create_mocks(github_mock, org_mock, pag_mock, repos) scanner._gh = github_mock # when findings = scanner._process_repos(None, None) # then org_mock.get_repos.assert_called_with(type='all', sort='pushed', direction='asc') self.assertEqual(6, len(findings), msg='There should be exactly 6 findings') self.assertFalse(findings[0]["attributes"]["archived"]) self.assertFalse(findings[1]["attributes"]["archived"]) self.assertTrue(findings[2]["attributes"]["archived"]) self.assertFalse(findings[3]["attributes"]["archived"]) self.assertFalse(findings[4]["attributes"]["archived"]) self.assertTrue(findings[5]["attributes"]["archived"]) for finding in findings: self.assertEqual(finding['name'], 'GitHub Repo', msg=self.wrong_output_msg) self.assertFalse("last_commit_id" in finding['attributes'])
def test_process_github_repos_with_ignore_repos(self, github_mock, org_mock, pag_mock): # given scanner = GitHubScanner('url', 'token', 'org', [1], False) repos = assemble_repos() create_mocks(github_mock, org_mock, pag_mock, repos) scanner._gh = github_mock # when findings = scanner._process_repos(None, None) # then github_mock.get_organization.assert_called_with('org') self.assertEqual(4, len(findings), msg='There should be exactly 4 findings')
def test_process_github_repos_with_no_ignore_list(self, github_mock, org_mock, pag_mock): # given scanner = GitHubScanner('url', 'token', 'org', [], False) repos = assemble_repos() create_mocks(github_mock, org_mock, pag_mock, repos) scanner._gh = github_mock # when findings = scanner._process_repos(None, None) # then org_mock.get_repos.assert_called_with(type='all', sort='pushed', direction='asc') self.assertEqual(6, len(findings), msg='There should be exactly 6 findings') for finding in findings: self.assertEqual(finding['name'], 'GitHub Repo', msg=self.wrong_output_msg)