connect-sdk-ruby 2.30.2 → 2.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/connect-sdk-ruby.gemspec +3 -2
- data/lib/ingenico/connect/sdk/client.rb +14 -0
- data/lib/ingenico/connect/sdk/communicator.rb +15 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_connection.rb +27 -3
- data/lib/ingenico/connect/sdk/logging/log_message_builder.rb +15 -7
- data/lib/ingenico/connect/sdk/logging/logging_util.rb +49 -36
- data/lib/ingenico/connect/sdk/logging/obfuscation/body_obfuscator.rb +98 -0
- data/lib/ingenico/connect/sdk/logging/obfuscation/header_obfuscator.rb +52 -0
- data/lib/ingenico/connect/sdk/logging/obfuscation/obfuscation_capable.rb +18 -0
- data/lib/ingenico/connect/sdk/logging/obfuscation/obfuscation_rule.rb +45 -0
- data/lib/ingenico/connect/sdk/logging/request_log_message_builder.rb +6 -4
- data/lib/ingenico/connect/sdk/logging/response_log_message_builder.rb +4 -2
- data/lib/ingenico/connect/sdk/logging.rb +4 -0
- data/lib/ingenico/connect/sdk/meta_data_provider.rb +1 -1
- data/lib/ingenico/connect/sdk/modules.rb +4 -0
- data/spec/fixtures/resources/logging/bodyWithCardCustomObfuscated.json +21 -0
- data/spec/lib/logging/header_obfuscator_spec.rb +7 -7
- data/spec/lib/logging/legacy_logging_spec.rb +178 -0
- data/spec/lib/logging/obfuscation/body_obfuscator_spec.rb +93 -0
- data/spec/lib/logging/obfuscation/header_obfuscator_spec.rb +166 -0
- data/spec/lib/logging/value_obfuscator_spec.rb +3 -3
- metadata +30 -4
@@ -9,8 +9,10 @@ module Ingenico::Connect::SDK
|
|
9
9
|
# @param request_id [String] identifier of the request corresponding to this response.
|
10
10
|
# @param status_code [Integer] HTTP status code of the response.
|
11
11
|
# @param duration [Float] time elapsed between request and response.
|
12
|
-
def initialize(request_id, status_code, duration=-1
|
13
|
-
|
12
|
+
def initialize(request_id, status_code, duration=-1,
|
13
|
+
body_obfuscator = Obfuscation::BodyObfuscator.default_obfuscator,
|
14
|
+
header_obfuscator = Obfuscation::HeaderObfuscator.default_obfuscator)
|
15
|
+
super(request_id, body_obfuscator, header_obfuscator)
|
14
16
|
@status_code = status_code
|
15
17
|
@duration = duration
|
16
18
|
end
|
@@ -8,3 +8,7 @@ require prefix + 'logging_util'
|
|
8
8
|
require prefix + 'communicator_logger'
|
9
9
|
require prefix + 'ruby_communicator_logger'
|
10
10
|
require prefix + 'stdout_communicator_logger'
|
11
|
+
require prefix + 'obfuscation/obfuscation_rule'
|
12
|
+
require prefix + 'obfuscation/body_obfuscator'
|
13
|
+
require prefix + 'obfuscation/header_obfuscator'
|
14
|
+
require prefix + 'obfuscation/obfuscation_capable'
|
@@ -7,7 +7,7 @@ module Ingenico::Connect::SDK
|
|
7
7
|
#
|
8
8
|
# @attr_reader [Array<Ingenico::Connect::SDK::RequestHeader>] meta_data_headers List of headers that should be used in all requests.
|
9
9
|
class MetaDataProvider
|
10
|
-
@@SDK_VERSION = '2.
|
10
|
+
@@SDK_VERSION = '2.31.0'
|
11
11
|
@@SERVER_META_INFO_HEADER = 'X-GCS-ServerMetaInfo'
|
12
12
|
@@PROHIBITED_HEADERS = [@@SERVER_META_INFO_HEADER, 'X-GCS-Idempotence-Key',
|
13
13
|
'Date', 'Content-Type', 'Authorization'].sort!.freeze
|
@@ -7,6 +7,10 @@ end
|
|
7
7
|
module Ingenico::Connect::SDK::DefaultImpl
|
8
8
|
end
|
9
9
|
|
10
|
+
# Contains all obfuscation-related classes.
|
11
|
+
module Ingenico::Connect::SDK::Logging::Obfuscation
|
12
|
+
end
|
13
|
+
|
10
14
|
# Contains all logging-related classes.
|
11
15
|
module Ingenico::Connect::SDK::Logging
|
12
16
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"order": {
|
3
|
+
"amountOfMoney": {
|
4
|
+
"currencyCode": "CAD",
|
5
|
+
"amount": 2345
|
6
|
+
},
|
7
|
+
"customer": {
|
8
|
+
"billingAddress": {
|
9
|
+
"countryCode": "CA"
|
10
|
+
}
|
11
|
+
}
|
12
|
+
},
|
13
|
+
"cardPaymentMethodSpecificInput": {
|
14
|
+
"paymentProductId": 1,
|
15
|
+
"card": {
|
16
|
+
"cvv": "***",
|
17
|
+
"cardNumber": "123456******3456",
|
18
|
+
"expiryDate": "**20"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
LegacyHeaderObfuscator ||= Ingenico::Connect::SDK::Logging::HeaderObfuscator
|
4
4
|
ValueObfuscator ||= Ingenico::Connect::SDK::Logging::ValueObfuscator
|
5
5
|
|
6
|
-
describe
|
7
|
-
subject(:sample) {
|
6
|
+
describe LegacyHeaderObfuscator do
|
7
|
+
subject(:sample) { LegacyHeaderObfuscator.new(obsfs) }
|
8
8
|
context 'initialize' do
|
9
9
|
let(:obsfs) { { 'k1' => ValueObfuscator.fixed_length(5),
|
10
10
|
'k2' => ValueObfuscator.keep_start_count(2) } }
|
@@ -18,13 +18,13 @@ describe HeaderObfuscator do
|
|
18
18
|
|
19
19
|
it '.builder returns new Builder obj' do
|
20
20
|
expect(
|
21
|
-
|
21
|
+
LegacyHeaderObfuscator.builder.is_a? LegacyHeaderObfuscator::Builder
|
22
22
|
).to be(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'Builder' do
|
26
26
|
it 'checks argument type' do
|
27
|
-
b =
|
27
|
+
b = LegacyHeaderObfuscator.builder
|
28
28
|
expect {
|
29
29
|
b.with_all(123)
|
30
30
|
}.to raise_error(ArgumentError)
|
@@ -35,7 +35,7 @@ describe HeaderObfuscator do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'inherits parent methods' do
|
38
|
-
b =
|
38
|
+
b = LegacyHeaderObfuscator.builder
|
39
39
|
expect {
|
40
40
|
b.with_keep_start_count('k1', 123)
|
41
41
|
b.with_keep_end_count('k2', 123)
|
@@ -44,7 +44,7 @@ describe HeaderObfuscator do
|
|
44
44
|
|
45
45
|
it 'implements build method' do
|
46
46
|
expect(
|
47
|
-
|
47
|
+
LegacyHeaderObfuscator.builder.build.is_a? LegacyHeaderObfuscator
|
48
48
|
).to be(true)
|
49
49
|
end
|
50
50
|
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
PROPERTY_OBFUSCATOR = Ingenico::Connect::SDK::Logging::PropertyObfuscator.builder
|
4
|
+
.with_keep_end_count("cardNumber", 4)
|
5
|
+
.with_keep_end_count("expiryDate", 2)
|
6
|
+
.with_all("cvv")
|
7
|
+
.with_keep_end_count("iban", 4)
|
8
|
+
.with_keep_end_count("accountNumber", 4)
|
9
|
+
.with_keep_end_count("reformattedAccountNumber", 4)
|
10
|
+
.with_keep_start_count("bin", 6)
|
11
|
+
.with_all("value")
|
12
|
+
.with_fixed_length("keyId", 8)
|
13
|
+
.with_fixed_length("secretKey", 8)
|
14
|
+
.with_fixed_length("publicKey", 8)
|
15
|
+
.with_fixed_length("userAuthenticationToken", 8)
|
16
|
+
.with_fixed_length("encryptedPayload", 8)
|
17
|
+
.with_fixed_length("decryptedPayload", 8)
|
18
|
+
.with_fixed_length("encryptedCustomerInput", 8)
|
19
|
+
.build
|
20
|
+
|
21
|
+
HEADER_OBFUSCATOR = Ingenico::Connect::SDK::Logging::HeaderObfuscator.builder
|
22
|
+
.with_fixed_length("Authorization", 8)
|
23
|
+
.with_fixed_length("WWW-Authenticate", 8)
|
24
|
+
.with_fixed_length("Proxy-Authenticate", 8)
|
25
|
+
.with_fixed_length("Proxy-Authorization", 8)
|
26
|
+
.with_fixed_length("X-GCS-Authentication-Token", 8)
|
27
|
+
.with_fixed_length("X-GCS-CallerPassword", 8)
|
28
|
+
.build
|
29
|
+
|
30
|
+
|
31
|
+
def test_obfuscate_body_with_matches(original_resource, obfuscated_resource)
|
32
|
+
prefix = 'spec/fixtures/resources/logging/'
|
33
|
+
body = IO.read(prefix + original_resource)
|
34
|
+
expected = IO.read(prefix + obfuscated_resource)
|
35
|
+
expected == PROPERTY_OBFUSCATOR.obfuscate(body)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_obfuscate_body_with_no_matches(resource)
|
39
|
+
prefix = 'spec/fixtures/resources/logging/'
|
40
|
+
body = IO.read(prefix + resource)
|
41
|
+
body == PROPERTY_OBFUSCATOR.obfuscate(body)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_obfuscate_header_with_match(name, original_value, expected_value)
|
45
|
+
expected_value == HEADER_OBFUSCATOR.obfuscate_header(name, original_value)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_obfuscate_header_with_no_match(name, original_value)
|
49
|
+
original_value == HEADER_OBFUSCATOR.obfuscate_header(name, original_value)
|
50
|
+
end
|
51
|
+
|
52
|
+
describe Ingenico::Connect::SDK::Logging::PropertyObfuscator do
|
53
|
+
context '.obfuscate_body()' do
|
54
|
+
|
55
|
+
context 'with null body' do
|
56
|
+
let(:body) { nil }
|
57
|
+
it 'returns null body' do
|
58
|
+
expect(
|
59
|
+
PROPERTY_OBFUSCATOR.obfuscate(body)
|
60
|
+
).to be_nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'with empty body' do
|
65
|
+
let(:body) { '' }
|
66
|
+
it 'returns empty body' do
|
67
|
+
expect(
|
68
|
+
PROPERTY_OBFUSCATOR.obfuscate(body)
|
69
|
+
).to eq(body)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'works with card' do
|
74
|
+
expect(
|
75
|
+
test_obfuscate_body_with_matches("bodyWithCardOriginal.json",
|
76
|
+
"bodyWithCardObfuscated.json")
|
77
|
+
).to be(true)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'works with iban' do
|
81
|
+
expect(
|
82
|
+
test_obfuscate_body_with_matches("bodyWithIbanOriginal.json",
|
83
|
+
"bodyWithIbanObfuscated.json")
|
84
|
+
).to be(true)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'works with bin' do
|
88
|
+
expect(
|
89
|
+
test_obfuscate_body_with_matches("bodyWithBinOriginal.json",
|
90
|
+
"bodyWithBinObfuscated.json")
|
91
|
+
).to be(true)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'works when there is no match' do
|
95
|
+
expect(
|
96
|
+
test_obfuscate_body_with_no_matches("bodyNoObfuscation.json")
|
97
|
+
).to be(true)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'works with object' do
|
101
|
+
expect(
|
102
|
+
test_obfuscate_body_with_matches("bodyWithObjectOriginal.json",
|
103
|
+
"bodyWithObjectObfuscated.json")
|
104
|
+
).to be(true)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe Ingenico::Connect::SDK::Logging::HeaderObfuscator do
|
110
|
+
context '.obfuscate_header()' do
|
111
|
+
it 'works when there is a match' do
|
112
|
+
expect(
|
113
|
+
test_obfuscate_header_with_match("Authorization",
|
114
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
115
|
+
"********")
|
116
|
+
).to be(true)
|
117
|
+
|
118
|
+
expect(
|
119
|
+
test_obfuscate_header_with_match("authorization",
|
120
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
121
|
+
"********")
|
122
|
+
).to be(true)
|
123
|
+
|
124
|
+
expect(
|
125
|
+
test_obfuscate_header_with_match("AUTHORIZATION",
|
126
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
127
|
+
"********")
|
128
|
+
).to be(true)
|
129
|
+
|
130
|
+
expect(
|
131
|
+
test_obfuscate_header_with_match("X-GCS-Authentication-Token",
|
132
|
+
"foobar", "********")
|
133
|
+
).to be(true)
|
134
|
+
|
135
|
+
expect(
|
136
|
+
test_obfuscate_header_with_match("x-gcs-authentication-token",
|
137
|
+
"foobar", "********")
|
138
|
+
).to be(true)
|
139
|
+
|
140
|
+
expect(
|
141
|
+
test_obfuscate_header_with_match("X-GCS-AUTHENTICATION-TOKEN",
|
142
|
+
"foobar", "********")
|
143
|
+
).to be(true)
|
144
|
+
|
145
|
+
expect(
|
146
|
+
test_obfuscate_header_with_match("X-GCS-CallerPassword", "foobar",
|
147
|
+
"********")
|
148
|
+
).to be(true)
|
149
|
+
|
150
|
+
expect(
|
151
|
+
test_obfuscate_header_with_match("x-gcs-callerpassword", "foobar",
|
152
|
+
"********")
|
153
|
+
).to be(true)
|
154
|
+
|
155
|
+
expect(
|
156
|
+
test_obfuscate_header_with_match("X-GCS-CALLERPASSWORD", "foobar",
|
157
|
+
"********")
|
158
|
+
).to be(true)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'works when there is no match' do
|
162
|
+
expect(
|
163
|
+
test_obfuscate_header_with_no_match("Content-Type",
|
164
|
+
"application/json")
|
165
|
+
).to be(true)
|
166
|
+
|
167
|
+
expect(
|
168
|
+
test_obfuscate_header_with_no_match("content-type",
|
169
|
+
"application/json")
|
170
|
+
).to be(true)
|
171
|
+
|
172
|
+
expect(
|
173
|
+
test_obfuscate_header_with_no_match("CONTENT-TYPE",
|
174
|
+
"application/json")
|
175
|
+
).to be(true)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
BodyObfuscator = Ingenico::Connect::SDK::Logging::Obfuscation::BodyObfuscator
|
4
|
+
|
5
|
+
def test_obfuscate_body_with_matches(original_resource, obfuscated_resource,
|
6
|
+
body_obfuscator=BodyObfuscator.default_obfuscator)
|
7
|
+
prefix = 'spec/fixtures/resources/logging/'
|
8
|
+
body = IO.read(prefix + original_resource)
|
9
|
+
expected = IO.read(prefix + obfuscated_resource)
|
10
|
+
expected == body_obfuscator.obfuscate_body(body)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_obfuscate_body_with_no_matches(resource)
|
14
|
+
prefix = 'spec/fixtures/resources/logging/'
|
15
|
+
body = IO.read(prefix + resource)
|
16
|
+
body == BodyObfuscator.default_obfuscator.obfuscate_body(body)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe BodyObfuscator do
|
20
|
+
context '.obfuscate_body()' do
|
21
|
+
|
22
|
+
context 'with null body' do
|
23
|
+
let(:body) { nil }
|
24
|
+
it 'returns null body' do
|
25
|
+
expect(
|
26
|
+
BodyObfuscator.default_obfuscator.obfuscate_body(body)
|
27
|
+
).to be_nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with empty body' do
|
32
|
+
let(:body) { '' }
|
33
|
+
it 'returns empty body' do
|
34
|
+
expect(
|
35
|
+
BodyObfuscator.default_obfuscator.obfuscate_body(body)
|
36
|
+
).to eq(body)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'works with card' do
|
41
|
+
expect(
|
42
|
+
test_obfuscate_body_with_matches("bodyWithCardOriginal.json",
|
43
|
+
"bodyWithCardObfuscated.json")
|
44
|
+
).to be(true)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'works with custom card rule' do
|
48
|
+
def obfuscate_custom(value)
|
49
|
+
# range describes the range of characters to replace with asterisks
|
50
|
+
range = 6...(value.length - 4)
|
51
|
+
value[range] = '*' * range.size
|
52
|
+
value
|
53
|
+
end
|
54
|
+
|
55
|
+
body_obfuscator = BodyObfuscator.new(additional_rules={
|
56
|
+
'cardNumber' => method(:obfuscate_custom)
|
57
|
+
})
|
58
|
+
|
59
|
+
expect(
|
60
|
+
test_obfuscate_body_with_matches("bodyWithCardOriginal.json",
|
61
|
+
"bodyWithCardCustomObfuscated.json",
|
62
|
+
body_obfuscator=body_obfuscator)
|
63
|
+
).to be(true)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'works with iban' do
|
67
|
+
expect(
|
68
|
+
test_obfuscate_body_with_matches("bodyWithIbanOriginal.json",
|
69
|
+
"bodyWithIbanObfuscated.json")
|
70
|
+
).to be(true)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'works with bin' do
|
74
|
+
expect(
|
75
|
+
test_obfuscate_body_with_matches("bodyWithBinOriginal.json",
|
76
|
+
"bodyWithBinObfuscated.json")
|
77
|
+
).to be(true)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'works when there is no match' do
|
81
|
+
expect(
|
82
|
+
test_obfuscate_body_with_no_matches("bodyNoObfuscation.json")
|
83
|
+
).to be(true)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'works with object' do
|
87
|
+
expect(
|
88
|
+
test_obfuscate_body_with_matches("bodyWithObjectOriginal.json",
|
89
|
+
"bodyWithObjectObfuscated.json")
|
90
|
+
).to be(true)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
HeaderObfuscator = Ingenico::Connect::SDK::Logging::Obfuscation::HeaderObfuscator
|
4
|
+
Obfuscation = Ingenico::Connect::SDK::Logging::Obfuscation
|
5
|
+
|
6
|
+
def test_obfuscate_header_with_match(name, original_value, expected_value,
|
7
|
+
header_obfuscator=HeaderObfuscator.default_obfuscator)
|
8
|
+
expected_value == header_obfuscator.obfuscate_header(name, original_value)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_obfuscate_header_with_no_match(name, original_value)
|
12
|
+
original_value == HeaderObfuscator.default_obfuscator.obfuscate_header(name, original_value)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe HeaderObfuscator do
|
16
|
+
context '.obfuscate_header()' do
|
17
|
+
it 'works when there is a match' do
|
18
|
+
expect(
|
19
|
+
test_obfuscate_header_with_match("Authorization",
|
20
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
21
|
+
"********")
|
22
|
+
).to be(true)
|
23
|
+
|
24
|
+
expect(
|
25
|
+
test_obfuscate_header_with_match("authorization",
|
26
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
27
|
+
"********")
|
28
|
+
).to be(true)
|
29
|
+
|
30
|
+
expect(
|
31
|
+
test_obfuscate_header_with_match("AUTHORIZATION",
|
32
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
33
|
+
"********")
|
34
|
+
).to be(true)
|
35
|
+
|
36
|
+
expect(
|
37
|
+
test_obfuscate_header_with_match("X-GCS-Authentication-Token",
|
38
|
+
"foobar", "********")
|
39
|
+
).to be(true)
|
40
|
+
|
41
|
+
expect(
|
42
|
+
test_obfuscate_header_with_match("x-gcs-authentication-token",
|
43
|
+
"foobar", "********")
|
44
|
+
).to be(true)
|
45
|
+
|
46
|
+
expect(
|
47
|
+
test_obfuscate_header_with_match("X-GCS-AUTHENTICATION-TOKEN",
|
48
|
+
"foobar", "********")
|
49
|
+
).to be(true)
|
50
|
+
|
51
|
+
expect(
|
52
|
+
test_obfuscate_header_with_match("X-GCS-CallerPassword", "foobar",
|
53
|
+
"********")
|
54
|
+
).to be(true)
|
55
|
+
|
56
|
+
expect(
|
57
|
+
test_obfuscate_header_with_match("x-gcs-callerpassword", "foobar",
|
58
|
+
"********")
|
59
|
+
).to be(true)
|
60
|
+
|
61
|
+
expect(
|
62
|
+
test_obfuscate_header_with_match("X-GCS-CALLERPASSWORD", "foobar",
|
63
|
+
"********")
|
64
|
+
).to be(true)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'works when there is no match' do
|
68
|
+
expect(
|
69
|
+
test_obfuscate_header_with_no_match("Content-Type",
|
70
|
+
"application/json")
|
71
|
+
).to be(true)
|
72
|
+
|
73
|
+
expect(
|
74
|
+
test_obfuscate_header_with_no_match("content-type",
|
75
|
+
"application/json")
|
76
|
+
).to be(true)
|
77
|
+
|
78
|
+
expect(
|
79
|
+
test_obfuscate_header_with_no_match("CONTENT-TYPE",
|
80
|
+
"application/json")
|
81
|
+
).to be(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'works with a custom rule' do
|
85
|
+
header_obfuscator = HeaderObfuscator.new(additional_rules={
|
86
|
+
'content-type' => Obfuscation.obfuscate_all
|
87
|
+
})
|
88
|
+
|
89
|
+
expect(
|
90
|
+
test_obfuscate_header_with_match("Authorization",
|
91
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
92
|
+
"********",
|
93
|
+
header_obfuscator=header_obfuscator)
|
94
|
+
).to be(true)
|
95
|
+
|
96
|
+
expect(
|
97
|
+
test_obfuscate_header_with_match("authorization",
|
98
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
99
|
+
"********",
|
100
|
+
header_obfuscator=header_obfuscator)
|
101
|
+
).to be(true)
|
102
|
+
|
103
|
+
expect(
|
104
|
+
test_obfuscate_header_with_match("AUTHORIZATION",
|
105
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
106
|
+
"********",
|
107
|
+
header_obfuscator=header_obfuscator)
|
108
|
+
).to be(true)
|
109
|
+
|
110
|
+
expect(
|
111
|
+
test_obfuscate_header_with_match("X-GCS-Authentication-Token",
|
112
|
+
"foobar", "********",
|
113
|
+
header_obfuscator=header_obfuscator)
|
114
|
+
).to be(true)
|
115
|
+
|
116
|
+
expect(
|
117
|
+
test_obfuscate_header_with_match("x-gcs-authentication-token",
|
118
|
+
"foobar", "********",
|
119
|
+
header_obfuscator=header_obfuscator)
|
120
|
+
).to be(true)
|
121
|
+
|
122
|
+
expect(
|
123
|
+
test_obfuscate_header_with_match("X-GCS-AUTHENTICATION-TOKEN",
|
124
|
+
"foobar", "********",
|
125
|
+
header_obfuscator=header_obfuscator)
|
126
|
+
).to be(true)
|
127
|
+
|
128
|
+
expect(
|
129
|
+
test_obfuscate_header_with_match("X-GCS-CallerPassword", "foobar",
|
130
|
+
"********",
|
131
|
+
header_obfuscator=header_obfuscator)
|
132
|
+
).to be(true)
|
133
|
+
|
134
|
+
expect(
|
135
|
+
test_obfuscate_header_with_match("x-gcs-callerpassword", "foobar",
|
136
|
+
"********",
|
137
|
+
header_obfuscator=header_obfuscator)
|
138
|
+
).to be(true)
|
139
|
+
|
140
|
+
expect(
|
141
|
+
test_obfuscate_header_with_match("X-GCS-CALLERPASSWORD", "foobar",
|
142
|
+
"********",
|
143
|
+
header_obfuscator=header_obfuscator)
|
144
|
+
).to be(true)
|
145
|
+
|
146
|
+
expect(
|
147
|
+
test_obfuscate_header_with_match("Content-Type", "application/json",
|
148
|
+
"****************",
|
149
|
+
header_obfuscator=header_obfuscator)
|
150
|
+
).to be(true)
|
151
|
+
|
152
|
+
expect(
|
153
|
+
test_obfuscate_header_with_match("content-type", "application/json",
|
154
|
+
"****************",
|
155
|
+
header_obfuscator=header_obfuscator)
|
156
|
+
).to be(true)
|
157
|
+
|
158
|
+
expect(
|
159
|
+
test_obfuscate_header_with_match("CONTENT-TYPE", "application/json",
|
160
|
+
"****************",
|
161
|
+
header_obfuscator=header_obfuscator)
|
162
|
+
).to be(true)
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
@@ -75,13 +75,13 @@ describe ValueObfuscator do
|
|
75
75
|
expect(sample.obfuscate_value('')).to eq('')
|
76
76
|
end
|
77
77
|
|
78
|
-
it 'calls
|
78
|
+
it 'calls repeat_mask(@fixed_length) if @fixed_length is not 0' do
|
79
79
|
expect(
|
80
80
|
sample.obfuscate_value('str')
|
81
81
|
).to eq(sample.send(:repeat_mask, fixed_length))
|
82
82
|
end
|
83
83
|
|
84
|
-
it 'calls
|
84
|
+
it 'calls repeat_mask(value.length) if using ALL' do
|
85
85
|
expect(
|
86
86
|
ValueObfuscator.ALL.obfuscate_value(value)
|
87
87
|
).to eq(sample.send(:repeat_mask, value.length))
|
@@ -90,7 +90,7 @@ describe ValueObfuscator do
|
|
90
90
|
context '.keep_start_count or .keep_end_count' do
|
91
91
|
subject(:sample) { ValueObfuscator.keep_start_count(5) }
|
92
92
|
|
93
|
-
it 'returns
|
93
|
+
it 'returns original value if value is too short' do
|
94
94
|
expect(
|
95
95
|
sample.obfuscate_value('str')
|
96
96
|
).to eq('str')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: connect-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ingenico ePayments
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -86,14 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1
|
89
|
+
version: '2.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webrick
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.7'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
110
|
+
version: '1.7'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -591,6 +605,10 @@ files:
|
|
591
605
|
- lib/ingenico/connect/sdk/logging/log_message_builder.rb
|
592
606
|
- lib/ingenico/connect/sdk/logging/logging_capable.rb
|
593
607
|
- lib/ingenico/connect/sdk/logging/logging_util.rb
|
608
|
+
- lib/ingenico/connect/sdk/logging/obfuscation/body_obfuscator.rb
|
609
|
+
- lib/ingenico/connect/sdk/logging/obfuscation/header_obfuscator.rb
|
610
|
+
- lib/ingenico/connect/sdk/logging/obfuscation/obfuscation_capable.rb
|
611
|
+
- lib/ingenico/connect/sdk/logging/obfuscation/obfuscation_rule.rb
|
594
612
|
- lib/ingenico/connect/sdk/logging/request_log_message_builder.rb
|
595
613
|
- lib/ingenico/connect/sdk/logging/response_log_message_builder.rb
|
596
614
|
- lib/ingenico/connect/sdk/logging/ruby_communicator_logger.rb
|
@@ -667,6 +685,7 @@ files:
|
|
667
685
|
- spec/fixtures/resources/logging/bodyNoObfuscation.json
|
668
686
|
- spec/fixtures/resources/logging/bodyWithBinObfuscated.json
|
669
687
|
- spec/fixtures/resources/logging/bodyWithBinOriginal.json
|
688
|
+
- spec/fixtures/resources/logging/bodyWithCardCustomObfuscated.json
|
670
689
|
- spec/fixtures/resources/logging/bodyWithCardObfuscated.json
|
671
690
|
- spec/fixtures/resources/logging/bodyWithCardOriginal.json
|
672
691
|
- spec/fixtures/resources/logging/bodyWithIbanObfuscated.json
|
@@ -705,7 +724,10 @@ files:
|
|
705
724
|
- spec/lib/defaultimpl/default_marshaller_spec.rb
|
706
725
|
- spec/lib/factory_spec.rb
|
707
726
|
- spec/lib/logging/header_obfuscator_spec.rb
|
727
|
+
- spec/lib/logging/legacy_logging_spec.rb
|
708
728
|
- spec/lib/logging/logging_util_spec.rb
|
729
|
+
- spec/lib/logging/obfuscation/body_obfuscator_spec.rb
|
730
|
+
- spec/lib/logging/obfuscation/header_obfuscator_spec.rb
|
709
731
|
- spec/lib/logging/obfuscator_spec.rb
|
710
732
|
- spec/lib/logging/ruby_communicator_logger_spec.rb
|
711
733
|
- spec/lib/logging/stdout_communicator_logger_spec.rb
|
@@ -759,6 +781,7 @@ test_files:
|
|
759
781
|
- spec/fixtures/resources/logging/bodyNoObfuscation.json
|
760
782
|
- spec/fixtures/resources/logging/bodyWithBinObfuscated.json
|
761
783
|
- spec/fixtures/resources/logging/bodyWithBinOriginal.json
|
784
|
+
- spec/fixtures/resources/logging/bodyWithCardCustomObfuscated.json
|
762
785
|
- spec/fixtures/resources/logging/bodyWithCardObfuscated.json
|
763
786
|
- spec/fixtures/resources/logging/bodyWithCardOriginal.json
|
764
787
|
- spec/fixtures/resources/logging/bodyWithIbanObfuscated.json
|
@@ -797,7 +820,10 @@ test_files:
|
|
797
820
|
- spec/lib/defaultimpl/default_marshaller_spec.rb
|
798
821
|
- spec/lib/factory_spec.rb
|
799
822
|
- spec/lib/logging/header_obfuscator_spec.rb
|
823
|
+
- spec/lib/logging/legacy_logging_spec.rb
|
800
824
|
- spec/lib/logging/logging_util_spec.rb
|
825
|
+
- spec/lib/logging/obfuscation/body_obfuscator_spec.rb
|
826
|
+
- spec/lib/logging/obfuscation/header_obfuscator_spec.rb
|
801
827
|
- spec/lib/logging/obfuscator_spec.rb
|
802
828
|
- spec/lib/logging/ruby_communicator_logger_spec.rb
|
803
829
|
- spec/lib/logging/stdout_communicator_logger_spec.rb
|