【问题标题】:Jmeter how to get value of Httprequest GET at runtimeJmeter如何在运行时获取Httprequest GET的值
【发布时间】:2019-05-14 02:49:41
【问题描述】:

我已经完成了很多从第一个请求的响应中提取值并使用正则表达式/CSS 提取器等传递给后续请求的情况,但现在我想在 GET 处提取一个值并将其传递给相同的 GET(当我单击我的页面会生成一个随机代码,该代码必须传递到同一页面,此代码对于每次点击都是唯一的)。如何创建变量并存储代码值并传递?

如何在运行时从 jmeter 中的请求中提取 GET 值并将其作为变量传递。我想在同一个请求中将此值作为变量传递 看下面的截图

我用于加密/解密的 C# 代码如下 -

 string handlerPath = HttpUtility.UrlEncode(appPath + "/ReportFileUpload.ashx");

            string cipherText = string.Empty;
            string passPhrase = "!MMFileUploader123";        // can be any string
            string initVector = "2038459710286532"; // must be 16 bytes

            // Before encrypting data, we will append plain text to a random
            // salt value, which will be between 4 and 8 bytes long (implicitly
            // used defaults).
            RijndaelEnhanced cipher = new RijndaelEnhanced(passPhrase, initVector); //, 4, 16, 256, "SHA1", DateTime.Today.ToBinary().ToString());

            cipherText = cipher.Encrypt("?rn=" + repNum + "&uid=" + user.UserId + "&op=" + originPath + "&hp=" + handlerPath + "&p=" + pass + "&domain=" + domain + "&org=" + org + "&entitytype=" + entityType);
            cipherText = HttpUtility.UrlEncode(cipherText);

//解密

//破译代码获取参数并赋值给inParams

      string passPhrase = "!MMFileUploader123";
                string initVector = "2038459710286532"; // must be 16 bytes

                RijndaelEnhanced cipher = new RijndaelEnhanced(passPhrase, initVector);
string cipherText = HttpUtility.ParseQueryString(
                                ApplicationDeployment.CurrentDeployment.ActivationUri.Query)["code"];

                            inParams = cipher.Decrypt(cipherText);

【问题讨论】:

    标签: jmeter


    【解决方案1】:

    您需要将预先生成的random code 存储在 CSV(CSV 数据集配置)中并将其传递给请求。

    向您的开发人员询问生成random code 的逻辑,它应该类似于某些md5 加密。

    【讨论】:

    • 为什么我无法读取运行时生成的代码并通过??我不想创建和存储
    • 因为看起来你的随机代码不是在服务器端生成的,代码是通过 javascript 在客户端本身生成的,Jmeter 无法捕获,为了避免使用 CSV 配置,你可以使用可用的函数在 Jmeter 5 ${__digest(SHA-256,String to be hashed,Salt,,)} 中,但为了获得在服务器端验证的正确代码,您需要知道生成有效随机代码的加密逻辑。
    • 我的代码不是用JS生成的。我有我的加密/解密代码,但我不确定如何在 Jmeter 中使用它。我在帖子中发布了上面的代码。请看一下
    【解决方案2】:

    在您的请求之前使用 JSR223 预处理器生成随机值并将该值传递给您的请求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-01
      • 1970-01-01
      • 2019-10-15
      • 1970-01-01
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 2021-10-29
      相关资源
      最近更新 更多