My application separate into 2 part, webUI (AngularJS) and Web API (ASP.net Web API). After user login, the Web API will generate a token and it will store in browser session storage. Every request must submit this token together to do validation. Unfortunately, the Web performance test not able to read the session storage. Any solution for this problem?
我的应用程序分为两个部分,webUI (AngularJS)和Web API (ASP.net Web API)。在用户登录之后,Web API将生成一个令牌,它将存储在浏览器会话存储中。每个请求都必须将这个标记提交到一起进行验证。不幸的是,Web性能测试无法读取会话存储。有什么办法解决这个问题吗?
1 个解决方案
#1
0
You said the token is generated and stored in the browser session storage, but it is also probably returned in a response. If it is, you can use custom extraction rules in order to pull that token value out, and use it in all subsequent requests in the form of a context parameter. This post may help you out: Using custom Extraction Rules
您说,令牌生成并存储在浏览器会话存储中,但它也可能在响应中返回。如果是,您可以使用自定义提取规则来提取标记值,并在所有后续请求中以上下文参数的形式使用它。这篇文章可能会帮助你:使用定制的提取规则。
If that token is not returned to you in a response of some sort, you'll have to create a custom Request Plugin, and probably tie into the PostRequest event so that you can grab the token it generated. Once you grab the token you'll have to add it to the set of context parameters for the test so that you can reuse the token in all subsequent tests.
如果这个令牌在某种类型的响应中没有返回给您,您将不得不创建一个自定义请求插件,并且可能绑定到PostRequest事件,以便您可以获取它生成的令牌。一旦您获取了令牌,您就必须将它添加到测试的上下文参数集合中,以便在以后的所有测试中重用这个令牌。
If you need to generate a token in the beginning, you may also be able to create a plugin that will generate a token for you, add it to the list of context parameters, and then use that as your token in all headers for each request so the token stays consistent.
如果您需要生成一个令牌一开始,您还可以创建一个插件,将为您生成一个令牌,将其添加到上下文参数列表,然后使用它作为你的令牌在所有标题为每个请求令牌保持一致。
These are some custom request plugins I've created before, so they may show you how to get started creating a custom one for yourself.
这些是我以前创建的一些定制的请求插件,因此它们可以向您展示如何开始为自己创建一个定制的插件。
#1
0
You said the token is generated and stored in the browser session storage, but it is also probably returned in a response. If it is, you can use custom extraction rules in order to pull that token value out, and use it in all subsequent requests in the form of a context parameter. This post may help you out: Using custom Extraction Rules
您说,令牌生成并存储在浏览器会话存储中,但它也可能在响应中返回。如果是,您可以使用自定义提取规则来提取标记值,并在所有后续请求中以上下文参数的形式使用它。这篇文章可能会帮助你:使用定制的提取规则。
If that token is not returned to you in a response of some sort, you'll have to create a custom Request Plugin, and probably tie into the PostRequest event so that you can grab the token it generated. Once you grab the token you'll have to add it to the set of context parameters for the test so that you can reuse the token in all subsequent tests.
如果这个令牌在某种类型的响应中没有返回给您,您将不得不创建一个自定义请求插件,并且可能绑定到PostRequest事件,以便您可以获取它生成的令牌。一旦您获取了令牌,您就必须将它添加到测试的上下文参数集合中,以便在以后的所有测试中重用这个令牌。
If you need to generate a token in the beginning, you may also be able to create a plugin that will generate a token for you, add it to the list of context parameters, and then use that as your token in all headers for each request so the token stays consistent.
如果您需要生成一个令牌一开始,您还可以创建一个插件,将为您生成一个令牌,将其添加到上下文参数列表,然后使用它作为你的令牌在所有标题为每个请求令牌保持一致。
These are some custom request plugins I've created before, so they may show you how to get started creating a custom one for yourself.
这些是我以前创建的一些定制的请求插件,因此它们可以向您展示如何开始为自己创建一个定制的插件。