Running tests with API authentication in Travis CI without revealing API passwords

I have a Rails application on Github that uses some external API that requires password authentication. Right now, I have my credentials for this API in a file that is not in git, and some integration tests that use the VCR stone, so these tests always fail in Travis because they don’t have credentials for the API. I can’t check the VCR tapes on git because there is still my username in plain text and maybe some other data that is better not to expose. I think I could use a simple webmock to emulate API responses, but I think that would be too cumbersome and error prone.

Is there a way to write tests that use an external authentication API that will still work on Travis without exposing my API password to Github?

+4
source share
2 answers

You can encrypt Travis variables with the tool travis.

You will encrypt your variable with travis encrypt FOO=<your passowrd/sensitive data here>. This will print something like:secure: "djfhfjriwjdncml2948328$+@jdjw"

You can then use this variable in your envoirmental variables or elsewhere.

For example, if you copy this variable to an environment section, you can safely save your environment variable.

env:
  - secure: "djfhfjriwjdncml2948328$+@jdjw"

FOO . ,

+4

Source: https://habr.com/ru/post/1532951/


All Articles