[英]How can I test a request with a literal given querystring?
For testing a given API I have to test a request with an exact querystring, because the whole querystring is hashed together with a shared secret for security, like 为了测试给定的API,我必须使用精确的查询字符串来测试请求,因为整个查询字符串都与用于安全性的共享密钥一起进行了哈希处理,例如
inject?a=1&b[a]=2&b[b]=3&d=4&sign=76c8abec496a5e6c8a51c57e231e3a62612aeff0
I can only see a way to give parameters as a hash, which does not ensure the order (at least not if it's a nested hash): 我只能看到一种以散列方式提供参数的方法,这种方法不能确保顺序(至少如果是嵌套散列,则不能保证顺序):
test "right signature injects" do
get :inject, a:1 , b: {a:2, b:3}, d: 4, sign: '76c8abec496a5e6c8a51c57e231e3a62612aeff0'
assert_response :success
end
How can I test a get request with an exact query string? 如何测试具有确切查询字符串的get请求?
Why does the order make a difference? 为什么顺序会有所不同? If you are passing GET variables surely order doesn't matter?
如果您要传递GET变量,那么顺序肯定没关系吗? I can't see any reason why your test shouldn't do what you need unless there is something in the controller that responds to this request.
我看不出任何原因,除非您的控制器中有响应此请求的东西,否则您的测试不应满足您的要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.