示例#1
0
        public void WebServices_RestAction()
        {
            ActREST a2 = new ActREST();

            try
            {
                a2.RequestType                = ActREST.eRequestType.GET;
                a2.ReqHttpVersion             = ActREST.eHttpVersion.HTTPV11;
                a2.ContentType                = ActREST.eContentType.JSon;
                a2.CookieMode                 = ActREST.eCookieMode.None;
                a2.SecurityType               = ActREST.eSercurityType.None;
                a2.EndPointURL.ValueForDriver = "https://reqres.in/api/users/2";

                //Act
                a2.AddNewReturnParams = true;
                a2.Execute();
            }
            finally
            {
                //running validation only in case of success
                if (((int)a2.ResponseCode).ToString().StartsWith("2"))
                {
                    Assert.AreEqual(17, a2.ReturnValues.Count);


                    Assert.AreEqual("Weaver", a2.ReturnValues.Where(x => x.Param == "last_name").First().Actual);
                }
            }
        }
示例#2
0
        public void Rest1()
        {
            ActREST a2 = new ActREST();

            a2.RequestType    = ActREST.eRequestType.GET;
            a2.ReqHttpVersion = ActREST.eHttpVersion.HTTPV10;
            //a2.ContentType = ActREST.eContentType.TextPlain;
            a2.ContentType  = ActREST.eContentType.JSon;
            a2.CookieMode   = ActREST.eCookieMode.None;
            a2.SecurityType = ActREST.eSercurityType.None;
            a2.EndPointURL.ValueForDriver = "https://jsonplaceholder.typicode.com/posts/1";

            //Act
            a2.Execute();

            if (a2.ReturnValues.Count > 0)
            {
                foreach (ActReturnValue val in a2.ReturnValues)
                {
                    if (val.Actual.ToString() == "OK")
                    {
                        Assert.AreEqual(val.Actual, "OK");
                    }
                }
            }
        }
示例#3
0
        public ActRESTEditPage(ActREST a)
        {
            InitializeComponent();

            mActREST = a;
            URLUCValueExpression.Init(Context.GetAsContext(mActREST.Context), mActREST.EndPointURL);
            URLDomainUCValueExpression.Init(Context.GetAsContext(mActREST.Context), mActREST.URLDomain, nameof(ActInputValue.Value));
            URLPasswordUCValueExpression.Init(Context.GetAsContext(mActREST.Context), mActREST.URLPass, nameof(ActInputValue.Value));
            URLUserUCValueExpression.Init(Context.GetAsContext(mActREST.Context), mActREST.URLUser, nameof(ActInputValue.Value));
            RequestBodyUCValueExpression.Init(Context.GetAsContext(mActREST.Context), mActREST.RequestBody);
            RequestRespondXmlSaveTextBox.Init(Context.GetAsContext(mActREST.Context), mActREST.SaveRequestResponseFolderPath);

            TemplateFileNameFileBrowser.Init(Context.GetAsContext(mActREST.Context), mActREST.TemplateFile);
            GingerCore.General.FillComboFromEnumObj(RequestTypeComboBox, mActREST.RequestType);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(RequestTypeComboBox, ComboBox.TextProperty, mActREST, ActREST.Fields.RequestType);

            //httpversion content type
            GingerCore.General.FillComboFromEnumObj(HttpVersioncombobox, mActREST.ReqHttpVersion);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(HttpVersioncombobox, ComboBox.SelectedValueProperty, mActREST, ActREST.Fields.ReqHttpVersion);

            //Request content type
            GingerCore.General.FillComboFromEnumObj(ContentTypeComboBox, mActREST.ContentType);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(ContentTypeComboBox, ComboBox.SelectedValueProperty, mActREST, ActREST.Fields.ContentType);

            //Response Content Type
            GingerCore.General.FillComboFromEnumObj(ResponseTypeComboBox, mActREST.ResponseContentType);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(ResponseTypeComboBox, ComboBox.SelectedValueProperty, mActREST, ActREST.Fields.ResponseContentType);
            //Security Type
            GingerCore.General.FillComboFromEnumObj(SecurityTypeComboBox, mActREST.SecurityType);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(SecurityTypeComboBox, ComboBox.SelectedValueProperty, mActREST, ActREST.Fields.SecurityType);

            //Cookie Mode
            GingerCore.General.FillComboFromEnumObj(CookieMode, mActREST.CookieMode);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(CookieMode, ComboBox.SelectedValueProperty, mActREST, ActREST.Fields.CookieMode);

            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(restRequest, CheckBox.IsCheckedProperty, mActREST, ActREST.Fields.RestRequestSave);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(restResponse, CheckBox.IsCheckedProperty, mActREST, ActREST.Fields.RestResponseSave);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(templateFileRadioBtn, RadioButton.IsCheckedProperty, mActREST, ActREST.Fields.UseRequestBody);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(freeBodyRadioBtn, RadioButton.IsCheckedProperty, mActREST, ActREST.Fields.UseTemplateFile);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(RestFailActionOnBadRespose, CheckBox.IsCheckedProperty, mActREST, ActREST.Fields.DoNotFailActionOnBadRespose);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(AcceptAllSSLCertificate, CheckBox.IsCheckedProperty, mActREST, ActREST.Fields.AcceptAllSSLCertificate);

            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xUseLegacyJSONParsingCheckBox, CheckBox.IsCheckedProperty, mActREST, ActREST.Fields.UseLegacyJSONParsing);

            SetDynamicGrid();

            DynamicElementsGrid.btnAdd.AddHandler(Button.ClickEvent, new RoutedEventHandler(AddDynamicXMLelement));

            SetHeadersGrid();
            HttpHeadersGrid.btnAdd.AddHandler(Button.ClickEvent, new RoutedEventHandler(AddHttpHeader));
        }
示例#4
0
        public void WebServices_RestAction()
        {
            ActREST a2 = new ActREST();

            a2.RequestType                = ActREST.eRequestType.GET;
            a2.ReqHttpVersion             = ActREST.eHttpVersion.HTTPV11;
            a2.ContentType                = ActREST.eContentType.JSon;
            a2.CookieMode                 = ActREST.eCookieMode.None;
            a2.SecurityType               = ActREST.eSercurityType.None;
            a2.EndPointURL.ValueForDriver = "https://reqres.in/api/users/2";

            //Act
            a2.AddNewReturnParams = true;
            a2.Execute();

            Assert.AreEqual(17, a2.ReturnValues.Count);


            Assert.AreEqual("Weaver", a2.ReturnValues.Where(x => x.Param == "last_name").First().Actual);
        }
示例#5
0
        public void LegacyRestActionToNewWebApiRest_Converter_Test()
        {
            Activity oldActivity = new Activity();

            oldActivity.Active       = true;
            oldActivity.ActivityName = "Legacy Rest Service activity";
            oldActivity.CurrentAgent = wsAgent;
            mBF.Activities.Add(oldActivity);

            ActREST actLegacyRestService = new ActREST();

            actLegacyRestService.AddOrUpdateInputParamValue(ActREST.Fields.RequestType, ActREST.eRequestType.GET.ToString());
            actLegacyRestService.AddOrUpdateInputParamValue(ActREST.Fields.ReqHttpVersion, ActREST.eHttpVersion.HTTPV10.ToString());
            actLegacyRestService.AddOrUpdateInputParamValue(ActREST.Fields.ContentType, ActREST.eContentType.JSon.ToString());
            actLegacyRestService.AddOrUpdateInputParamValue(ActREST.Fields.CookieMode, ActREST.eCookieMode.None.ToString());
            actLegacyRestService.AddOrUpdateInputParamValue(ActREST.Fields.SecurityType, ActREST.eSercurityType.None.ToString());
            actLegacyRestService.AddOrUpdateInputParamValue(ActREST.Fields.EndPointURL, @"https://jsonplaceholder.typicode.com/posts/1");

            actLegacyRestService.FileName           = "Web Rest Action";
            actLegacyRestService.FilePath           = "Web Rest Action";
            actLegacyRestService.Active             = true;
            actLegacyRestService.AddNewReturnParams = true;

            mBF.Activities[0].Acts.Add(actLegacyRestService);
            mDriver.StartDriver();
            mGR.RunRunner();

            //Assert old action
            Assert.AreNotEqual(0, actLegacyRestService.ReturnValues.Count);
            var expected = actLegacyRestService.ReturnValues.FirstOrDefault(x => x.Actual == "OK");

            Assert.AreNotEqual(null, expected);

            //Convert the legacy action
            Activity newActivity = new Activity()
            {
                Active = true
            };

            newActivity.ActivityName = "New - " + oldActivity.ActivityName;
            newActivity.CurrentAgent = wsAgent;
            mBF.Activities.Add(newActivity);

            Act newAction = ((IObsoleteAction)actLegacyRestService).GetNewAction();

            newAction.AddNewReturnParams = true;
            newAction.Active             = true;
            newAction.ItemName           = "Converted webapiRest action";
            newActivity.Acts.Add((ActWebAPIRest)newAction);
            mBF.Activities[1].Acts.Add(newAction);

            //Assert converted action
            Assert.AreNotEqual(0, newAction.ReturnValues.Count);
            var expected1 = newAction.ReturnValues.FirstOrDefault(x => x.Actual == "OK");

            Assert.AreNotEqual(null, expected1);

            //Run newAction
            mGR.RunRunner();

            //assert newaction
            Assert.AreNotEqual(0, newAction.ReturnValues.Count);
            var expected2 = newAction.ReturnValues.FirstOrDefault(x => x.Actual == "OK");

            Assert.AreNotEqual(null, expected2);
        }