Skip to content

Commit 4d4936c

Browse files
author
Sunny Raj Rathod
authored
Merge pull request #152 from varyonic/credentials
Replace hard coded test account credentials
2 parents 23f326d + 644e1d0 commit 4d4936c

9 files changed

+24
-13
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Gemfile.lock
2-
spec/credentials.yml
32
.ruby-*
43
.idea
54
gemfiles/*.lock

spec/aim_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe AuthorizeNet::AIM::Transaction do
44
before :all do
55
begin
6-
creds = YAML.load_file(File.dirname(__FILE__) + "/credentials.yml")
6+
creds = credentials
77
@api_key = creds['api_transaction_key']
88
@api_login = creds['api_login_id']
99
@md5_value = creds['md5_value']
@@ -285,7 +285,7 @@
285285
describe AuthorizeNet::AIM::Response do
286286
before :all do
287287
begin
288-
creds = YAML.load_file(File.dirname(__FILE__) + "/credentials.yml")
288+
creds = credentials
289289
@api_key = creds['api_transaction_key']
290290
@api_login = creds['api_login_id']
291291
rescue Errno::ENOENT => e

spec/api_spec.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
describe Transaction do
55
before :all do
66
begin
7-
creds = YAML.load_file(File.dirname(__FILE__) + "/credentials.yml")
7+
creds = credentials
88
@api_key = creds['api_transaction_key']
99
@api_login = creds['api_login_id']
1010
@gateway = :sandbox
@@ -158,7 +158,7 @@
158158

159159
expect(createProfResp).not_to eq(nil)
160160
unless createProfResp.messages.resultCode == MessageTypeEnum::Ok
161-
puts createProfResp.messages.messages[0].text
161+
puts createProfResp.messages.messages[0].text, createProfReq.transId
162162
end
163163
expect(createProfResp.messages.resultCode).to eq(MessageTypeEnum::Ok)
164164
expect(createProfResp.customerProfileId).not_to eq(nil)
@@ -484,6 +484,7 @@
484484
end
485485

486486
it "should be able to get subscription" do
487+
@api_login, @api_key = '5KP3u95bQpv', '346HZ32z3fP4hTG2' # FIXME: this spec added in #66 depends on a hard coded test account.
487488
transaction = AuthorizeNet::API::Transaction.new(@api_login, @api_key, gateway: @gateway)
488489
@createTransactionRequest = ARBGetSubscriptionRequest.new
489490

@@ -505,6 +506,7 @@
505506
end
506507

507508
it "should be able to get Customer Payment Profile List Request" do
509+
@api_login, @api_key = '5KP3u95bQpv', '346HZ32z3fP4hTG2' # FIXME: this spec added in #66 depends on a hard coded test account.
508510
transaction = AuthorizeNet::API::Transaction.new(@api_login, @api_key, gateway: @gateway)
509511

510512
searchTypeEnum = CustomerPaymentProfileSearchTypeEnum::CardsExpiringInMonth
@@ -538,6 +540,7 @@
538540
end
539541

540542
it "should be able to get transaction List Request" do
543+
@api_login, @api_key = '5KP3u95bQpv', '346HZ32z3fP4hTG2' # FIXME: this spec added in #72 depends on a hard coded test account.
541544
transaction = AuthorizeNet::API::Transaction.new(@api_login, @api_key, gateway: @gateway)
542545

543546
batchId = "4551107"

spec/arb_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe AuthorizeNet::ARB::Transaction do
44
before :all do
55
begin
6-
creds = YAML.load_file(File.dirname(__FILE__) + "/credentials.yml")
6+
creds = credentials
77
@api_key = creds['api_transaction_key']
88
@api_login = creds['api_login_id']
99
rescue Errno::ENOENT => e

spec/cim_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def create_payment_profile(payment_profile, profile, validation_mode = :none)
253253
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, gateway: :sandbox)
254254
expect(transaction).to respond_to(:create_transaction_auth_only)
255255
response = transaction.create_transaction_auth_only(@amount, profile, payment_profile, AuthorizeNet::Order.new)
256+
expect(response.message_text).to eq 'Successful.'
256257
expect(response.success?).to eq true
257258
direct_response = response.direct_response
258259
expect(direct_response).to be_instance_of(AuthorizeNet::AIM::Response)
@@ -263,6 +264,7 @@ def create_payment_profile(payment_profile, profile, validation_mode = :none)
263264
# create an auth only transaction
264265
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, gateway: :sandbox)
265266
response = transaction.create_transaction_auth_only(@amount + 10, profile, payment_profile, AuthorizeNet::Order.new)
267+
expect(response.message_text).to eq 'Successful.'
266268
expect(response.success?).to eq true
267269
direct_response = response.direct_response
268270
expect(direct_response.success?).to eq true
@@ -281,6 +283,7 @@ def create_payment_profile(payment_profile, profile, validation_mode = :none)
281283
# create a transaction
282284
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, gateway: :sandbox)
283285
response = transaction.create_transaction_auth_capture(@amount, profile, payment_profile, AuthorizeNet::Order.new)
286+
expect(response.message_text).to eq 'Successful.'
284287
expect(response.success?).to eq true
285288
direct_response = response.direct_response
286289
expect(direct_response.success?).to eq true
@@ -326,6 +329,7 @@ def create_payment_profile(payment_profile, profile, validation_mode = :none)
326329
it "should support custom fields" do
327330
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, gateway: :sandbox)
328331
response = transaction.create_transaction_auth_capture(@amount, profile, payment_profile, AuthorizeNet::Order.new, custom_fields: { foo: '123', bar: '456' })
332+
expect(response.message_text).to eq 'Successful.'
329333
expect(response.success?).to eq true
330334
direct_response = response.direct_response
331335
expect(direct_response.success?).to eq true
@@ -341,6 +345,7 @@ def create_payment_profile(payment_profile, profile, validation_mode = :none)
341345
order.description = 'This order includes invoice num'
342346
order.po_num = 'PO_12345'
343347
response = transaction.create_transaction_auth_capture(@amount, profile, payment_profile, order)
348+
expect(response.message_text).to eq 'Successful.'
344349
expect(response.success?).to eq true
345350
direct_response = response.direct_response
346351
expect(direct_response).to be_instance_of(AuthorizeNet::AIM::Response)

spec/credentials.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#obtain an API login_id and transaction_id according to instructions at https://developer.authorize.net/faqs/#gettranskey
2-
api_login_id: 5KP3u95bQpv
3-
api_transaction_key: 346HZ32z3fP4hTG2
2+
api_login_id: <%= ENV.fetch 'API_LOGIN_ID' %>
3+
api_transaction_key: <%= ENV.fetch 'API_TRANSACTION_KEY' %>
4+
45
#obtained md5 hash value by first setting the hash value in https://sandbox.authorize.net/ under the Account tab->MD5 Hash
5-
md5_value: MD5_TEST
6+
md5_value: <%= ENV['MD5_VALUE'] || 'MD5_TEST' %>

spec/reporting_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe AuthorizeNet::Reporting do
44
before :all do
55
begin
6-
creds = YAML.load_file(File.dirname(__FILE__) + "/credentials.yml")
6+
creds = credentials
77
@api_key = creds['api_transaction_key']
88
@api_login = creds['api_login_id']
99
rescue Errno::ENOENT => e

spec/sim_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe AuthorizeNet::SIM::Transaction do
44
before :all do
55
begin
6-
creds = YAML.load_file(File.dirname(__FILE__) + "/credentials.yml")
6+
creds = credentials
77
@api_key = creds['api_transaction_key']
88
@api_login = creds['api_login_id']
99
rescue Errno::ENOENT => e
@@ -53,7 +53,7 @@
5353
describe AuthorizeNet::SIM::Response do
5454
before :all do
5555
begin
56-
creds = YAML.load_file(File.dirname(__FILE__) + "/credentials.yml")
56+
creds = credentials
5757
@api_key = creds['api_transaction_key']
5858
@api_login = creds['api_login_id']
5959
rescue Errno::ENOENT => e

spec/support/shared_helper.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
require 'erb'
2+
require 'yaml'
3+
14
module SharedHelper
25
def credentials
3-
$credentials ||= YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
6+
$credentials ||= YAML.load(ERB.new(File.read "#{__dir__}/../credentials.yml").result)
47
rescue Errno::ENOENT
58
warn "WARNING: Running w/o valid AuthorizeNet sandbox credentials. Create spec/credentials.yml."
69
end

0 commit comments

Comments
 (0)