Skip to content

Commit 2b72be8

Browse files
authored
Merge pull request #9 from CyberSource/cybersource-rest-client-bugfixes-dec17
Cybersource rest client bugfixes dec17
2 parents b6a3d3f + d7aa35e commit 2b72be8

29 files changed

+712
-109
lines changed

AuthenticationSDK/Cybersource.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ Gem::Specification.new do |s|
1717
s.add_runtime_dependency 'interface','~> 1.0', '>= 1.0.4'
1818
s.add_runtime_dependency 'jwt', '~> 2.1.0'
1919

20-
s.add_development_dependency 'rspec', '~> 2.1'
21-
s.add_development_dependency 'simplecov'
20+
s.add_runtime_dependency 'rspec', '~> 2.1'
21+
s.add_runtime_dependency 'simplecov'
22+
s.add_runtime_dependency 'simplecov-json'
2223
s.add_development_dependency 'rubocop', '~> 0.57.2'
2324
end
2425

AuthenticationSDK/core/MerchantConfig.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require_relative './Logger.rb'
22
require_relative '../util/Constants.rb'
3-
require_relative '../Util/ApiException.rb'
3+
require_relative '../util/ApiException.rb'
44
public
55
# This fuction has all the merchantConfig properties getters and setters methods
66
class Merchantconfig
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"startDay":"23",
3+
"timeZone":"America/Chicago",
4+
"reportDefinitionName":"TransactionRequestClass",
5+
"startTime":"1100",
6+
"reportFrequency":"DAILY",
7+
"ReportName":"TRRReport",
8+
"reportFormat":"csv",
9+
"orgId":"testrest",
10+
"reportType":"detail",
11+
"reportFields": ["Request.RequestID","Request.TransactionDate","Request.MerchantReferenceNumber","Request.MerchantID"]
12+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# WARNING #
3+
# Do not alter the values on the left hand side. "LEFTHANDSIDE" = "EDITABLE".
4+
#
5+
6+
#HTTP_Signature / JWT
7+
authenticationType : "jwt"
8+
#UNQUIE MERCHANT ID
9+
merchantID : "testrest"
10+
# CyberSource.Environment.SANDBOX or CyberSource.Environment. or (api.) working domain
11+
runEnvironment : "Cybersource.Environment.SANDBOX"
12+
# JWT Parameters
13+
keyAlias : "testrest"
14+
keyPass : "testrest"
15+
keyFilename : "testrest"
16+
#P12 key path. Enter the folder path where the .p12 file is located.
17+
keysDirectory : ".././resource"
18+
#EBC portal Values
19+
merchantKeyId : "08c94330-f618-42a3-b09d-e1e43be5efda"
20+
merchantsecretKey : "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE="
21+
#Logging to be enabled or not [true/false].
22+
enableLog : true
23+
#Log directory Path
24+
logDirectory : "../log"
25+
#Enter only file name, do not enter the extension type like .log, .txt etc.
26+
logFilename : "Cybs"
27+
#Log file size in KB "5K" or MB as "5M".
28+
logSize : 10485760
29+
#Proxy Setup
30+
# proxyAddress : "userproxy.com"
31+
# proxyPort :
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"clientReferenceInformation": {
3+
"code": "TC50171_3"
4+
},
5+
"processingInformation": {
6+
"commerceIndicator": "internet"
7+
},
8+
"aggregatorInformation": {
9+
"subMerchant": {
10+
"cardAcceptorID": "1234567890",
11+
"country": "US",
12+
"phoneNumber": "650-432-0000",
13+
"address1": "900 Metro Center",
14+
"postalCode": "94404-2775",
15+
"locality": "Foster City",
16+
"name": "Visa Inc",
17+
"administrativeArea": "CA",
18+
"region": "PEN",
19+
"email": "[email protected]"
20+
},
21+
"name": "V-Internatio",
22+
"aggregatorID": "123456789"
23+
},
24+
"orderInformation": {
25+
"billTo": {
26+
"country": "US",
27+
"lastName": "VDP",
28+
"address2": "Address 2",
29+
"address1": "201 S. Division St.",
30+
"postalCode": "48104-2201",
31+
"locality": "Ann Arbor",
32+
"administrativeArea": "MI",
33+
"firstName": "RTS",
34+
"phoneNumber": "999999999",
35+
"district": "MI",
36+
"buildingNumber": "123",
37+
"company": "Visa",
38+
"email": "[email protected]"
39+
},
40+
"amountDetails": {
41+
"totalAmount": "102.21",
42+
"currency": "USD"
43+
}
44+
},
45+
"paymentInformation": {
46+
"card": {
47+
"expirationYear": "2031",
48+
"number": "5555555555554444",
49+
"securityCode": "123",
50+
"expirationMonth": "12",
51+
"type": "002"
52+
}
53+
}
54+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"clientReferenceInformation": {
3+
"code": "TC50171_3"
4+
},
5+
"orderInformation": {
6+
"amountDetails": {
7+
"totalAmount": "102.21",
8+
"currency": "USD"
9+
}
10+
}
11+
}
3.47 KB
Binary file not shown.

AuthenticationSDK/spec/Authorization_spec.rb

Lines changed: 274 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
public
2+
class MerchantConfigData
3+
def merchantConfigProp()
4+
merchantId='testrest'
5+
runEnvironment='cybersource.environment.sandbox'
6+
timeout=1000 #In Milliseconds
7+
authenticationType='JWT' #'HTTP_Signature'
8+
logDirectory='../../../AuthenticationSDK/src/log'
9+
logDirectory=File.expand_path(logDirectory,__FILE__)
10+
jsonFilePath='./PostRequestData.json'
11+
logSize=10485760
12+
enableLog=true
13+
# proxyAddress='userproxy.com'
14+
# proxyPort=''
15+
# HTTP Parameters
16+
merchantSecretKey='yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE='
17+
merchantKeyId='08c94330-f618-42a3-b09d-e1e43be5efda'
18+
# JWT Parameters
19+
keysDirectory='../../../AuthenticationSDK/resource'
20+
keysDirectory=File.expand_path(keysDirectory,__FILE__)
21+
keyAlias='testrest'
22+
keyPass='testrest'
23+
keyFilename='testrest'
24+
logFilename='Cybs'
25+
configurationDictionary={}
26+
configurationDictionary['merchantID']=merchantId
27+
configurationDictionary['runEnvironment']=runEnvironment
28+
configurationDictionary['timeout']=timeout
29+
configurationDictionary['authenticationType']=authenticationType
30+
configurationDictionary['logDirectory']=logDirectory
31+
configurationDictionary['jsonFilePath']=jsonFilePath
32+
configurationDictionary['logSize']=logSize
33+
configurationDictionary['enableLog']=enableLog
34+
# configurationDictionary['proxyPort']=proxyPort
35+
configurationDictionary['merchantsecretKey']=merchantSecretKey
36+
configurationDictionary['merchantKeyId']=merchantKeyId
37+
configurationDictionary['keysDirectory']=keysDirectory
38+
configurationDictionary['keyAlias']=keyAlias
39+
configurationDictionary['keyPass']=keyPass
40+
configurationDictionary['keyFilename'] = keyFilename
41+
configurationDictionary['logFilename'] = logFilename
42+
return configurationDictionary
43+
end
44+
def setLog(logDirectory, logFilename, logSize, enableLog)
45+
if enableLog == true
46+
filename = logDirectory + '/' + logFilename + '.log'
47+
datetime = DateTime.now
48+
if File.exist?(filename) && File.size(filename) >= logSize
49+
updatedFileName = logDirectory + '/' + logFilename + '_' + datetime.strftime('%Y%m%d%H%M%S') + '.log'
50+
File.rename(filename, updatedFileName)
51+
end
52+
@logger = Logger.new(STDOUT)
53+
@logger = Logger.new(filename, logSize)
54+
@logger.datetime_format = datetime.strftime('%Y-%m-%d %H:%M:%S')
55+
else
56+
@logger = Logger.new(false)
57+
end
58+
end
59+
end
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
require_relative './MerchantConfigData.rb'
2+
require_relative './spec_helper'
3+
4+
describe Merchantconfig do
5+
it 'Validating enablelog as null MerchantConfig File' do
6+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
7+
cybsPropertyobj['enableLog']=''
8+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
9+
expect(merchantConfigObj.enableLog).to eq true
10+
end
11+
it 'Validating logFileName as null MerchantConfig File' do
12+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
13+
cybsPropertyobj['logFilename']=''
14+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
15+
expect(merchantConfigObj.logFilename).to eq 'cybs'
16+
end
17+
it 'Validating enableLog as fixnum in MerchantConfig File' do
18+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
19+
cybsPropertyobj['enableLog']=123
20+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
21+
expect(merchantConfigObj.enableLog).to eq '123'
22+
end
23+
it 'Validating logDirectory as fixnum in MerchantConfig File' do
24+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
25+
cybsPropertyobj['logDirectory']=''
26+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
27+
expect(merchantConfigObj.logDirectory).to eq '../log'
28+
end
29+
it 'Validating RunEnvironment as Prod MerchantConfig File' do
30+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
31+
cybsPropertyobj['runEnvironment']='Cybersource.Environment.Production'
32+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
33+
expect(merchantConfigObj.requestHost).to eq 'api.cybersource.com'
34+
end
35+
it 'Validating RunEnvironment as default MerchantConfig File' do
36+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
37+
cybsPropertyobj['runEnvironment']='api.cybersource.com'
38+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
39+
expect(merchantConfigObj.requestHost).to eq 'api.cybersource.com'
40+
end
41+
it 'Validating MerchantId as empty in MerchantConfig File' do
42+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
43+
cybsPropertyobj['merchantID']=''
44+
expect { Merchantconfig.new cybsPropertyobj }.to raise_error(StandardError)
45+
end
46+
it 'Validating authenticationType as empty in MerchantConfig File' do
47+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
48+
cybsPropertyobj['authenticationType']=''
49+
expect { Merchantconfig.new cybsPropertyobj }.to raise_error(StandardError)
50+
end
51+
it 'Validating authenticationType as Fixnum in MerchantConfig File' do
52+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
53+
cybsPropertyobj['authenticationType']=123
54+
expect { Merchantconfig.new cybsPropertyobj }.to raise_error(StandardError)
55+
end
56+
it 'Validating keyAlias as Fixnum MerchantConfig File' do
57+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
58+
cybsPropertyobj['keyAlias']=123
59+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
60+
expect(merchantConfigObj.keyAlias).to eq '123'
61+
end
62+
it 'Validating keyPass as Fixnum MerchantConfig File' do
63+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
64+
cybsPropertyobj['keyPass']=123
65+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
66+
expect(merchantConfigObj.keyPass).to eq '123'
67+
end
68+
it 'Validating keysDirectory as Fixnum MerchantConfig File' do
69+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
70+
cybsPropertyobj['keysDirectory']=123
71+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
72+
expect(merchantConfigObj.keysDirectory).to eq '123'
73+
end
74+
it 'Validating keyFilename as Fixnum MerchantConfig File' do
75+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
76+
cybsPropertyobj['keyFilename']=123
77+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
78+
expect(merchantConfigObj.keyFilename).to eq '123'
79+
end
80+
it 'Validating keyAlias as empty MerchantConfig File' do
81+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
82+
cybsPropertyobj['keyAlias']=''
83+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
84+
expect(merchantConfigObj.keyAlias).to eq 'testrest'
85+
end
86+
it 'Validating keyAlias not equal to merchantId MerchantConfig File' do
87+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
88+
cybsPropertyobj['keyAlias']='test'
89+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
90+
expect(merchantConfigObj.keyAlias).to eq 'testrest'
91+
end
92+
it 'Validating keyPass as empty MerchantConfig File' do
93+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
94+
cybsPropertyobj['keyPass']=''
95+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
96+
expect(merchantConfigObj.keyPass).to eq 'testrest'
97+
end
98+
it 'Validating keyFilename as empty MerchantConfig File' do
99+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
100+
cybsPropertyobj['keyFilename']=''
101+
merchantConfigObj=Merchantconfig.new cybsPropertyobj
102+
expect(merchantConfigObj.keyFilename).to eq 'testrest'
103+
end
104+
it 'Validating merchantKeyId as empty MerchantConfig File' do
105+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
106+
cybsPropertyobj['merchantKeyId']=''
107+
cybsPropertyobj['authenticationType']='http_signature'
108+
expect { Merchantconfig.new cybsPropertyobj }.to raise_error(StandardError)
109+
end
110+
it 'Validating merchantSecretKey as empty MerchantConfig File' do
111+
cybsPropertyobj=MerchantConfigData.new.merchantConfigProp
112+
cybsPropertyobj['merchantsecretKey']=''
113+
cybsPropertyobj['authenticationType']='http_signature'
114+
expect { Merchantconfig.new cybsPropertyobj }.to raise_error(StandardError)
115+
end
116+
end

0 commit comments

Comments
 (0)