def test_extract_jenkins_credentials(self): """Tests the extract_jenkins_credentials method.""" config.LoadConfig() task = jenkins.JenkinsAnalysisTask() credentials = task._extract_jenkins_credentials( str(self.JENKINS_USER_CONFIG)) self.assertEqual(credentials, self.EXPECTED_CREDENTIALS)
def test_extract_jenkins_version(self): """Tests the extract_jenkins_version method.""" config.LoadConfig() task = jenkins.JenkinsAnalysisTask() version = task._extract_jenkins_version(str( self.JENKINS_SYSTEM_CONFIG)) self.assertEqual(version, self.EXPECTED_VERSION)
def test_analyze_jenkins_no_findings(self, bruteforce_mock): """Test that analyze_jenkins returns valid output with no findings.""" config.LoadConfig() task = jenkins.JenkinsAnalysisTask() bruteforce_mock.return_value = [] (report, priority, summary) = task.analyze_jenkins(self.EXPECTED_VERSION, self.EXPECTED_CREDENTIALS) self.assertEqual(report, self.JENKINS_ANALYSIS_EMPTY_REPORT) self.assertEqual(priority, 80) self.assertEqual(summary, 'Jenkins analysis found no issues')
def test_analyze_jenkins(self, bruteforce_mock): """Test that analyze_jenkins returns valid output with findings.""" config.LoadConfig() task = jenkins.JenkinsAnalysisTask() bruteforce_mock.return_value = [ ('$2a$10$DSltvO4YXZuoLuUU77R871627TEST', 'weakpassword') ] (report, priority, summary) = task.analyze_jenkins(self.EXPECTED_VERSION, self.EXPECTED_CREDENTIALS) report = report + '\n' self.assertEqual(report, self.JENKINS_ANALYSIS_REPORT) self.assertEqual(priority, 10) self.assertEqual(summary, 'Jenkins analysis found potential issues')