Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Remove credentials
Browse files Browse the repository at this point in the history
Instead of using hardcoded API credentials for the remote test suite,
use a configuration file that is ignore by Git. This also fixes some remote
tests that fail due to an expired credit card.

Fixes #10

Successful Full Test Suite Run at 2019-05-31 09:48:37
  • Loading branch information
dtykocki committed May 31, 2019
1 parent ac8176d commit 41299df
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ erl_crash.dump
/doc
.tool-versions*
/.elixir_ls
config/test.secret.exs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ iex> Spreedly.find_transaction(env, "NonExistentToken")

We're happy to consider [pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).

To help ensure a consistent code style and passing tests, we ask that you execute `script/test` before submitting the PR. The test script runs Credo, Dialyzer and the remote test suite.
To help ensure a consistent code style and passing tests, we ask that you execute `script/test` before submitting the PR. The test script runs Credo, Dialyzer and the remote test suite. To run the remote test suite, the `config/test.secret.exs` file must have valid Spreedly credentials.

Upon success, it will output a message like:

Expand Down
16 changes: 13 additions & 3 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
use Mix.Config

config :spreedly,
environment_key: "R7lHscqcYkZeDGGbthKp6GKMu15",
access_secret: "8sefxO5Q44sLWpmZpalQS3Qlqo03JbCemsqsWJR3YOLCuigOFRlaLSAn0WaL5dWU"
if File.exists?("#{__DIR__}/test.secret.exs") do
import_config "test.secret.exs"
else
Mix.shell().info([:yellow, "\nExpected a config/test.secret.exs file to exist."])

msg = """
We use this file to specify gitignored configuration information
used to run remote tests.
See the top-level README.md for instructions.
"""

Mix.shell().info([:yellow, msg])
end
3 changes: 2 additions & 1 deletion lib/spreedly/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ defmodule Spreedly.Base do
defp reason_phrase(status_code) do
statuses = %{
408 => "Request Timeout See https://docs.spreedly.com/reference/api/v1/#408-request-timeout",
429 => "Too many requests, rate limit exceeded. See https://docs.spreedly.com/reference/api/v1/#429-too-many-requests",
429 =>
"Too many requests, rate limit exceeded. See https://docs.spreedly.com/reference/api/v1/#429-too-many-requests",
500 => "Internal Server Error",
501 => "Not Implemented",
502 => "Bad Gateway",
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Spreedly.Mixfile do
def project do
[
app: :spreedly,
version: "2.1.1",
version: "2.1.2",
elixir: "~> 1.4",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
Expand Down
6 changes: 4 additions & 2 deletions test/support/remote/environment_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ defmodule Remote.Environment.Case do
alias Spreedly

defp card_deets(options \\ []) do
today = Date.utc_today()

default_deets = [
email: "matrim@wot.com",
number: "5555555555554444",
month: 1,
year: 2019,
month: today.month,
year: today.year + 3,
last_name: "Cauthon",
first_name: "Matrim"
]
Expand Down

0 comments on commit 41299df

Please sign in to comment.