# File lib/rhc/rest/mock.rb, line 69
    def stub_api_request(method, uri, with_auth=true)
      api = stub_request(method, mock_href(uri, with_auth))
      api.with(&lambda{ |r| request.headers['Authorization'] == "Bearer #{with_auth[:token]}" }) if with_auth.respond_to?(:[]) && with_auth[:token]
      api.with(&expect_authorization(with_auth))
      api.with(&user_agent_header)
      if @challenge
        stub_request(method, mock_href(uri, false)).to_return(:status => 401, :headers => {'www-authenticate' => 'basic realm="openshift broker"'})
      end
      api
    end