Non techy - getting going

41 views
Skip to first unread message

Matt Nash

unread,
Jun 19, 2018, 6:54:56 AM6/19/18
to http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API

Hello there,

 

Fairly non-technical tester here, who’s looking to reproduce some tests that I completed with Apache JMeter.

 

I’m ok with Ruby and loved the look of this gem, but I’m finding it a bit tricky to get going, even after reading the tests.  Hoping someone can help.


All i need to do is authenticate some users and immediately visit some pages as part of the same session.  This is what i have and am wondering if i'm on the completely wrong track.


HTTP.persistent("path" ) { |http|

  response = http.post("/j_security_check", :params => {:j_username => "user", :j_password => "password"}).flush

   cookie = response["Set-Cookie"][1].split(";")[0].split("=")[1]

  %w[reports support tasks].map { |page|

    http.get("/#{page}/home.do", :headers => {:cookie => "JSESSIONID=#{cookie}" } ).flush

  }

}


I've tried tweaking this a few times and get a 404 which is strange because without the persistent connection I create a manual session in my browser, grab the session id and i can navigate everywhere with;

 

   >> HTTP.cookies(:JSESSIONID => "abc123etc").get(/reports)

   >> HTTP.cookies(:JSESSIONID => "abc123etc").get(/support)

   >> HTTP.cookies(:JSESSIONID => "abc123etc").get(/tasks)


Sorry if this is really dumb... I’d really appreciate a nudge to get me going with this ruby library before my boss reminds me of time pressure and tells me to “just use wget or something”.


Many thanks


Matt

Aleksey Zapparov

unread,
Jun 19, 2018, 9:39:19 AM6/19/18
to Matt Nash, http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API
You can grab cookie jar from response:

```
response = HTTP.post(auth_url, :params => auth_params).flush
cookies = response.cookies

puts HTTP.cookies(auth_response.cookies).get(some_url).to_s
```

--
You received this message because you are subscribed to the Google Groups "http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to httprb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Sincerely yours, Alexey Zapparov
http://ixti.net | +34 677 990 688
Reply all
Reply to author
Forward
Message has been deleted
0 new messages