GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Stubbing out authentication · Issue #936 · googleapis/google-cloud-node

Stubbing out authentication #936

New issue
Copy link
New issue
Copy link
Closed
Closed
Stubbing out authentication#936
Copy link
Assignees
stephenplusplus
Labels
api: datastoreIssues related to the Datastore API.

Description

@brainsiq
brainsiq
opened on Nov 10, 2015
Issue body actions

I have the gcloud module talking to a local cloud datastore using the gcd tool for automated testing but am finding that it only works if I provide real credentials from my google console. Is there a way to stub out the authentication process so I can use test credentials?

Activity

  1. stephenplusplus commented on Nov 10, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 10, 2015
    Contributor
    More actions

    This should definitely be possible. Can you show me how you're getting the Dataset instance and the errors/signs that it's not working that you are getting?

  2. stephenplusplus commented on Nov 10, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 10, 2015
    Contributor
    More actions

    I put together a test branch, please give it a shot and let me know how it goes!

    $ npm install --save stephenplusplus/gcloud-node#spp--gcd-no-auth
  3. stephenplusplus
    added
    api: datastoreIssues related to the Datastore API.
    on Nov 10, 2015
  4. brainsiq commented on Nov 10, 2015

    @brainsiq
    brainsiq
    on Nov 10, 2015
    Author
    More actions

    Thanks for the response. I'll give that branch a go tomorrow. So far I've just set the DATASTORE_HOST environment variable to my gcd server as I haven't come across any specific instructions for stubbing out the oAuth call that is made with the credentials.

  5. brainsiq commented on Nov 10, 2015

    @brainsiq
    brainsiq
    on Nov 10, 2015
    Author
    More actions

    I get an invalid_grant response out of the gcloud lib when calling dataset.save

  6. stephenplusplus commented on Nov 10, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 10, 2015
    Contributor
    More actions

    So far I've just set the DATASTORE_HOST environment variable

    That's mainly what I was wondering. Our code currently isn't seeing that and turning off the auth step. Hopefully that branch resolves that.

  7. brainsiq commented on Nov 11, 2015

    @brainsiq
    brainsiq
    on Nov 11, 2015
    Author
    More actions

    Looks like this may now be turning off the auth step but breaking something else further down the line as when it comes to doing the save I get [Error: Invalid URI "undefined/datastore/v1beta2/datasets/suppliers/commit"]

    I found that this.apiEndpoint from the Dataset constructor needs to be set for the API calls. Seems fairly easy to fix but can't quite see, at the moment, how to write tests to ensure that both this.apiEndpoint and customEndpoint both get set correctly.

  8. stephenplusplus commented on Nov 11, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 11, 2015
    Contributor
    More actions

    Oops, good catch. I just pushed a fix (hopefully).

    If this works, I'll probably re-think how this is written before sending a PR. It's getting a wee bit messy.

  9. brainsiq commented on Nov 11, 2015

    @brainsiq
    brainsiq
    on Nov 11, 2015
    Author
    More actions

    Yep that change seems to have done the trick.

    These are my thoughts on the tests/implementation (slightly naive perhaps given I don't know any of the rest of the code base), hope they're welcome 😄 ...

    I thought that with the current implementation the tests would be better just asserting that ds.apiEndpoint is set to the correct URL depending on the options/env, rather than testing the implementation of that private determineApiEndpoint_ function. And if determineApiEndpoint_ became just getCustomEndpoint then you shouldn't need to mutate the options parameter as a side effect. I did feel it also needs a test that when a custom endpoint is provided then it sets up the auth correctly as presumably that's why this slipped through the net. That was the main thing I couldn't work out how to do given the current state of things, so I guess you may want to tweak things further.

    Anyway. Thanks for your help! Can live with it making the live auth calls for the time being until you figure something out.

  10. stephenplusplus commented on Nov 11, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 11, 2015
    Contributor
    More actions

    Of course, all thoughts are welcome. I will ping you when it's in the PR
    stage for more :)

    On Wednesday, November 11, 2015, Chris Impey [email protected]
    wrote:

    Yep that change seems to have done the trick.

    These are my thoughts on the tests/implementation (slightly naive perhaps
    given I don't know any of the rest of the code base), hope they're welcome [image:
    😄] ...

    I thought that with the current implementation the tests would be better
    just asserting that ds.apiEndpoint is set to the correct URL depending on
    the options/env, rather than testing the implementation of that private
    determineApiEndpoint_ function. And if determineApiEndpoint_ became just
    getCustomEndpoint then you shouldn't need to mutate the options parameter
    as a side effect. I did feel it also needs a test that when a custom
    endpoint is provided then it sets up the auth correctly as presumably
    that's why this slipped through the net. That was the main thing I couldn't
    work out how to do given the current state of things, so I guess you may
    want to tweak things further.

    Anyway. Thanks for your help! Can live with it making the live auth calls
    for the time being until you figure something out.

    —
    Reply to this email directly or view it on GitHub
    #936 (comment)
    .

  11. stephenplusplus
    self-assigned this
    on Nov 11, 2015
  12. callmehiphop
    closed this as completedin #940on Nov 12, 2015
  13. brainsiq commented on Nov 13, 2015

    @brainsiq
    brainsiq
    on Nov 13, 2015
    Author
    More actions

    Good work 👍

    When might this make it to npm?

  14. stephenplusplus commented on Nov 14, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 14, 2015
    Contributor
    More actions

    I'll shoot for Wednesday/Thursday next week. Our code is in a bit of a transition state right now, we have a few more PRs to squeeze in. Will ping you when it's out!

  15. sofisl
    added a commit that references this issue on Nov 11, 2022

    chore: update v2.14.2 gapic-generator-typescript (#936)

    32cec0c
  16. sofisl
    added a commit that references this issue on Jan 17, 2023

    chore(nodejs): update client ref docs link in metadata (#936)

    d62d4ad
  17. miguelvelezsa
    added a commit that references this issue on Jan 28, 2026

    feat: Query filters for datastore (#936)

    dfd7c7a
  18. sofisl
    added a commit that references this issue on Feb 5, 2026

    feat: Query filters for datastore (#936)

    c15afcf
  19. sofisl
    added a commit that references this issue on Feb 17, 2026

    feat: Query filters for datastore (#936)

    68a4ad6
  20. sofisl
    added 2 commits that reference this issue on Feb 25, 2026

    chore: release 4.1.3 (#936)

    727b8a4

    fix: pause request stream on backpressure (#936)

    7528b8f
  21. GautamSharda
    added a commit that references this issue on Mar 5, 2026

    chore: release 8.0.10 (#936)

    fda1cbc
  22. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    chore: release 4.1.3 (googleapis#936)

    f7e0c1e
  23. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    build: enable release-trigger bot (#1212) (#936)

    2cf65f3

    build: enable release-trigger bot (#1212) (#936)

    521c22e
  24. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    build: enable release-trigger bot (#1212) (#936)

    649f3ad
  25. thiyaguk09
    added a commit that references this issue on May 5, 2026

    build: enable release-trigger bot (googleapis#1212) (googleapis#936)

    59435b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @stephenplusplus
    stephenplusplus

Labels

api: datastoreIssues related to the Datastore API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.