peburrows / goth

Elixir package for Oauth authentication via Google Cloud APIs
http://hexdocs.pm/goth
MIT License
284 stars 108 forks source link

Disabled flag not working as expected #61

Closed rjacobskind closed 5 years ago

rjacobskind commented 5 years ago

I want to set up a test environment where I can run tests without credentials for goth to start. In my test.exs I have:

config :goth,
  disabled: true

When I run mix test with this, I get an error:

** (Mix) Could not start application goth: Goth.start(:normal, []) returned an error: shutdown: failed to start child: Goth.Config
    ** (EXIT) an exception was raised:
        ** (RuntimeError)  Failed to retrieve project data from GCE internal metadata service.
                   Either you haven't configured your GCP credentials, you aren't running on GCE, or both.
                   Please see README.md for instructions on configuring your credentials.
            (goth) lib/goth/config.ex:139: Goth.Config.determine_project_id/2
            (goth) lib/goth/config.ex:60: Goth.Config.init/1
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

When I substitute in the valid credentials for the prod environment, the tests are able to run as expected. Is my config for disabling goth incorrect?

peburrows commented 5 years ago

Interesting. That config should do the trick, so I'll have to dig into this and see what might be going on. Do you happen to have a minimal project where I can reproduce what you're seeing?

rjacobskind commented 5 years ago

@peburrows Unfortunately, I don't currently. If I have time I can try to put something together, but I don't foresee having a chance in the near future.

rjacobskind commented 5 years ago

I resolved the issue. I made the silly mistake of downloading the version that's mentioned in the README.md, rather than checking out the hex package page for the most recent. I updated to version 1.1.0 and it runs fine.

peburrows commented 5 years ago

Ah, sorry about that! I've updated the README to reference the latest version so other people don't run into this same issue.