Search code examples
c#visual-studioeggplant

How to submit a string in a Request using C# for Eggplant Performance


Greeting for 2022.

I am currently evaluating a performance tool called Eggplant performance using a C#.

The application I am testing against has a user set password that requires me to insert certain random characters of my password.

Example: Password = password1 Then the application will make me insert 3characters of my password randomly.

Each required field gets an ID that is between 7-9 characters long, but always longer than 6 and shorter than 10.

The payload down the wire then looks like this:

B806b8220=s&e210cdd9=s&cd5d5105=d&landingpage=express etc.

I have been able to do the work correlating those fields and and getting the logic around that.

What I am struggling with, and it is because I do not have a dev background is submitting this back down the wire.

The correlated build up value looks like below:

Passphrase is set as string

And where i need to submit it is:

Submit the Request

I receive a bunch of errors all over the place.

Any guidance into the right way will be much appreciated. (Using Visual Studio 2015)

////Additional Information:

The code where the extraction happens. I extract 9 ID's (as the password1 is 9 characters).

I then Say if the ID extracted is bigger than 6, use that plus add the correlated password piece. This works 100%

ExtractionCursor extractionCursor41 = new ExtractionCursor(); 
                    if (response41.Find(extractionCursor41, "Enter only the required characters of", ActionType.ACT_EXIT_VU, true, SearchFlags.SEARCH_IN_BODY))
                    {
                        Set("c_surephraseIDs_41", response41.ExtractList(extractionCursor41, "name=\"", "\" id=\"", "viLabel=\"Password 9\" />", true, 9, ActionType.ACT_EXIT_VU, SearchFlags.SEARCH_IN_BODY));
                    }
                    
                    if (extractionCursor41.Succeeded)
                    {
                        WriteMessage("Items extracted to list variable: c_surephraseIDs_41...");
                        List<string> valuesList = Get<List<string>>("c_surephraseIDs_41");
                        foreach (string listItem in valuesList)
                        {
                            WriteMessage(String.Format("Item: {0}", listItem));
                        }

                        List<string> Array2 = Get<List<string>>("c_surephraseIDs_41");
                        List<string> Array1 = new List<string> { "p", "a", "s", "s", "w", "o", "r", "d", "1" };
                        List<string> Array3 = new List<string> { "", "", "", "", "", "", "", "", "" };
                        int j = 0;

                        for (int i = 0; i < 9; i++)
                        {
                            
                            if (Array2[i].Length > 6)
                            {                            
                                Array3[j] = Array2[i] + "=" + Array1[i];
                                WriteMessage(Array3[j]);
                                j++;
                            }
                        }

                        string Passphrase = Array3[0] + "&" + Array3[1] + "&" + Array3[2];
 

                    }
                    
                    // Rule: Verify that the result code matches what was recorded
                    response41.VerifyResult(HttpStatus.OK, ActionType.ACT_WARNING);
                }

Then in the request where this is parsed back to the website:

using (Request request44 = WebBrowser.CreateRequest(HttpMethod.POST, url44, 44))
            {
                request44.SetReferer(new Url(protocol1, onlinebankinguat3, "/absa-online/login.jsp"));
                request44.SetHeader("Origin", "https://onlinebankinguat3.absa.co.za");
                request44.SetHeader("Content-Type", "application/x-www-form-urlencoded");
                Form postData44 = new Form();
                postData44.CharEncoding = Encoding.GetEncoding("ISO-8859-1");
                //The below 3 are originally as per the recording.
                //postData44.AddElement(new InputElement("B3391b84d", "a", Encoding.GetEncoding("ISO-8859-1")));
                //postData44.AddElement(new InputElement("B54824db9", "r", Encoding.GetEncoding("ISO-8859-1")));
                //postData44.AddElement(new InputElement("fa2ebc87", "d", Encoding.GetEncoding("ISO-8859-1")));
                //The below is the one I am trying to send over the wire
                postData44.AddElement(new InputElement("",GetString("Passphrase"), Encoding.GetEncoding("ISO-8859-1")));
                //
                postData44.AddElement(new InputElement("landingpage", "express", Encoding.GetEncoding("ISO-8859-1")));
                postData44.AddElement(new InputElement("dsp", "false", Encoding.GetEncoding("ISO-8859-1")));
                postData44.AddElement(new InputElement("dspid", "0", Encoding.GetEncoding("ISO-8859-1")));
                postData44.AddElement(new InputElement("dspreferer", "null", Encoding.GetEncoding("ISO-8859-1")));
                postData44.AddElement(new InputElement("goto", "", Encoding.GetEncoding("ISO-8859-1")));
                postData44.AddElement(new InputElement("", "", Encoding.GetEncoding("ISO-8859-1")));
                postData44.AddElement(new InputElement("", "", Encoding.GetEncoding("ISO-8859-1")));
                postData44.AddElement(new InputElement("nonce", "0", Encoding.GetEncoding("ISO-8859-1")));
                postData44.AddElement(new InputElement("uniq", GetMillisecondsSinceEpoch(-5) /* Replaced timestamp 1641064306006 (2022-01-01T21:11:46.006000+02:00) */ , Encoding.GetEncoding("ISO-8859-1")));
                request44.SetMessageBody(postData44);

When it comes to building the string Passphrase I can see that it works correctly:

The string builds correctly

And when it comes to the sending of the request this is the response:

The errors that is logged once I try send the request


Solution

  • I did this:

    for (int i = 0; i < 9; i++)
    {
    
      if (Array2[i].Length > 6)
      {
        Array3[j] = Array2[i] + "=" + Array1[i];
    
        if (j == 0)
        {
          Set<string>("PPleft1", Array2[i]);
          Set<string>("PPright1", Array1[i]);
        }
        if (j == 1)
        {
          Set<string>("PPleft2", Array2[i]);
          Set<string>("PPright2", Array1[i]);
        }
        if (j == 2)
        {
          Set<string>("PPleft3", Array2[i]);
          Set<string>("PPright3", Array1[i]);
        }
      }
    }