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

How to mock firebase-ruby with VCR #86

Closed
aosyatnik opened this issue Feb 16, 2018 · 2 comments
Closed

How to mock firebase-ruby with VCR #86

aosyatnik opened this issue Feb 16, 2018 · 2 comments

Comments

@aosyatnik
Copy link

Good day.
I'm trying to mock up firebase requests with VCR. With old api it used to work as following:

- request:
    method: get
    uri: https://test-database.firebaseio.com/alerts.json?auth=foobar
    body:
      encoding: UTF-8
      string: ''
    headers:
      User-Agent:
      - HTTPClient/1.0 (2.8.3, ruby 2.3.1 (2016-04-26))
      Accept:
      - "*/*"
      Date:
      - Tue, 12 Dec 2017 05:00:00 GMT
      Content-Type:
      - application/json
  response:
    status:
      code: 200
      message: OK
    headers:
      Server:
      - nginx
      Date:
      - Wed, 17 Jan 2018 11:20:04 GMT
      Content-Type:
      - application/json; charset=utf-8
      Content-Length:
      - '4'
      Connection:
      - keep-alive
      Access-Control-Allow-Origin:
      - "*"
      Cache-Control:
      - no-cache
      Strict-Transport-Security:
      - max-age=31556926; includeSubDomains; preload
    body:
      encoding: UTF-8
      string: 'null'
    http_version:
  recorded_at: Tue, 12 Dec 2017 05:00:00 GMT

But now, with new API it makes additional request to https://www.googleapis.com/oauth2/v3/token and I have no idea how to mock this request. I've tried as following:

- request:
    method: post
    uri: https://www.googleapis.com/oauth2/v3/token
    body:
      encoding: UTF-8
      string: ''
    headers:
      User-Agent:
      - HTTPClient/1.0 (2.8.3, ruby 2.3.1 (2016-04-26))
      Accept:
      - "*/*"
      Date:
      - Tue, 12 Dec 2017 05:00:00 GMT
      Content-Type:
      - application/json
  response:
    status:
      code: 200
      message: OK
    headers:
      Server:
      - GSE
      Date:
      - Wed, 17 Jan 2018 11:20:08 GMT
      Content-Type:
      - application/json; charset=UTF-8
      Content-Length:
      - '131'
      Connection:
      - keep-alive
      Access-Control-Allow-Origin:
      - "*"
      Cache-Control:
      - no-cache
      Strict-Transport-Security:
      - max-age=31556926; includeSubDomains; preload
    body:
      encoding: UTF-8
      ????? WHAT SHOULD BE THERE ????? string: '{"kind":"identitytoolkit#VerifyCustomTokenResponse","idToken":"foo", "refreshToken": "foo", "expiresIn": "3600", "isNewUser": true}' 
    http_version:
  recorded_at: Tue, 12 Dec 2017 05:00:00 GMT

But it doesn't work. In terminal I can see, that it's failing somewhere on 30 row:
image

I assume that response json, that I wrote is incorrect. What is expected output?
Could you, please, give me some tips how can I mock up firebase calls?
Thank you and I'm sorry if it's kind of stupid question.

Best wishes!

@vincentwoo
Copy link
Collaborator

I'm not really sure how to use VCR, but you can use the old auth method (database secrets) if you don't want to mock out the OAuth portion of the library.

@aosyatnik
Copy link
Author

@vincentwoo , thank you for helping. I think I've found a solution.

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

2 participants