Exemple #1
0
    def test_rule_load_with_replatform_advice(self):
        rule = """
- category: "JEE Config"
  app_type: java
  file_type: config
  refactor_rating: 1
  replatform_advice: "Convert to Spring based application configuration"
  description: "JEE specific config file"
  files:
    - "application.xml"
"""

        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(1, len(Scanner.rulebase))
        rule = Scanner.rulebase[0]
        self.assertEqual("JEE Config", rule.file_category,
                         "Category should be mapped")
        self.assertEqual("java", rule.app_type, "App Type should be mapped")
        self.assertEqual("config", rule.file_type,
                         "File Type should be mapped")
        self.assertEqual("1", rule.refactor_rating,
                         "Refactor Rating should be mapped")
        self.assertEqual("Convert to Spring based application configuration",
                         rule.replatform_advice,
                         "Replatform Advice should be mapped")
        self.assertEqual("JEE specific config file", rule.description,
                         "Description should be mapped")
        self.assertEqual("application.xml", rule.file_name,
                         "File Name should be mapped")
Exemple #2
0
 def test_dotnet_version_not_present(self):
     """.NET framework version not in csproj file"""
     Scanner.csproj_file_scan(
         ['    <NoFrameworkVersion></NoFrameworkVersion>'],
         "testfile.csproj")
     results = Scanner.scan_results
     self.assertEqual(0, len(results))
 def test_config_scan(self):
     Scanner.load_rules(os.path.join("ephemerol", "test", "rulebase.csv"))
     file_path_list = ['persistence.xml', 'web.xml', 'bing.xml', 'dir/dir/dir/ra.xml', '/dir/dir/ejb-jar.xml',
                       'dir/dir/web.xml']
     Scanner.config_scan(file_path_list=file_path_list)
     results = Scanner.scan_results
     self.assertEqual(4, len(results))
Exemple #4
0
 def test_scan_for_filesystem_watcher(self):
     """Found .cs file with call to File.WriteAllText"""
     Scanner.cs_file_scan(
         ['        FileSystemWatcher watcher = new FileSystemWatcher();'],
         'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
    def test_rule_load_with_overriden_description_replatform_advice_refactor_rating(self):
        rule = """
- category: "cat1"
  app_type: app1
  file_type: type1
  refactor_rating: 0
  replatform_advice: "foo"
  description: "desc1"
  files:
    - "file1": { description: "desc2", replatform_advice: "bar", refactor_rating: 2 }
    - "file2"
"""
        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(2, len(Scanner.rulebase))
        found1 = False
        found2 = False
        for rule in Scanner.rulebase:
            self.assertEqual("cat1", rule.file_category, "Category should be mapped")
            self.assertEqual("app1", rule.app_type, "App Type should be mapped")
            self.assertEqual("type1", rule.file_type, "File Type should be mapped")
            self.assertTrue(rule.file_name == "file1" or rule.file_name == "file2")
            if rule.file_name == "file1":
                found1 = True
                self.assertEqual("2", rule.refactor_rating, "Refactor Rating should be mapped")
                self.assertEqual("bar", rule.replatform_advice, "Replatform Advice should be mapped")
                self.assertEqual("desc2", rule.description, "Description should be mapped")
            elif rule.file_name == "file2":
                found2 = True
                self.assertEqual("0", rule.refactor_rating, "Refactor Rating should be mapped")
                self.assertEqual("foo", rule.replatform_advice, "Replatform Advice should be mapped")
                self.assertEqual("desc1", rule.description, "Description should be mapped")
                self.assertEqual("file2", rule.file_name, "File Name should be mapped")
        self.assertTrue(found1 and found2, "Should have found both file1 and file2")
    def test_multiple_file_rule_load(self):
        rule = """
- category: "Web Profile"
  app_type: java
  file_type: config
  refactor_rating: 0
  description: "Web application config file"
  files:
    - "web.xml"
    - "foo.barml"
"""

        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(2, len(Scanner.rulebase))
        rule = Scanner.rulebase[0]
        self.assertEqual("Web Profile", rule.file_category, "Category should be mapped")
        self.assertEqual("java", rule.app_type, "App Type should be mapped")
        self.assertEqual("config", rule.file_type, "File Type should be mapped")
        self.assertEqual("0", rule.refactor_rating, "Refactor Rating should be mapped")
        self.assertEqual("Web application config file", rule.description, "Description should be mapped")
        self.assertEqual("web.xml", rule.file_name, "File Name should be mapped")
        rule = Scanner.rulebase[1]
        self.assertEqual("Web Profile", rule.file_category, "Category should be mapped")
        self.assertEqual("java", rule.app_type, "App Type should be mapped")
        self.assertEqual("config", rule.file_type, "File Type should be mapped")
        self.assertEqual("0", rule.refactor_rating, "Refactor Rating should be mapped")
        self.assertEqual("Web application config file", rule.description, "Description should be mapped")
        self.assertEqual("foo.barml", rule.file_name, "File Name should be mapped")
 def test_scan_for_file_open(self):
     """Found .cs file with call to File.Open"""
     Scanner.cs_file_scan(
         ['        using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Write, FileShare.None))'],
         'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
    def test_rule_load_with_multiple_text_patterns_overrides_and_file_pattern(self):
        rule = """
- category: "cat1"
  app_type: app1
  file_type: type1
  refactor_rating: 1
  replatform_advice: "foo"
  description: "desc1"
  text_patterns:
    - "pattern1"
    - "pattern2": { description: "desc2", replatform_advice: "bar", refactor_rating: 2 }
  file_pattern: "*.file1"
"""
        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(2, len(Scanner.rulebase))
        found1 = False
        found2 = False
        for rule in Scanner.rulebase:
            self.assertEqual("cat1", rule.file_category, "Category should be mapped")
            self.assertEqual("app1", rule.app_type, "App Type should be mapped")
            self.assertEqual("type1", rule.file_type, "File Type should be mapped")
            self.assertEqual("*.file1", rule.file_name, "File name should be mapped")
            self.assertTrue(rule.text_pattern == "pattern1" or rule.text_pattern == "pattern2")
            if rule.text_pattern == "pattern1":
                found1 = True
                self.assertEqual("desc1", rule.description, "Description should be mapped")
                self.assertEqual("foo", rule.replatform_advice, "Replatform advice should be mapped")
                self.assertEqual("1", rule.refactor_rating, "Refactor rating should be mapped")
            elif rule.text_pattern == "pattern2":
                found2 = True
                self.assertEqual("desc2", rule.description, "Description should be mapped")
                self.assertEqual("bar", rule.replatform_advice, "Replatform advice should be mapped")
                self.assertEqual("2", rule.refactor_rating, "Refactor rating should be mapped")
        self.assertTrue(found1 and found2, "Should have found pattern1 and pattern2")
Exemple #9
0
    def test_rule_load_with_multiple_text_patterns(self):
        rule = """
- category: "cat1"
  app_type: app1
  file_type: type1
  refactor_rating: 1
  replatform_advice: "foo"
  description: "desc1"
  text_patterns: [ "pattern1", "pattern2" ]
  files: [ "file1" ]
"""
        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(2, len(Scanner.rulebase))
        found1 = False
        found2 = False
        for rule in Scanner.rulebase:
            self.assertEqual("cat1", rule.file_category,
                             "Category should be mapped")
            self.assertEqual("app1", rule.app_type,
                             "App Type should be mapped")
            self.assertEqual("type1", rule.file_type,
                             "File Type should be mapped")
            self.assertEqual("file1", rule.file_name,
                             "File name should be mapped")
            self.assertTrue(rule.text_pattern == "pattern1"
                            or rule.text_pattern == "pattern2")
            if rule.text_pattern == "pattern1":
                found1 = True
            elif rule.text_pattern == "pattern2":
                found2 = True
        self.assertTrue(found1 and found2,
                        "Should have found pattern1 and pattern2")
    def test_rule_load_with_multiple_text_patterns(self):
        rule = """
- category: "cat1"
  app_type: app1
  file_type: type1
  refactor_rating: 1
  replatform_advice: "foo"
  description: "desc1"
  text_patterns: [ "pattern1", "pattern2" ]
  files: [ "file1" ]
"""
        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(2, len(Scanner.rulebase))
        found1 = False
        found2 = False
        for rule in Scanner.rulebase:
            self.assertEqual("cat1", rule.file_category, "Category should be mapped")
            self.assertEqual("app1", rule.app_type, "App Type should be mapped")
            self.assertEqual("type1", rule.file_type, "File Type should be mapped")
            self.assertEqual("file1", rule.file_name, "File name should be mapped")
            self.assertTrue(rule.text_pattern == "pattern1" or rule.text_pattern == "pattern2")
            if rule.text_pattern == "pattern1":
                found1 = True
            elif rule.text_pattern == "pattern2":
                found2 = True
        self.assertTrue(found1 and found2, "Should have found pattern1 and pattern2")
Exemple #11
0
    def test_rule_load_with_file_pattern(self):
        rule = """
- category: "cat1"
  app_type: app1
  file_type: type1
  refactor_rating: 1
  replatform_advice: "foo"
  description: "desc1"
  file_pattern: "*.file1"
"""
        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(1, len(Scanner.rulebase))
        rule = Scanner.rulebase[0]
        self.assertEqual("cat1", rule.file_category,
                         "Category should be mapped")
        self.assertEqual("app1", rule.app_type, "App Type should be mapped")
        self.assertEqual("type1", rule.file_type, "File Type should be mapped")
        self.assertEqual("*.file1", rule.file_name,
                         "File name should be mapped")
        self.assertEqual("1", rule.refactor_rating,
                         "Refactor Rating should be mapped")
        self.assertEqual("foo", rule.replatform_advice,
                         "Replatform Advice should be mapped")
        self.assertEqual("desc1", rule.description,
                         "Description should be mapped")
Exemple #12
0
 def test_scan_for_file_open(self):
     """Found .cs file with call to File.Open"""
     Scanner.cs_file_scan(
         ['        using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Write, FileShare.None))'],
         'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
Exemple #13
0
 def test_config_scan(self):
     file_path_list = ['persistence.xml', 'web.xml', 'bing.xml', 'dir/dir/dir/ra.xml', '/dir/dir/ejb-jar.xml',
                       'dir/dir/web.xml']
     Scanner.scan_results = []
     Scanner.config_scan(file_path_list=file_path_list)
     results = Scanner.scan_results
     self.assertEqual(5, len(results))
     print(results)
Exemple #14
0
 def test_java_scan(self):
     Scanner.load_rules(os.path.join("ephemerol", "test", "rulebase.csv"))
     df = Scanner.scan_archive(os.path.join("ephemerol", "test", "SampleWebApp-master.zip"))
     #print(df)
     self.assertEqual(1, df[(df.refactor_rating == 3)].shape[0])
     self.assertEqual(5, df[(df.refactor_rating == 1)].shape[0])
     self.assertEqual(11, df[(df.refactor_rating == 0)].shape[0])
     self.assertEqual(92, 100 - df.refactor_rating.cumsum().tail(1).item())
 def test_config_scan(self):
     file_path_list = ['persistence.xml', 'web.xml', 'bing.xml', 'dir/dir/dir/ra.xml', '/dir/dir/ejb-jar.xml',
                       'dir/dir/web.xml']
     Scanner.scan_results = []
     Scanner.config_scan(file_path_list=file_path_list)
     results = Scanner.scan_results
     self.assertEqual(5, len(results))
     print(results)
Exemple #16
0
 def test_scan_for_extension_but_not_servicebase(self):
     """Found .cs file with class extending FooBar"""
     Scanner.cs_file_scan([
         'using System.ServiceProcess;', 'using System.Text;',
         'using System.Threading.Tasks;', 'namespace WindowsService1', '{',
         '    public partial class Service1 : FooBar', '    {'
     ], 'Service1.cs')
     results = Scanner.scan_results
     self.assertEqual(0, len(results))
Exemple #17
0
 def test_scan_for_servicebase_extension(self):
     """Found .cs file with class extending ServiceBase"""
     Scanner.cs_file_scan([
         'using System.ServiceProcess;', 'using System.Text;',
         'using System.Threading.Tasks;', 'namespace WindowsService1', '{',
         '    public partial class Service1 : ServiceBase', '    {'
     ], 'Service1.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
     self.assertEqual("20", results[0].refactor_rating)
Exemple #18
0
    def test_load_rules(self):
        Scanner.load_rules(os.path.join("ephemerol", "test", "rulebase.csv"))
        rb = Scanner.rulebase

        self.assertEqual(66, rb[(rb.app_type == "java")].shape[0])
        self.assertEqual(1, rb[(rb.file_id == "persistence.xml")].shape[0])
        self.assertEqual(6, rb[(rb.refactor_rating == 3)].shape[0])
        self.assertEqual(1, rb[(rb.description == "JPA based ORM")].shape[0])
        self.assertEqual(53, rb[(rb.file_type == "config")].shape[0])
        self.assertEqual(6, rb[(rb.file_category == "Web Profile")].shape[0])
        self.assertEqual(1, rb[(rb.text_pattern == "import javax.ejb.")].shape[0])
 def test_scan_for_extension_but_not_servicebase(self):
     """Found .cs file with class extending FooBar"""
     Scanner.cs_file_scan(['using System.ServiceProcess;',
                           'using System.Text;',
                           'using System.Threading.Tasks;',
                           'namespace WindowsService1',
                           '{',
                           '    public partial class Service1 : FooBar',
                           '    {'],
                          'Service1.cs')
     results = Scanner.scan_results
     self.assertEqual(0, len(results))
 def test_scan_for_servicebase_extension(self):
     """Found .cs file with class extending ServiceBase"""
     Scanner.cs_file_scan(['using System.ServiceProcess;',
                           'using System.Text;',
                           'using System.Threading.Tasks;',
                           'namespace WindowsService1',
                           '{',
                           '    public partial class Service1 : ServiceBase',
                           '    {'],
                          'Service1.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
     self.assertEqual("20", results[0].refactor_rating)
 def test_archive_scan(self):
     """Verify cloud readiness index for SampleWebApp-master.zip and rulebase.csv"""
     archive = "SampleWebApp-master.zip"
     if not os.path.isfile(archive):
         archive = os.path.join("ephemerol", "test", archive)
     results_stats = Scanner.scan_archive(archive)
     self.assertEqual(97.44, results_stats.cloud_readiness_index)
Exemple #22
0
 def test_archive_scan(self):
     """Verify cloud readiness index for SampleWebApp-master.zip and rulebase.csv"""
     archive = "SampleWebApp-master.zip"
     if not os.path.isfile(archive):
         archive = os.path.join("ephemerol", "test", archive)
     results_stats = Scanner.scan_archive(archive)
     self.assertEqual(97.44, results_stats.cloud_readiness_index)
Exemple #23
0
    def test_rule_load_with_multiple_text_patterns_overrides_and_file_pattern(
            self):
        rule = """
- category: "cat1"
  app_type: app1
  file_type: type1
  refactor_rating: 1
  replatform_advice: "foo"
  description: "desc1"
  text_patterns:
    - "pattern1"
    - "pattern2": { description: "desc2", replatform_advice: "bar", refactor_rating: 2 }
  file_pattern: "*.file1"
"""
        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(2, len(Scanner.rulebase))
        found1 = False
        found2 = False
        for rule in Scanner.rulebase:
            self.assertEqual("cat1", rule.file_category,
                             "Category should be mapped")
            self.assertEqual("app1", rule.app_type,
                             "App Type should be mapped")
            self.assertEqual("type1", rule.file_type,
                             "File Type should be mapped")
            self.assertEqual("*.file1", rule.file_name,
                             "File name should be mapped")
            self.assertTrue(rule.text_pattern == "pattern1"
                            or rule.text_pattern == "pattern2")
            if rule.text_pattern == "pattern1":
                found1 = True
                self.assertEqual("desc1", rule.description,
                                 "Description should be mapped")
                self.assertEqual("foo", rule.replatform_advice,
                                 "Replatform advice should be mapped")
                self.assertEqual("1", rule.refactor_rating,
                                 "Refactor rating should be mapped")
            elif rule.text_pattern == "pattern2":
                found2 = True
                self.assertEqual("desc2", rule.description,
                                 "Description should be mapped")
                self.assertEqual("bar", rule.replatform_advice,
                                 "Replatform advice should be mapped")
                self.assertEqual("2", rule.refactor_rating,
                                 "Refactor rating should be mapped")
        self.assertTrue(found1 and found2,
                        "Should have found pattern1 and pattern2")
Exemple #24
0
    def test_rule_load_with_overriden_description_replatform_advice_refactor_rating(
            self):
        rule = """
- category: "cat1"
  app_type: app1
  file_type: type1
  refactor_rating: 0
  replatform_advice: "foo"
  description: "desc1"
  files:
    - "file1": { description: "desc2", replatform_advice: "bar", refactor_rating: 2 }
    - "file2"
"""
        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(2, len(Scanner.rulebase))
        found1 = False
        found2 = False
        for rule in Scanner.rulebase:
            self.assertEqual("cat1", rule.file_category,
                             "Category should be mapped")
            self.assertEqual("app1", rule.app_type,
                             "App Type should be mapped")
            self.assertEqual("type1", rule.file_type,
                             "File Type should be mapped")
            self.assertTrue(rule.file_name == "file1"
                            or rule.file_name == "file2")
            if rule.file_name == "file1":
                found1 = True
                self.assertEqual("2", rule.refactor_rating,
                                 "Refactor Rating should be mapped")
                self.assertEqual("bar", rule.replatform_advice,
                                 "Replatform Advice should be mapped")
                self.assertEqual("desc2", rule.description,
                                 "Description should be mapped")
            elif rule.file_name == "file2":
                found2 = True
                self.assertEqual("0", rule.refactor_rating,
                                 "Refactor Rating should be mapped")
                self.assertEqual("foo", rule.replatform_advice,
                                 "Replatform Advice should be mapped")
                self.assertEqual("desc1", rule.description,
                                 "Description should be mapped")
                self.assertEqual("file2", rule.file_name,
                                 "File Name should be mapped")
        self.assertTrue(found1 and found2,
                        "Should have found both file1 and file2")
    def test_rule_load_with_file_pattern(self):
        rule = """
- category: "cat1"
  app_type: app1
  file_type: type1
  refactor_rating: 1
  replatform_advice: "foo"
  description: "desc1"
  file_pattern: "*.file1"
"""
        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(1, len(Scanner.rulebase))
        rule = Scanner.rulebase[0]
        self.assertEqual("cat1", rule.file_category, "Category should be mapped")
        self.assertEqual("app1", rule.app_type, "App Type should be mapped")
        self.assertEqual("type1", rule.file_type, "File Type should be mapped")
        self.assertEqual("*.file1", rule.file_name, "File name should be mapped")
        self.assertEqual("1", rule.refactor_rating, "Refactor Rating should be mapped")
        self.assertEqual("foo", rule.replatform_advice, "Replatform Advice should be mapped")
        self.assertEqual("desc1", rule.description, "Description should be mapped")
Exemple #26
0
    def test_multiple_file_rule_load(self):
        rule = """
- category: "Web Profile"
  app_type: java
  file_type: config
  refactor_rating: 0
  description: "Web application config file"
  files:
    - "web.xml"
    - "foo.barml"
"""

        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(2, len(Scanner.rulebase))
        rule = Scanner.rulebase[0]
        self.assertEqual("Web Profile", rule.file_category,
                         "Category should be mapped")
        self.assertEqual("java", rule.app_type, "App Type should be mapped")
        self.assertEqual("config", rule.file_type,
                         "File Type should be mapped")
        self.assertEqual("0", rule.refactor_rating,
                         "Refactor Rating should be mapped")
        self.assertEqual("Web application config file", rule.description,
                         "Description should be mapped")
        self.assertEqual("web.xml", rule.file_name,
                         "File Name should be mapped")
        rule = Scanner.rulebase[1]
        self.assertEqual("Web Profile", rule.file_category,
                         "Category should be mapped")
        self.assertEqual("java", rule.app_type, "App Type should be mapped")
        self.assertEqual("config", rule.file_type,
                         "File Type should be mapped")
        self.assertEqual("0", rule.refactor_rating,
                         "Refactor Rating should be mapped")
        self.assertEqual("Web application config file", rule.description,
                         "Description should be mapped")
        self.assertEqual("foo.barml", rule.file_name,
                         "File Name should be mapped")
    def test_rule_load_with_replatform_advice(self):
        rule = """
- category: "JEE Config"
  app_type: java
  file_type: config
  refactor_rating: 1
  replatform_advice: "Convert to Spring based application configuration"
  description: "JEE specific config file"
  files:
    - "application.xml"
"""

        Scanner.load_yaml_rules_stream(rule)
        self.assertEqual(1, len(Scanner.rulebase))
        rule = Scanner.rulebase[0]
        self.assertEqual("JEE Config", rule.file_category, "Category should be mapped")
        self.assertEqual("java", rule.app_type, "App Type should be mapped")
        self.assertEqual("config", rule.file_type, "File Type should be mapped")
        self.assertEqual("1", rule.refactor_rating, "Refactor Rating should be mapped")
        self.assertEqual("Convert to Spring based application configuration", rule.replatform_advice,
                         "Replatform Advice should be mapped")
        self.assertEqual("JEE specific config file", rule.description, "Description should be mapped")
        self.assertEqual("application.xml", rule.file_name, "File Name should be mapped")
Exemple #28
0
    def test_cloud_readiness_index_algorithm(self):
        """make sure no scan results to 20 to 220 show consistent readiness index"""
        scan_stats = ScanStats(Scanner.scan_results)
        self.assertEqual(0, len(scan_stats.scan_result_list))
        self.assertEqual(100, scan_stats.cloud_readiness_index)

        for counter in range(0, 10):
            Scanner.java_file_scan(['import javax.ejb.'], 'BadPojo.java')
            Scanner.java_file_scan(['import org.springframework.'], 'GoodPojo.java')

        scan_stats = ScanStats(Scanner.scan_results)
        self.assertEqual(20, len(scan_stats.scan_result_list))
        self.assertEqual(85, scan_stats.cloud_readiness_index)

        for counter in range(0, 100):
            Scanner.java_file_scan(['import javax.ejb.'], 'BadPojo.java')
            Scanner.java_file_scan(['import org.springframework.'], 'GoodPojo.java')
            scan_stats = ScanStats(Scanner.scan_results)

        self.assertEqual(220, len(scan_stats.scan_result_list))
        self.assertEqual(85, scan_stats.cloud_readiness_index)
    def test_cloud_readiness_index_algorithm(self):
        """make sure no scan results to 20 to 220 show consistent readiness index"""
        scan_stats = ScanStats(Scanner.scan_results)
        self.assertEqual(0, len(scan_stats.scan_result_list))
        self.assertEqual(100, scan_stats.cloud_readiness_index)

        for counter in range(0, 10):
            Scanner.java_file_scan(['import javax.ejb.'], 'BadPojo.java')
            Scanner.java_file_scan(['import org.springframework.'], 'GoodPojo.java')

        scan_stats = ScanStats(Scanner.scan_results)
        self.assertEqual(20, len(scan_stats.scan_result_list))
        self.assertEqual(85, scan_stats.cloud_readiness_index)

        for counter in range(0, 100):
            Scanner.java_file_scan(['import javax.ejb.'], 'BadPojo.java')
            Scanner.java_file_scan(['import org.springframework.'], 'GoodPojo.java')
            scan_stats = ScanStats(Scanner.scan_results)

        self.assertEqual(220, len(scan_stats.scan_result_list))
        self.assertEqual(85, scan_stats.cloud_readiness_index)
 def test_scan_for_ado_net_use(self):
     """Found .cs file with \"using System.Data\'"""
     Scanner.cs_file_scan(['using System.Data;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
 def dotnet_version_tester(self, sample_data, refactor_rating):
     Scanner.csproj_file_scan([sample_data], "testfile.csproj")
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
     self.assertEqual(refactor_rating, results[0].refactor_rating)
 def test_has_scan_func_for_csproj(self):
     """Make sure files ending in csproj have a scan function"""
     scan_func = Scanner.get_scan_func("foobar.csproj")
     self.assertIsNotNone(scan_func)
 def test_archive_scan_yaml(self):
     Scanner.load_yaml_rules(self.path_helper("rulebase.yml"))
     results_stats = Scanner.scan_archive(self.path_helper("SampleWebApp-master.zip"))
     self.assertEqual(97.44, results_stats.cloud_readiness_index)
Exemple #34
0
 def test_scan_double_hit_for_ado_net_and_odbc_use(self):
     """Found .cs file with \"using System.Data\'" and \"using System.Data.Odbc\'"""
     Scanner.cs_file_scan(['using System.Data;', 'using System.Data.Odbc;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(2, len(results))
 def setUp(self):
     Scanner.load_rules(self.TEST_RULE_FILE)
     Scanner.scan_results = []
 def test_scan_for_filesystem_watcher(self):
     """Found .cs file with call to File.WriteAllText"""
     Scanner.cs_file_scan(['        FileSystemWatcher watcher = new FileSystemWatcher();'], 'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
Exemple #37
0
 def test_scan_for_ado_net_use(self):
     """Found .cs file with \"using System.Data\'"""
     Scanner.cs_file_scan(['using System.Data;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
 def test_scan_for_file_write(self):
     """Found .cs file with call to File.WriteAllText"""
     Scanner.cs_file_scan(['File.WriteAllText("foo.bar", "Some Text");'], 'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
Exemple #39
0
 def test_scan_for_file_write(self):
     """Found .cs file with call to File.WriteAllText"""
     Scanner.cs_file_scan(['File.WriteAllText("foo.bar", "Some Text");'], 'FileWrite.cs')
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
 def test_dotnet_version_not_present(self):
     """.NET framework version not in csproj file"""
     Scanner.csproj_file_scan(['    <NoFrameworkVersion></NoFrameworkVersion>'], "testfile.csproj")
     results = Scanner.scan_results
     self.assertEqual(0, len(results))
Exemple #41
0
 def setUp(self):
     Scanner.load_rules(self.TEST_RULE_FILE)
     Scanner.scan_results = []
Exemple #42
0
 def test_archive_scan(self):
     """Verify cloud readiness index for SampleWebApp-master.zip and rulebase.csv"""
     results_stats = Scanner.scan_archive(os.path.join("ephemerol", "test", "SampleWebApp-master.zip"))
     stats = results_stats[1]
     self.assertEqual(97.44, stats.cloud_readiness_index)
 def test_scan_double_hit_for_ado_net_and_odbc_use(self):
     """Found .cs file with \"using System.Data\'" and \"using System.Data.Odbc\'"""
     Scanner.cs_file_scan(['using System.Data;', 'using System.Data.Odbc;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(2, len(results))
 def test_scan_for_ef_use(self):
     """Found .cs file with \"using System.Data.Entity\'"""
     Scanner.cs_file_scan(['using System.Data;', 'using System.Data.Odbc;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(2, len(results))
Exemple #45
0
 def test_archive_scan_yaml(self):
     Scanner.load_yaml_rules(self.path_helper("rulebase.yml"))
     results_stats = Scanner.scan_archive(
         self.path_helper("SampleWebApp-master.zip"))
     self.assertEqual(97.44, results_stats.cloud_readiness_index)
Exemple #46
0
 def test_scan_for_ef_use(self):
     """Found .cs file with \"using System.Data.Entity\'"""
     Scanner.cs_file_scan(['using System.Data;', 'using System.Data.Odbc;'], 'Repository.cs')
     results = Scanner.scan_results
     self.assertEqual(2, len(results))
Exemple #47
0
 def test_has_scan_func_for_csproj(self):
     """Make sure files ending in csproj have a scan function"""
     scan_func = Scanner.get_scan_func("foobar.csproj")
     self.assertIsNotNone(scan_func)
Exemple #48
0
 def dotnet_version_tester(self, sample_data, refactor_rating):
     Scanner.csproj_file_scan([sample_data], "testfile.csproj")
     results = Scanner.scan_results
     self.assertEqual(1, len(results))
     self.assertEqual(refactor_rating, results[0].scan_item.refactor_rating)