public void Create_Update_Delete_Policy()
        {
            var newPolicy = new PolicyVersion
            {
                name        = testData.Policyname,
                description = testData.Policydescription,
                sca_blacklist_grace_period = testData.Policysca_blacklist_grace_period,
                score_grace_period         = testData.Policyscore_grace_period,
                sev0_grace_period          = testData.Policysev0_grace_period,
                sev1_grace_period          = testData.Policysev1_grace_period,
                sev2_grace_period          = testData.Policysev2_grace_period,
                sev3_grace_period          = testData.Policysev3_grace_period,
                sev4_grace_period          = testData.Policysev4_grace_period,
                sev5_grace_period          = testData.Policysev5_grace_period,
                type                 = testData.Policytype,
                vendor_policy        = testData.Policyvendor_policy,
                scan_frequency_rules = new List <ScanFrequencyRule>(),
                finding_rules        = new List <FindingRule>()
            };

            var policy = _repo.CreatePolicy(newPolicy);

            Assert.IsNotNull(policy);

            policy.name = testData.Policynameupdated;
            _           = _repo.UpdatePolicy(policy, policy.guid);

            var retrievedPolicy = _repo.GetPolicies().SingleOrDefault(x => x.name.Contains(testData.Policynameupdated));

            Assert.AreEqual(testData.Policynameupdated, retrievedPolicy.name);

            var deleted = _repo.DeletePolicy(policy.guid).SingleOrDefault(x => x.name.Contains(testData.Policynameupdated));

            Assert.IsNull(deleted);
        }
Example #2
0
 public bool CreatePolicy(ApplicationProfile app, Policy policy)
 {
     _veracodeRepository.CreatePolicy(new PolicyVersion
     {
         name        = $"{app.application_name}",
         description = $"Custom policy for application {app.application_name}",
         sca_blacklist_grace_period = policy.sca_blacklist_grace_period,
         score_grace_period         = policy.score_grace_period,
         sev0_grace_period          = policy.sev0_grace_period,
         sev1_grace_period          = policy.sev1_grace_period,
         sev2_grace_period          = policy.sev2_grace_period,
         sev3_grace_period          = policy.sev3_grace_period,
         sev4_grace_period          = policy.sev4_grace_period,
         sev5_grace_period          = policy.sev5_grace_period,
         type                 = "CUSTOMER",
         vendor_policy        = false,
         scan_frequency_rules = policy.scan_frequency_rules.Select(ConfigurationConverter.Convert).ToList(),
         finding_rules        = policy.finding_rules.Select(ConfigurationConverter.Convert).ToList(),
         created              = DateTime.Now
     });
     return(_veracodeRepository
            .GetPolicies()
            .Any(x => x.name == app.application_name));
 }