有没有办法在运行sampler之前添加像Authorization这样的动态标头?

问题描述 投票:1回答:1

我正在设置Jmeter进行性能测试。但是,我的API在访问API之前需要HMAC身份验证。我有相同的JS脚本。

vars.put('hmacAuthHeader', response);

在标题管理器中,我添加了一个标题:

Authorization: ${hmacAuthHeader}

运行采样器后,当我检查请求标头时,它仍然是相同的。此外,hmac生成逻辑取决于我发送到服务器的请求,如下所示:

if(request['method'] == 'GET') {
    l_content_type  =   '';
} 

请建议一种方法来实现这一目标。

javascript jmeter hmac
1个回答
0
投票

我有它的java代码。 //如果有用户名密码而不是AuthManager manager = new AuthManager(); Authorization authorization = new Authorization(); // authorization.setURL("http://url"); authorization.setUser("username"); authorization.setPass("password"); manager.addAuth(authorization); manager.setName(JMeterUtils.getResString("auth_manager_title")); // $NON-NLS-1$ manager.setProperty(TestElement.TEST_CLASS, AuthManager.class.getName()); manager.setProperty(TestElement.GUI_CLASS, AuthPanel.class.getName());

© www.soinside.com 2019 - 2024. All rights reserved.