/// <summary>
        /// Parses csv to TestCases
        /// </summary>
        /// <param name="data">data parameter</param>
        /// <param name="resources">resources parameter</param>
        /// <returns>TestCase list</returns>
        public static TestCases Parse(List<List<string>> data, ResourceManager resources = null)
        {
            if (data == null || !data.Any()) { throw new ArgumentNullException("data"); }

            var rootHeader = HeaderParser.Parse(data);
            HeaderValidator.Validate(rootHeader);

            var cases = new TestCases();
            var lastStartIndex = 0;

            for (var i = HeaderParser.HeaderRowCount; i < data.Count; i++)
            {
                var row = data[i];
                if (!string.IsNullOrWhiteSpace(row[0]))
                {
                    if (i != HeaderParser.HeaderRowCount)
                    {
                        cases.Add(TestCaseParser.Parse(rootHeader, data.GetRange(lastStartIndex, i - lastStartIndex), resources));
                    }

                    lastStartIndex = i;
                }
            }

            cases.Add(TestCaseParser.Parse(rootHeader, data.GetRange(lastStartIndex, data.Count - lastStartIndex), resources));

            return cases;
        }
Example #2
0
        /// <summary>
        /// Parses csv to TestCases
        /// </summary>
        /// <param name="data">data parameter</param>
        /// <param name="resources">resources parameter</param>
        /// <returns>TestCase list</returns>
        public static TestCases Parse(List <List <string> > data, ResourceManager resources = null)
        {
            if (data == null || !data.Any())
            {
                throw new ArgumentNullException("data");
            }

            var rootHeader = HeaderParser.Parse(data);

            HeaderValidator.Validate(rootHeader);

            var cases          = new TestCases();
            var lastStartIndex = 0;

            for (var i = HeaderParser.HeaderRowCount; i < data.Count; i++)
            {
                var row = data[i];
                if (!string.IsNullOrWhiteSpace(row[0]))
                {
                    if (i != HeaderParser.HeaderRowCount)
                    {
                        cases.Add(TestCaseParser.Parse(rootHeader, data.GetRange(lastStartIndex, i - lastStartIndex), resources));
                    }

                    lastStartIndex = i;
                }
            }

            cases.Add(TestCaseParser.Parse(rootHeader, data.GetRange(lastStartIndex, data.Count - lastStartIndex), resources));

            return(cases);
        }
Example #3
0
            /// <summary>
            /// The init.
            /// </summary>
            /// <param name="currentcontext">
            /// The current context.
            /// </param>
            /// <param name="target">
            /// The target.
            /// </param>
            public override void Init(IContext currentcontext, ITarget target)
            {
                base.Init(currentcontext, target);

                TestCases.Clear();

                TestCases.Add(
                    new TestCase
                {
                    TestName        = TimingTestCase,
                    InjectionString =
                        new[]
                    {
                        "%20and%201%20in%20(select%20SLEEP(10))"
                    },
                    FilterResponseContentType = new[] { "text/html" }
                });

                TestCases.Add(
                    new TestCase
                {
                    TestName        = SqlErrorTestCase,
                    InjectionString =
                        new[]
                    {
                        "%20or%201%20=%201"
                    },
                    FilterResponseContentType = new[] { "text/html" }
                });
            }
Example #4
0
        void Discovery_TestCaseDiscoveryMessageEvent(MessageHandlerArgs <ITestCaseDiscoveryMessage> args)
        {
            var testCaseDiscovered = args.Message;
            var testCase           = testCaseDiscovered.TestCase;

            if (string.IsNullOrEmpty(testCase.SkipReason)) /* TODO: Currently there are not filters */
            {
                var testMethod     = testCaseDiscovered.TestMethod;
                var metrics        = new List <PerformanceMetricInfo>();
                var attributesInfo = GetMetricAttributes(testMethod);

                foreach (var attributeInfo in attributesInfo)
                {
                    var assemblyQualifiedAttributeTypeName = typeof(PerformanceMetricDiscovererAttribute).AssemblyQualifiedName;
                    var discovererAttr = attributeInfo.GetCustomAttributes(assemblyQualifiedAttributeTypeName).FirstOrDefault();
                    var discoverer     = GetPerformanceMetricDiscoverer(discovererAttr);
                    metrics.AddRange(discoverer.GetMetrics(attributeInfo));
                }

                if (metrics.Count > 0)
                {
                    TestCases.Add(args.Message.TestCase);
                    Tests.Add(new PerformanceTestMessage
                    {
                        TestCase = testCaseDiscovered.TestCase,
                        Metrics  = metrics
                    });
                }
            }
        }
Example #5
0
        static partial void SetPublicDemoDataTwitterOAuth1()
        {
            oauth1 = new Xamarin.Auth._MobileServices.Helpers.OAuth1()
            {
                Description = "Twitter OAuth1",
                OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer = "",
                OAuth1_SecretKey_ConsumerSecret_APISecret            = "",
                OAuth1_UriRequestToken       = new Uri("https://api.twitter.com/oauth/request_token"),
                OAuth_UriAuthorization       = new Uri("https://api.twitter.com/oauth/authorize"),
                OAuth_UriCallbackAKARedirect = new Uri("http://xamarin.com"),
                OAuth1_UriAccessToken        = new Uri("https://api.twitter.com/oauth/access_token"),
                AllowCancel = true,
            };

            if (TestCases.ContainsKey(oauth1.Description))
            {
                TestCases[oauth1.Description] = oauth1;
            }
            else
            {
                TestCases.Add(oauth1.Description, oauth1);
            }

            return;
        }
Example #6
0
        public void Initialize()
        {
            localRepository.Initialize();
            s3Repository.Initialize();
            mongodbRepository.Initialize();

            var localMetadata = UseLocalStorage ? localRepository.GetDocumentsMetadata().ToDictionary(e => e.DocumentKey, e => e)
                : new Dictionary <string, Metadata>();
            var s3Metadata = UseS3Storage ? s3Repository.GetDocumentsMetadata().ToDictionary(e => e.DocumentKey, e => e)
                : new Dictionary <string, Metadata>();
            var mongoDB = UseMongoDBStorage ? mongodbRepository.GetDocumentsMetadata().ToDictionary(e => e.DocumentKey, e => e)
                : new Dictionary <string, Metadata>();

            var createTestCaseViewModel = new Func <Metadata, bool, bool, bool, TestCaseViewModel>((m, e1, e2, e3) =>
            {
                var vm              = new TestCaseViewModel(m, e1, e2, e3);
                vm.PropertyChanged += OnTestCasePropertyChanged;
                return(vm);
            });

            foreach (var key in localMetadata.Keys)
            {
                TestCases.Add(createTestCaseViewModel(localMetadata[key], true, s3Metadata.ContainsKey(key), mongoDB.ContainsKey(key)));
            }
            foreach (var key in s3Metadata.Keys.Except(localMetadata.Keys))
            {
                TestCases.Add(createTestCaseViewModel(s3Metadata[key], false, true, mongoDB.ContainsKey(key)));
            }
            foreach (var key in mongoDB.Keys.Except(localMetadata.Keys).Except(s3Metadata.Keys))
            {
                TestCases.Add(createTestCaseViewModel(mongoDB[key], false, false, true));
            }
        }
        static partial void SetPublicDemoDataMicrosoftLiveOAuth2()
        {
            oauth2 = new Xamarin.Auth._MobileServices.Helpers.OAuth2()
            {
                Description = "Microsoft Live OAuth2",

                /*
                 * clientId: "<MyclientI>",
                 * scope: "wl.basic, wl.signin, wl.offline_access",
                 * authorizeUrl: new Uri(""https://login.live.com/oauth20_authorize.srf"),
                 * redirectUrl: new Uri("https://login.live.com/oauth20_desktop.srf"))
                 */
                OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer = "",
                OAuth2_Scope                 = "wl.basic, wl.signin, wl.offline_access",
                OAuth_UriAuthorization       = new Uri("https://login.live.com/oauth20_authorize.srf"),
                OAuth_UriCallbackAKARedirect = new Uri("http://xamarin.com"),
                AllowCancel = true,
            };

            if (TestCases.ContainsKey(oauth2.Description))
            {
                TestCases[oauth2.Description] = oauth2;
            }
            else
            {
                TestCases.Add(oauth2.Description, oauth2);
            }

            return;
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestDiscoverySink"/> class.
        /// </summary>
        /// <param name="cancelThunk">An optional thunk which can be used to control cancellation.</param>
        public TestDiscoverySink(Func <bool> cancelThunk = null)
        {
            this.cancelThunk = cancelThunk ?? (() => false);

            discoverySink.TestCaseDiscoveryMessageEvent += args => TestCases.Add(args.Message.TestCase);
            discoverySink.DiscoveryCompleteMessageEvent += args => Finished.Set();
        }
 protected virtual void OnToggelUnlock()
 {
     if (IsLocked)
     {
         var output = ProblemSpecification.GetCorrectOutput(Password);
         if (output == null)
         {
             StateText = "Failed to unlock!";
             State     = ProblemState.FailedToSolve;
         }
         else
         {
             StateText = "Problem unlocked!";
             State     = ProblemState.Solved;
             TestCases.Clear();
             for (int i = 0; i < ProblemSpecification.TestInput.Length; i++)
             {
                 var tc = new TestCaseViewModel();
                 tc.Input  = ProblemSpecification.TestInput[i];
                 tc.Output = output[i];
                 TestCases.Add(tc);
             }
         }
     }
     else
     {
         StateText = "Problem locked!";
         TestCases.Clear();
         Password = "";
         State    = ProblemState.NotTested;
         IsNew    = false;
     }
 }
Example #10
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string newTestName;

            for (int testId = 1; ; ++testId)
            {
                newTestName = "case" + testId;
                if (!TestCases.Any(t => StringComparer.CurrentCultureIgnoreCase.Equals(newTestName, t.Name)))
                {
                    break;
                }
            }

            var newTestCase = new TestCase
            {
                Name          = newTestName,
                Input         = "",
                Output        = "",
                IsEnabled     = true,
                OutputIsKnown = true,
            };

            TestCases.Add(newTestCase);
            lstTestCases.SelectedItem = newTestCase;
        }
Example #11
0
        public TestsViewModel()
        {
            var assemblyFileName = Assembly.GetEntryAssembly().Location;

            // TODO: currently we disable app domain otherwise GameTestBase.ForceInteractiveMode is not kept
            //       we should find another way to transfer this parameter
            Controller = new XunitFrontController(AppDomainSupport.Denied, assemblyFileName);
            var sink = new TestDiscoverySink();

            Controller.Find(true, sink, TestFrameworkOptions.ForDiscovery());
            sink.Finished.WaitOne();

            var testAssemblyViewModel = new TestGroupViewModel(this, sink.TestCases.FirstOrDefault()?.TestMethod.TestClass.TestCollection.TestAssembly.Assembly.Name ?? "No tests were found");

            foreach (var testClass in sink.TestCases.GroupBy(x => x.TestMethod.TestClass))
            {
                var testClassViewModel = new TestGroupViewModel(this, testClass.Key.Class.Name);
                testAssemblyViewModel.Children.Add(testClassViewModel);
                foreach (var testCase in testClass)
                {
                    testClassViewModel.Children.Add(new TestCaseViewModel(this, testCase));
                }
            }
            TestCases.Add(testAssemblyViewModel);
        }
        static partial void SetPublicDemoDataGoogleOAuth2()
        {
            // https://www.snip2code.com/Snippet/245686/Xamarin-Google-and-Facebook-authenticati

            /*
             *      clientId: "123456789.apps.googleusercontent.com",
             *      scope: "https://www.googleapis.com/auth/userinfo.email",
             *      authorizeUrl: new Uri ("https://accounts.google.com/o/oauth2/auth"),
             *      redirectUrl: new Uri ("http://bunchy.com/oauth2callback"),
             *      getUsernameAsync: null)
             */
            oauth2 = new Xamarin.Auth.Helpers.OAuth2()
            {
                Description = "Google OAuth2",
                OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer = "",
                OAuth2_Scope                 = "https://www.googleapis.com/auth/userinfo.email",
                OAuth_UriAuthorization       = new Uri("https://accounts.google.com/o/oauth2/auth"),
                OAuth_UriCallbackAKARedirect = new Uri("http://xamarin.com"),
                AllowCancel = true,
            };

            if (TestCases.ContainsKey(oauth2.Description))
            {
                TestCases[oauth2.Description] = oauth2;
            }
            else
            {
                TestCases.Add(oauth2.Description, oauth2);
            }

            return;
        }
Example #13
0
        /// <summary>
        /// Loads test cases.
        /// </summary>
        public async Task LoadAsync(ITfsProjectWorkItemCollection projectworkItemCollection)
        {
            TestCases.Clear();
            var progress = new Progress <ITestCaseViewModel>(testCase => TestCases.Add(testCase));

            await QueryTestCases(projectworkItemCollection, progress);
        }
Example #14
0
 /// <summary>
 /// Initializer for the test plugin - the test manager will invoke this at the start of a test
 /// run. Tests that override this method must be sure to call the base.Init function, to ensure
 /// that the base class has the context, target, and results objects created and available, and
 /// if using the default DoTests function would add test case objects to the test cases collection
 /// (which the default DoTests function will use).
 /// </summary>
 /// <param name="currentcontext">
 /// The current context.
 /// </param>
 /// <param name="target">
 /// The target.
 /// </param>
 /// <seealso cref="M:BackScatterScannerLib.Engine.TestBase.Init(IContext,ITarget)"/>
 public override void Init(IContext currentcontext, ITarget target)
 {
     base.Init(currentcontext, target);
     TestCases.Add(new TestCase
     {
         TestName        = "Open Redirect",
         InjectionString = TestBaseHelper.LoadTestCase("OpenRedirectTester", Context).ToArray()
     });
 }
Example #15
0
        private void AppendTestCase(TestCase tc)
        {
            int    index = CalculateNextTestCaseId();
            string name  = String.Format("TC{0}", index);

            tc.Name = name;
            TestCases.Add(tc);
            tc.DisplayIndex = TestCases.Count; // displayindex includes first column action or condition
        }
Example #16
0
 /// <summary>
 /// The init.
 /// </summary>
 /// <param name="currentcontext">
 /// The current context.
 /// </param>
 /// <param name="target">
 /// The target.
 /// </param>
 public override void Init(IContext currentcontext, ITarget target)
 {
     base.Init(currentcontext, target);
     TestCases.Add(new TestCase
     {
         TestName        = "Possible null injection",
         InjectionString = TestBaseHelper.LoadTestCase("NullInjectionTester", Context).ToArray()
     });
 }
        public void SetSolution(TestResult result)
        {
            switch (result.Result)
            {
            case TestResultType.AC:
                string password = ProblemSpecification.GetPassword(result.Output);
                if (password == null)
                {
                    StateText = string.Format("Error in problem file or the probelem have no test cases. Must Be accepted. Time:{0} Memory:{1}", result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                    State     = ProblemState.FailedToSolve;
                }
                else
                {
                    TestCases.Clear();
                    for (int i = 0; i < ProblemSpecification.TestInput.Length; i++)
                    {
                        var tc = new TestCaseViewModel();
                        tc.Input  = ProblemSpecification.TestInput[i];
                        tc.Output = result.Output[i];
                        TestCases.Add(tc);
                    }
                    Password  = password;
                    State     = ProblemState.Solved;
                    StateText = string.Format("Accepted!! Time:{0} Memory:{1}", result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                }
                break;

            case TestResultType.WA:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Wrong answer on testcase {0}!! Time:{1} Memory:{2}", result.Output.Length, result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                break;

            case TestResultType.CTE:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Compile time error!! compiler output:{0}", result.CompilerOutput);
                break;

            case TestResultType.RTE:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Run-time error on testcase {0}!! Time:{1} Memory:{2}", result.Output.Length, result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                break;

            case TestResultType.TLE:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Time limit ecceded on testcase {0}!! Time:{1} Memory:{2}", result.Output.Length, result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                break;

            case TestResultType.MLE:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Memory limit ecceded on testcase {0}!! Time:{1} Memory:{2}", result.Output.Length, result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// Initializer for the test plugin - the test manager will invoke this at the start of a test
        /// run. Tests that override this method must be sure to call the base.Init function, to ensure
        /// that the base class has the context, target, and results objects created and available, and
        /// if using the default DoTests function would add test case objects to the test cases collection
        /// (which the default DoTests function will use).
        /// </summary>
        /// <param name="currentcontext">
        /// The current context.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <seealso cref="M:BackScatterScannerLib.Engine.TestBase.Init(IContext,ITarget)"/>
        public override void Init(IContext currentcontext, ITarget target)
        {
            base.Init(currentcontext, target);

            TestCases.Add(new TestCase
            {
                TestName                  = "DT Injection",
                InjectionString           = TestBaseHelper.LoadTestCase("DirectoryTraversalTest", Context).ToArray(),
                FilterResponseContentType = new[] { "text/html" }
            });
        }
Example #19
0
 /// <summary>
 /// The init.
 /// </summary>
 /// <param name="currentcontext">
 /// The current context.
 /// </param>
 /// <param name="target">
 /// The target.
 /// </param>
 public override void Init(IContext currentcontext, ITarget target)
 {
     base.Init(currentcontext, target);
     TestCases.Add(new TestCase
     {
         TestName = "Random cookie strings",
         InjectionCookieCallBack = FuzzCookies,
         SaveRequestCookies      = false,
         InjectionString         = new[] { "microsoft" }
     });
 }
Example #20
0
        public virtual TestCase AddTestCase(string testCaseName)
        {
            var newTestCase = new TestCase
            {
                PatternScreenshotName = testCaseName,
                Category = this,
                Project  = this.Project
            };

            TestCases.Add(newTestCase);
            return(newTestCase);
        }
Example #21
0
        /// <summary>
        /// The init.
        /// </summary>
        /// <param name="currentcontext">
        /// The current context.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        public override void Init(IContext currentcontext, ITarget target)
        {
            base.Init(currentcontext, target);

            // the vulns will be catch by the error detector, so no action for check vulns in this test
            TestCases.Add(new TestCase
            {
                TestName             = "Integer overflow - MaxInt+1/MaxLong+1",
                InjectionString      = TestBaseHelper.LoadTestCase("IntOverflowTester", Context).ToArray(),
                FuzzOnlyNumericParam = true
            });
        }
Example #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestDiscoverySink"/> class.
        /// </summary>
        /// <param name="cancelThunk">An optional thunk which can be used to control cancellation.</param>
        public TestDiscoverySink(Func <bool>?cancelThunk = null)
        {
            this.cancelThunk = cancelThunk ?? (() => false);

            DiscoverySink.TestCaseDiscoveredEvent += args =>
            {
                Guard.ArgumentNotNull(args);

                TestCases.Add(args.Message);
            };

            DiscoverySink.DiscoveryCompleteEvent += args => Finished.Set();
        }
Example #23
0
 /// <summary>
 /// Initializer for the test plugin - the test manager will invoke this at the start of a test
 /// run. Tests that override this method must be sure to call the base.Init function, to ensure
 /// that the base class has the context, target, and results objects created and available, and
 /// if using the default DoTests function would add test case objects to the test cases collection
 /// (which the default DoTests function will use).
 /// </summary>
 /// <param name="currentcontext">
 /// The current context.
 /// </param>
 /// <param name="target">
 /// The target.
 /// </param>
 /// <seealso cref="M:BackScatterScannerLib.Engine.TestBase.Init(IContext,ITarget)"/>
 public override void Init(IContext currentcontext, ITarget target)
 {
     base.Init(currentcontext, target);
     TestCases.Add(new TestCase
     {
         InjectionString = new[]
         {
             @"\r\nFrom:%[email protected]",
             @"%0d%0aFrom:%[email protected]",
             @"%%0d0d%%0a0aFrom:%[email protected]",
             @"%00%0d%0a0a0aFrom:%[email protected]",
             @"%250d%0a0aFrom:%[email protected]"
         }
     });
 }
Example #24
0
        public bool OnMessageWithTypes(IMessageSinkMessage message, HashSet <string> messageTypes)
        {
            switch (message)
            {
            case IDiscoveryCompleteMessage _:
                DiscoveryComplete.Set();
                break;

            case ITestCaseDiscoveryMessage testCaseDiscoveryMessage:
                TestCases.Add(testCaseDiscoveryMessage.TestCase);
                break;
            }

            return(true);
        }
Example #25
0
        static partial void SetPublicDemoDataLinkedInOAuth2()
        {
            /*
             * https://www.linkedin.com/secure/developer
             * https://developer.linkedin.com/docs/oauth2
             * https://developer.linkedin.com/docs/
             * https://developer.linkedin.com/docs/signin-with-linkedin
             *
             *
             * http://forums.xamarin.com/discussion/14883/login-with-linkedin
             * https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=***"
             *
             * http://forums.xamarin.com/discussion/25457/xamarin-auth
             *
             * TODO: need testing... not quite correct
             *
             */
            oauth2 = new Xamarin.Auth._MobileServices.Helpers.OAuth2()
            {
                Description = "LinkedIn OAuth2",
                OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer = "",
                OAuth2_Scope           = "r_basicprofile",
                OAuth_UriAuthorization =
                    new Uri
                    (
                        "https://www.linkedin.com/uas/oauth2/authorization?response_type=code"
                        +
                        "&client_id=" + ""
                        +
                        "&scope=" + Uri.EscapeDataString("r_basicprofile")
                        +
                        "&redirect_uri=" + Uri.EscapeDataString("https://xamarin.com/")
                    ),
                OAuth_UriCallbackAKARedirect = new Uri("https://xamarin.com/"),
                AllowCancel = true,
            };

            if (TestCases.ContainsKey(oauth2.Description))
            {
                TestCases[oauth2.Description] = oauth2;
            }
            else
            {
                TestCases.Add(oauth2.Description, oauth2);
            }

            return;
        }
        /// <summary>
        /// Initializer for the test plugin - the test manager will invoke this at the start of a test
        /// run. Tests that override this method must be sure to call the base.Init function, to ensure
        /// that the base class has the context, target, and results objects created and available, and
        /// if using the default DoTests function would add test case objects to the test cases collection
        /// (which the default DoTests function will use).
        /// </summary>
        /// <param name="currentcontext">
        /// The current context.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <seealso cref="M:BackScatterScannerLib.Engine.TestBase.Init(IContext,ITarget)"/>
        public override void Init(IContext currentcontext, ITarget target)
        {
            base.Init(currentcontext, target);

            TestCases.Add(new TestCase
            {
                TestName        = "SSI Injection",
                InjectionString = new[]
                {
                    "<!--#INCLUDE VIRTUAL=\"/web.config\"-->",
                    "<!--#exec cmd=\"ls\" -->",
                    "<!--#exec cmd=\"dir\" -->"
                },
                FilterResponseContentType = new[] { "text/html" }
            });
        }
Example #27
0
        private void Client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            IsSearching = false;
            TestCases.Clear();
            try
            {
                Result = Encoding.UTF8.GetString(e.Result);
            }
            catch (Exception)
            {
                this.ShowMessageEvent?.Invoke(this, "AI engine is not working now! Please try again later.");
                return;
            }

            var testCase = JsonConvert.DeserializeObject <TestCase>(Result);

            TestCases.Add(testCase);
        }
        private void Clone_Clicked(object source, RoutedEventArgs e)
        {
            Button btn = (Button)source;

            if (btn != null)
            {
                ITestCase testCase = btn.DataContext as ITestCase;
                if (testCase != null)
                {
                    ITestCase clone_case = testCase.Clone() as ITestCase;
                    if (clone_case != null)
                    {
                        TestCases.Add(clone_case);
                        Document.AddTestCase(clone_case);
                        Document.TestSuiteSaver.SaveSuite();
                    }
                }
            }
        }
Example #29
0
            protected override bool Visit(ITestCaseDiscoveryMessage testCaseDiscovered)
            {
                var testCase = testCaseDiscovered.TestCase;

                TestCases.Add(new TestCaseViewModel(discoverer.Serialize(testCase), testCase.DisplayName, testCaseDiscovered.TestAssembly.Assembly.AssemblyPath));

                foreach (var k in testCase.Traits.Keys)
                {
                    IList <string> value;
                    if (!Traits.TryGetValue(k, out value))
                    {
                        value     = new List <string>();
                        Traits[k] = value;
                    }

                    value.AddRange(testCase.Traits[k]);
                }

                return(true);
            }
        private void OnLoadBatchInpputTestFile()
        {
            var str = OpenTextBatch();
            int i   = 0;

            for (int j = 0; j < TestCases.Count; j++)
            {
                if (!string.IsNullOrEmpty(TestCases[j].Input))
                {
                    continue;
                }
                TestCases[j].Input = str[i];
            }
            for (; i < str.Length; i++)
            {
                TestCaseViewModel ts = new TestCaseViewModel();
                ts.Input = str[i];
                TestCases.Add(ts);
            }
        }
Example #31
0
        /// <summary>
        /// Initializer for the test plugin - the test manager will invoke this at the start of a test
        /// run. Tests that override this method must be sure to call the base.Init function, to ensure
        /// that the base class has the context, target, and results objects created and available, and
        /// if using the default DoTests function would add test case objects to the test cases collection
        /// (which the default DoTests function will use).
        /// </summary>
        /// <param name="currentcontext">
        /// The current context.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <seealso cref="M:BackScatterScannerLib.Engine.TestBase.Init(IContext,ITarget)"/>
        public override void Init(IContext currentcontext, ITarget target)
        {
            base.Init(currentcontext, target);

            TestCases.Add(
                new TestCase
            {
                TestName                  = SqlErrorTestCase,
                InjectionString           = TestBaseHelper.LoadTestCase("SqlInjectionErrorTestCase", Context).ToArray(),
                FilterResponseContentType = new[] { "text/html" }
            });

            // time delay 14s choose based on the http request timeout that we have now in the system
            TestCases.Add(
                new TestCase
            {
                TestName                  = TimingTestCase,
                InjectionString           = TestBaseHelper.LoadTestCase("SqlInjectionTimingTestCase", Context).ToArray(),
                FilterResponseContentType = new[] { "text/html" }
            });
        }