简体   繁体   中英

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

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?

Why does the order make a difference? If you are passing GET variables surely order doesn't matter? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM