Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stubbing Cookie/s with Typhoeus #813

Open
erwanlr opened this issue Apr 3, 2019 · 0 comments
Open

Stubbing Cookie/s with Typhoeus #813

erwanlr opened this issue Apr 3, 2019 · 0 comments

Comments

@erwanlr
Copy link

erwanlr commented Apr 3, 2019

Unless I am doing something wrong, it's currently not possible to stub Typhoeus requests with cookies.

stub_request(:get, url)
  .with(headers: { 'Cookie' => 'key=value' })
  .to_return(body: 'Cookies Accepted!')

does not work because Typhoeus does not set the Cookie header it seems, but rather use the :cookie option (https://github.com/typhoeus/ethon/blob/c5c9c6e10114c9939642be522ab05432ca7ec5d2/lib/ethon/curls/options.rb#L340):

@request=
#<Typhoeus::Request:0x0000000003619150
@__webmock_request_signature=
#<WebMock::RequestSignature:0x000000000361ec68
 @body=nil,
 @headers=
  {"User-Agent"=>"WPScan v3.5.0 (https://wpscan.org/)", "Expect"=>""},
 @method=:get,
 @uri=#<Addressable::URI:0x1b0f4b8 URI:http://wp.lab/>>,
@base_url="http://wp.lab/",
@block_connection=false,
@on_complete=[],
@on_headers=[],
@on_progress=[],
@on_success=[],
@options=
{:headers=>
  {"User-Agent"=>"WPScan v3.5.0 (https://wpscan.org/)", "Expect"=>""},
 :accept_encoding=>"gzip, deflate",
 :method=>:get,
 :cookie=>"key=value",
 :followlocation=>true,
 :maxredirs=>3},
@original_options=
{:headers=>{"User-Agent"=>"WPScan v3.5.0 (https://wpscan.org/)"},
 :accept_encoding=>"gzip, deflate",
 :method=>:get,
 :cookie=>"key=value",
 :followlocation=>true,
 :maxredirs=>3},
@response=#<Typhoeus::Response:0x0000000003628d80 ...>>>
@erwanlr erwanlr changed the title Typhoeus - Stubbing with Cookie Stubbing Cookie/s with Typhoeus Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant