使用具有令牌的 auth 使用 jmeter 进行性能测试

performance testing with jmeter using auth which has a token

我有休息 api,它在 header 中有令牌,但我无法执行响应数据,因为 api 必须请求令牌,我应该在哪里存储我的令牌在 jmeter 中?

  1. 如果您只有令牌并正在寻找一种方法将其添加到请求中 - 可以通过 HTTP Header Manager, you can configure it to send Authorization header 完成:

  2. 如果你需要先authenticate/authorize然后你可以使用JMeter的HTTP Request samplers first and once you get the token in the response you can extract it from there using a suitable JMeter Post-Processor and save it into a JMeter Variable.

    实现授权逻辑

    然后在 HTTP Header 管理器中,您将能够使用 Post-Processor 提取的 JMeter 变量。有关实施示例,请参阅 Using Regular Expressions to Extract Tokens and Session IDs to Variables 文章