/// <summary> /// Creates a test argument. /// </summary> private Test CreateWebUnitTest() { IHtmlFormUnitTestArgs args = null; Test test = new Test(); test.UnitTestDataType = GetUnitTestDataType(); #region Buffer Overflow Settings if ( this.rbBufferOverflow.Checked ) { args = new BufferOverflowTesterArgs(); ((BufferOverflowTesterArgs)args).BufferLength = (int)this.numBufferLen.Value; test.TestType = UnitTestType.BufferOverflow; test.TestTypeName = "Buffer Overflow Test"; test.Name = this.txtTestName.Text; test.Arguments = args; } #endregion #region Data Type Settings if ( this.rbDataType.Checked ) { args = new DataTypesTesterArgs(); ((DataTypesTesterArgs)args).SelectedDataType = (DataType)dataTypesList.GetKey(dataTypesList.IndexOfValue(this.cmbDataType.Text)); test.TestType= UnitTestType.DataTypes; test.TestTypeName = "Data Type Test"; test.Name = this.txtTestName.Text; test.Arguments = args; } #endregion #region SQL Injection Settings if ( this.rbSqlTest.Checked ) { args = new SqlInjectionTesterArgs(); ((SqlInjectionTesterArgs)args).SqlValue = this.cmbSqlTestValues.Text; test.TestType = UnitTestType.SqlInjection; test.TestTypeName = "SQL Injection Test"; test.Name = this.txtTestName.Text; test.Arguments = args; } #endregion #region XSS Settings if ( this.rbXSSTest.Checked ) { args = new XssInjectionTesterArgs(); ((XssInjectionTesterArgs)args).XssValue = this.cmbXssTestValues.Text; test.TestType = UnitTestType.XSS; test.TestTypeName = "XSS Injection Test"; test.Name = this.txtTestName.Text; test.Arguments = args; } #endregion #region Predefined Post Data Test if ( this.rbPredefined.Checked ) { args = new PredefinedTesterArgs(); PredefinedTesterArgs predefinedArgs = (PredefinedTesterArgs)args; if ( this.rbForm.Checked ) { predefinedArgs.FormData = this.WebSessionRequest.Form; } else { // TODO: Change to PostDataCollection method. FormConverter formConverter = new FormConverter(); predefinedArgs.UserPostData = formConverter.GetPostDataCollection(((PostSessionRequest)this.WebSessionRequest).PostData); } test.TestType = UnitTestType.Predefined; test.TestTypeName = "Predefined Test"; test.Name = this.txtTestName.Text; test.Arguments = args; } #endregion return test; }
private void CreateArgument() { IHtmlFormUnitTestArgs args = null; switch ( this.tabTests.SelectedTab.Name ) { case "tabBufferOverflow": args = new BufferOverflowTesterArgs(); ((BufferOverflowTesterArgs)args).BufferLength = (int)this.numBufferLen.Value; this.HtmlFormTestType = UnitTestType.BufferOverflow; this.TestType = "Buffer Overflow Test"; this.TestName = this.txtBufferTestName.Text; this.TestArgs = args; break; case "tabDataTypes": args = new DataTypesTesterArgs(); ((DataTypesTesterArgs)args).SelectedDataType = (DataType)dataTypesList.GetKey(dataTypesList.IndexOfValue(this.cmbDataType.Text)); this.HtmlFormTestType = UnitTestType.DataTypes; this.TestType = "Data Type Test"; this.TestName = this.txtDataTypeTestName.Text; this.TestArgs = args; break; case "tabSqlInjection": args = new SqlInjectionTesterArgs(); ((SqlInjectionTesterArgs)args).SqlValue = this.cmbSqlTestValues.Text; this.HtmlFormTestType = UnitTestType.SqlInjection; this.TestType = "SQL Injection Test"; this.TestName = this.txtSqlTestName.Text; this.TestArgs = args; break; case "tabXssInjection": args = new XssInjectionTesterArgs(); ((XssInjectionTesterArgs)args).XssValue = this.cmbXssTestValues.Text; this.HtmlFormTestType = UnitTestType.XSS; this.TestType = "XSS Injection Test"; this.TestName = this.txtXssTestName.Text; this.TestArgs = args; break; case "tabPredefinedTest": args = new PredefinedTesterArgs(); this.HtmlFormTestType = UnitTestType.Predefined; this.TestType = "Predefined Test"; this.TestName = this.txtPredfinedTestName.Text; this.TestArgs = args; break; } }