geocerts 0.0.25 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +38 -0
- data/Rakefile +2 -28
- data/geocerts.gemspec +22 -145
- data/lib/geo_certs.rb +1 -0
- data/lib/geo_certs/api.rb +3 -0
- data/lib/geo_certs/certificate.rb +5 -0
- data/lib/geo_certs/endpoints/certificates.rb +3 -0
- data/lib/geo_certs/endpoints/fraud_scores.rb +59 -0
- data/lib/geo_certs/fraud_score.rb +38 -0
- data/lib/geo_certs/version.rb +3 -0
- data/test/config/initializers/vcr.rb +14 -0
- data/test/factories.rb +8 -0
- data/test/fixtures/remote/certificates.yml +117 -0
- data/test/fixtures/remote/certificates_query_window.yml +47 -0
- data/test/fixtures/remote/product_agreement.yml +310 -0
- data/test/fixtures/remote/product_agreement_404.yml +45 -0
- data/test/fixtures/responses/fraud_score.rb +51 -0
- data/test/integrations/agreement_test.rb +7 -12
- data/test/integrations/certificate_test.rb +144 -63
- data/test/integrations/fraud_score_test.rb +72 -0
- data/test/test_helper.rb +8 -8
- data/test/units/geo_certs_test.rb +2 -2
- metadata +106 -44
- data/VERSION +0 -1
- data/test/config/initializers/fakeweb.rb +0 -2
- data/test/fixtures/responses/agreement.rb +0 -136
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: https://%{PARTNER_ID}:%{API_TOKEN}@sandbox.geocerts.com:443/1/products/BAD/agreement.xml
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
accept:
|
9
|
+
- application/xml
|
10
|
+
accept-encoding:
|
11
|
+
- gzip, deflate
|
12
|
+
response: !ruby/struct:VCR::Response
|
13
|
+
status: !ruby/struct:VCR::ResponseStatus
|
14
|
+
code: 422
|
15
|
+
message: Unprocessable Entity
|
16
|
+
headers:
|
17
|
+
x-powered-by:
|
18
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.0
|
19
|
+
connection:
|
20
|
+
- keep-alive
|
21
|
+
content-type:
|
22
|
+
- application/xml; charset=utf-8
|
23
|
+
server:
|
24
|
+
- nginx/0.8.52 + Phusion Passenger 3.0.0 (mod_rails/mod_rack)
|
25
|
+
x-runtime:
|
26
|
+
- "5"
|
27
|
+
content-length:
|
28
|
+
- "177"
|
29
|
+
set-cookie:
|
30
|
+
- _geocerts_sec=5cd7b1cc76a2a4defe5b3d6107482c48; path=/; secure
|
31
|
+
- _fresh_session=2419fe88920a026c3aecf3df4871003c; path=/; HttpOnly
|
32
|
+
cache-control:
|
33
|
+
- no-cache
|
34
|
+
status:
|
35
|
+
- "422"
|
36
|
+
body: |
|
37
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
38
|
+
<errors>
|
39
|
+
<error>
|
40
|
+
<code type="integer">-90000</code>
|
41
|
+
<message>Unrecognized product code requested</message>
|
42
|
+
</error>
|
43
|
+
</errors>
|
44
|
+
|
45
|
+
http_version: "1.1"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module GeoCerts
|
2
|
+
module Responses
|
3
|
+
module FraudScore
|
4
|
+
Query = <<-RESPONSE
|
5
|
+
HTTP/1.1 200 OK
|
6
|
+
Etag: "94d6a7687963f059aa9249300d721ef1"
|
7
|
+
Connection: Keep-Alive
|
8
|
+
Content-Type: application/xml; charset=utf-8
|
9
|
+
Date: Tue, 13 Jul 2010 21:57:44 GMT
|
10
|
+
X-Runtime: 444
|
11
|
+
Content-Length: 1439
|
12
|
+
Cache-Control: private, max-age=0, must-revalidate
|
13
|
+
|
14
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
15
|
+
<fraud-score>
|
16
|
+
<country-match type="boolean">true</country-match>
|
17
|
+
<country-code>US</country-code>
|
18
|
+
<high-risk-country type="boolean">false</high-risk-country>
|
19
|
+
<distance type="integer">20</distance>
|
20
|
+
<ip-region>FL</ip-region>
|
21
|
+
<ip-city>Orlando</ip-city>
|
22
|
+
<ip-latitude type="float">28.5341</ip-latitude>
|
23
|
+
<ip-longitude type="float">-81.1647</ip-longitude>
|
24
|
+
<ip-isp>PowerOne Internet LLC</ip-isp>
|
25
|
+
<ip-org>CoLabs</ip-org>
|
26
|
+
<anonymous-proxy type="boolean">false</anonymous-proxy>
|
27
|
+
<proxy-score type="float">0.0</proxy-score>
|
28
|
+
<transparent-proxy type="boolean"></transparent-proxy>
|
29
|
+
<freemail type="boolean">false</freemail>
|
30
|
+
<carder-email type="boolean"></carder-email>
|
31
|
+
<high-risk-username type="boolean"></high-risk-username>
|
32
|
+
<high-risk-password type="boolean"></high-risk-password>
|
33
|
+
<bin-match>NA</bin-match>
|
34
|
+
<bin-country></bin-country>
|
35
|
+
<bin-name-match>NA</bin-name-match>
|
36
|
+
<bin-name></bin-name>
|
37
|
+
<bin-phone-match>NA</bin-phone-match>
|
38
|
+
<bin-phone></bin-phone>
|
39
|
+
<phone-in-billing-location>false</phone-in-billing-location>
|
40
|
+
<ship-forward></ship-forward>
|
41
|
+
<city-postal-match type="boolean">false</city-postal-match>
|
42
|
+
<ship-city-postal-match type="boolean"></ship-city-postal-match>
|
43
|
+
<explanation>This order is low risk</explanation>
|
44
|
+
<risk-score type="float">0.1</risk-score>
|
45
|
+
<queries-remaining type="integer">975</queries-remaining>
|
46
|
+
<error></error>
|
47
|
+
</fraud-score>
|
48
|
+
RESPONSE
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -7,26 +7,21 @@ class GeoCerts::AgreementTest < Test::Unit::TestCase
|
|
7
7
|
context 'user agreement' do
|
8
8
|
|
9
9
|
should 'return a GeoCerts::Agreement' do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
10
|
+
VCR.use_cassette('product_agreement') do
|
11
|
+
assert_kind_of GeoCerts::Agreement,
|
12
|
+
GeoCerts::Product.find('Q').user_agreement
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
17
16
|
should 'contain the server-provided agreement text' do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
assert_match(/GeoTrust\(R\) SSL Certificate Subscriber Agreement/, text)
|
22
|
-
assert_match(/YOU MUST READ THIS GEOTRUST SSL CERTIFICATE SUBSCRIBER AGREEMENT/, text)
|
23
|
-
assert_match(/GeoTrust SSL Certificate Subscriber Agreement Version 2.0/, text)
|
24
|
-
end
|
17
|
+
VCR.use_cassette('product_agreement') do
|
18
|
+
text = GeoCerts::Product.find('Q').user_agreement.text
|
19
|
+
assert_match(/SSL Certificate Subscriber Agreement/, text)
|
25
20
|
end
|
26
21
|
end
|
27
22
|
|
28
23
|
should 'return an error for an unrecognized product code' do
|
29
|
-
|
24
|
+
VCR.use_cassette('product_agreement_404') do
|
30
25
|
assert_responds_with_exception(GeoCerts::UnprocessableEntity, -90000) do
|
31
26
|
GeoCerts::Product.new(:sku => 'BAD').user_agreement
|
32
27
|
end
|
@@ -1,73 +1,154 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class GeoCerts::CertificateTest < Test::Unit::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
context 'Certificate (using the API)' do
|
6
|
-
|
6
|
+
|
7
7
|
context 'all' do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
assert GeoCerts::Certificate.all.all? { |item| item.kind_of?(GeoCerts::Certificate) }
|
8
|
+
subject do
|
9
|
+
@_subject ||= VCR.use_cassette('certificates') do
|
10
|
+
GeoCerts::Certificate.all
|
12
11
|
end
|
13
12
|
end
|
14
|
-
|
15
|
-
should 'return
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
|
14
|
+
should 'return a collection of GeoCerts::Certificates' do
|
15
|
+
assert subject.all? { |item| item.kind_of?(GeoCerts::Certificate) }
|
16
|
+
end
|
17
|
+
|
18
|
+
should 'return a certificate' do
|
19
|
+
assert_equal 1, subject.size
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
should 'properly populate the certificate data' do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
23
|
+
certificate = subject.first
|
24
|
+
assert_equal('R6FQJ89F', certificate.order_id)
|
25
|
+
assert_equal('173141', certificate.geotrust_order_id)
|
26
|
+
assert_equal('Active', certificate.status)
|
27
|
+
assert_equal('envylabs.com', certificate.common_name)
|
28
|
+
assert_equal('5A43', certificate.serial_number)
|
29
|
+
assert_equal('', certificate.city)
|
30
|
+
assert_equal('', certificate.state)
|
31
|
+
assert_equal('US', certificate.country)
|
32
|
+
assert_equal('envylabs.com', certificate.organization)
|
33
|
+
assert_equal('Domain Control Validated - GeoTrust(R) SSL Trial', certificate.organizational_unit)
|
34
|
+
assert_equal(DateTime.parse('2011-01-11T07:06:37+00:00'), certificate.start_at)
|
35
|
+
assert_equal(DateTime.parse('2011-01-20T15:23:06+00:00'), certificate.end_at)
|
36
|
+
assert_match(%r{/orders/432866/certificate\.xml$}, certificate.url)
|
37
|
+
assert_equal(<<-_certificate_, certificate.certificate)
|
38
|
+
-----BEGIN CERTIFICATE-----
|
39
|
+
MIIEYDCCA0igAwIBAgICWkMwDQYJKoZIhvcNAQEFBQAwTzELMAkGA1UEBhMCVVMx
|
40
|
+
FTATBgNVBAoTDEdlb1RydXN0IEluYzEpMCcGA1UEAxMgR2VvVHJ1c3QgUHJlLVBy
|
41
|
+
b2R1Y3Rpb24gU1VCIENBIDMwHhcNMTEwMTExMDcwNjM3WhcNMTEwMTIwMTUyMzA2
|
42
|
+
WjCBtDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDGVudnlsYWJzLmNvbTETMBEGA1UE
|
43
|
+
CxMKR1Q4Nzg5NDQwNDEnMCUGA1UECxMed3d3Lmdlb3RydXN0LmNvbS9yZXNvdXJj
|
44
|
+
ZXMvY3BzMTkwNwYDVQQLEzBEb21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amE7vCFy3rTPWr
|
59
|
+
lTJLU10SrSpb0LgEAvI6a7HX31risInjPRDNTC25yn7D4rOkpQN1iE2BRPjkia2r
|
60
|
+
FHf5SVMRgY8yYBTik2cjnxCYrG1EmbcpqM6J+QjMZiRMIO/EWLnP78Tj8uAejgzd
|
61
|
+
oUXXRSwjOul7ZWfb9sTydjrUAz8WBfFVuo3/g3B95GEjWxatzaNQTriM7MrZSshq
|
62
|
+
5njFPdPu2+JKXyZnyjUEu7RdLNA=
|
63
|
+
-----END CERTIFICATE-----
|
64
|
+
_certificate_
|
65
|
+
|
66
|
+
assert_equal(<<-_certificate_, certificate.ca_root)
|
67
|
+
-----BEGIN CERTIFICATE-----
|
68
|
+
MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
|
69
|
+
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
|
70
|
+
YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG
|
71
|
+
EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg
|
72
|
+
R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9
|
73
|
+
9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq
|
74
|
+
fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv
|
75
|
+
iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU
|
76
|
+
1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+
|
77
|
+
bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW
|
78
|
+
MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA
|
79
|
+
ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l
|
80
|
+
uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn
|
81
|
+
Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS
|
82
|
+
tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF
|
83
|
+
PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un
|
84
|
+
hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV
|
85
|
+
5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==
|
86
|
+
-----END CERTIFICATE-----
|
87
|
+
_certificate_
|
88
|
+
|
89
|
+
assert_equal([<<-_certificate_], certificate.ca_intermediates)
|
90
|
+
-----BEGIN CERTIFICATE-----
|
91
|
+
MIID+jCCAuKgAwIBAgIDAjbSMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
|
92
|
+
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
|
93
|
+
YWwgQ0EwHhcNMTAwMjI2MjEzMjMxWhcNMjAwMjI1MjEzMjMxWjBhMQswCQYDVQQG
|
94
|
+
EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UECxMURG9tYWluIFZh
|
95
|
+
bGlkYXRlZCBTU0wxGzAZBgNVBAMTEkdlb1Ryd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XIlMSB1CyWee0r9Y9/k3MbBn3Y0mNhp4GgkZPJMHcCrhfCn13mZXCxJeFu1e
|
111
|
+
vTezMGnGkqX2Gdgd+DYSuUuVlZzQzmwwpxb79k1ktl8qFJymyFWOIPllByTMOAVM
|
112
|
+
IIi0tWeUz12OYjf+xLQ=
|
113
|
+
-----END CERTIFICATE-----
|
114
|
+
_certificate_
|
115
|
+
|
116
|
+
assert certificate.trial?
|
41
117
|
end
|
42
|
-
|
118
|
+
|
43
119
|
should 'set the end at time' do
|
44
|
-
|
45
|
-
|
46
|
-
end
|
120
|
+
assert_equal DateTime.parse('2011-01-12T19:53:05+00:00'),
|
121
|
+
subject.end_at
|
47
122
|
end
|
48
|
-
|
123
|
+
|
49
124
|
should 'set the start at time' do
|
50
|
-
|
51
|
-
|
52
|
-
end
|
125
|
+
assert_equal DateTime.parse('2010-12-12T19:53:05+00:00'),
|
126
|
+
subject.start_at
|
53
127
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
GeoCerts::Certificate.all(
|
128
|
+
|
129
|
+
should_eventually 'modify the queried window of time' do
|
130
|
+
VCR.use_cassette('certificates_query_window') do
|
131
|
+
result = GeoCerts::Certificate.all({
|
132
|
+
:start_at => DateTime.parse('2009-01-01T00:00:00Z'),
|
133
|
+
:end_at => DateTime.parse('2009-01-02T00:00:00Z')
|
134
|
+
})
|
135
|
+
assert_equal DateTime.parse('2009-01-01T00:00:00Z'),
|
136
|
+
subject.start_at.to_s
|
137
|
+
assert_equal DateTime.parse('2009-01-02T00:00:00Z'),
|
138
|
+
subject.end_at.to_s
|
58
139
|
end
|
59
140
|
end
|
60
|
-
|
141
|
+
|
61
142
|
end
|
62
|
-
|
143
|
+
|
63
144
|
context 'find' do
|
64
|
-
|
145
|
+
|
65
146
|
setup do
|
66
147
|
managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
|
67
148
|
@order_id = GeoCerts::Order.all.first.id
|
68
149
|
end
|
69
150
|
end
|
70
|
-
|
151
|
+
|
71
152
|
should 'return a GeoCerts::Certificate' do
|
72
153
|
managed_server_request :get, "/orders/#{@order_id}/certificate.xml", :response => Responses::Certificate::Certificate do
|
73
154
|
certificate = GeoCerts::Certificate.find(@order_id)
|
@@ -75,7 +156,7 @@ class GeoCerts::CertificateTest < Test::Unit::TestCase
|
|
75
156
|
assert_equal(@order_id, certificate.order_id)
|
76
157
|
end
|
77
158
|
end
|
78
|
-
|
159
|
+
|
79
160
|
should 'properly populate the certificate data' do
|
80
161
|
exclusively_mocked_request :get, '/orders/422815/certificate.xml', :response => Responses::Certificate::Certificate do
|
81
162
|
certificate = GeoCerts::Certificate.find(422815)
|
@@ -97,7 +178,7 @@ class GeoCerts::CertificateTest < Test::Unit::TestCase
|
|
97
178
|
assert !certificate.trial?
|
98
179
|
end
|
99
180
|
end
|
100
|
-
|
181
|
+
|
101
182
|
should 'raise a ResourceNotFound error' do
|
102
183
|
managed_server_request :get, '/orders/999999999/certificate.xml', :response => Responses::InvalidOrderId do
|
103
184
|
assert_responds_with_exception(GeoCerts::ResourceNotFound, -90004) do
|
@@ -105,17 +186,17 @@ class GeoCerts::CertificateTest < Test::Unit::TestCase
|
|
105
186
|
end
|
106
187
|
end
|
107
188
|
end
|
108
|
-
|
189
|
+
|
109
190
|
end
|
110
|
-
|
191
|
+
|
111
192
|
context 'find_by_order_id' do
|
112
|
-
|
193
|
+
|
113
194
|
setup do
|
114
195
|
managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
|
115
196
|
@order_id = GeoCerts::Order.all.first.id
|
116
197
|
end
|
117
198
|
end
|
118
|
-
|
199
|
+
|
119
200
|
should 'return a GeoCerts::Certificate' do
|
120
201
|
managed_server_request :get, "/orders/#{@order_id}/certificate.xml", :response => Responses::Certificate::Certificate do
|
121
202
|
certificate = GeoCerts::Certificate.find_by_order_id(@order_id)
|
@@ -123,7 +204,7 @@ class GeoCerts::CertificateTest < Test::Unit::TestCase
|
|
123
204
|
assert_equal(@order_id, certificate.order_id)
|
124
205
|
end
|
125
206
|
end
|
126
|
-
|
207
|
+
|
127
208
|
should 'properly populate the certificate data' do
|
128
209
|
exclusively_mocked_request :get, '/orders/422815/certificate.xml', :response => Responses::Certificate::Certificate do
|
129
210
|
certificate = GeoCerts::Certificate.find_by_order_id(422815)
|
@@ -145,7 +226,7 @@ class GeoCerts::CertificateTest < Test::Unit::TestCase
|
|
145
226
|
assert !certificate.trial?
|
146
227
|
end
|
147
228
|
end
|
148
|
-
|
229
|
+
|
149
230
|
should 'not raise a ResourceNotFound error, instead returning nil' do
|
150
231
|
managed_server_request :get, '/orders/999999999/certificate.xml', :response => Responses::InvalidOrderId do
|
151
232
|
assert_responds_without_exception(GeoCerts::ResourceNotFound, -90004) do
|
@@ -153,17 +234,17 @@ class GeoCerts::CertificateTest < Test::Unit::TestCase
|
|
153
234
|
end
|
154
235
|
end
|
155
236
|
end
|
156
|
-
|
237
|
+
|
157
238
|
end
|
158
|
-
|
239
|
+
|
159
240
|
context 'reissue' do
|
160
|
-
|
241
|
+
|
161
242
|
setup do
|
162
243
|
managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
|
163
244
|
@order_id = GeoCerts::Order.all.first.id
|
164
245
|
end
|
165
246
|
end
|
166
|
-
|
247
|
+
|
167
248
|
should 'return a GeoCerts::Certificate when successful' do
|
168
249
|
managed_server_request :get, "/orders/#{@order_id}/certificate.xml", :response => Responses::Certificate::Certificate do
|
169
250
|
managed_server_request :post, "/orders/422815/certificate/reissue.xml?certificate[csr][body]=testbody", :response => Responses::Certificate::Certificate do
|
@@ -171,7 +252,7 @@ class GeoCerts::CertificateTest < Test::Unit::TestCase
|
|
171
252
|
end
|
172
253
|
end
|
173
254
|
end
|
174
|
-
|
255
|
+
|
175
256
|
should 'raise an error with no CSR body provided' do
|
176
257
|
managed_server_request :get, "/orders/#{@order_id}/certificate.xml", :response => Responses::Certificate::Certificate do
|
177
258
|
managed_server_request :post, "/orders/#{@order_id}/certificate/reissue.xml?certificate[csr][body]=", :response => Responses::Certificate::MissingCSRBody do
|
@@ -181,9 +262,9 @@ class GeoCerts::CertificateTest < Test::Unit::TestCase
|
|
181
262
|
end
|
182
263
|
end
|
183
264
|
end
|
184
|
-
|
265
|
+
|
185
266
|
end
|
186
|
-
|
267
|
+
|
187
268
|
end
|
188
|
-
|
269
|
+
|
189
270
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GeoCerts::FraudScoreTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'Order (using the API)' do
|
6
|
+
|
7
|
+
context 'query' do
|
8
|
+
should 'properly populate the data' do
|
9
|
+
exclusively_mocked_request :post, %r{/fraud_score.xml}, :response => GeoCerts::Responses::FraudScore::Query do
|
10
|
+
score = GeoCerts::FraudScore.query(Factory.attributes_for(:fraud_score))
|
11
|
+
assert_equal '1.2.3.4', score.ip
|
12
|
+
assert_equal 'Orlando', score.city
|
13
|
+
assert_equal 'FL', score.region
|
14
|
+
assert_equal '32801', score.postal_code
|
15
|
+
assert_equal 'US', score.country
|
16
|
+
assert_equal nil, score.domain
|
17
|
+
assert_equal nil, score.bin
|
18
|
+
assert_equal '', score.bin_name
|
19
|
+
assert_equal '', score.bin_phone
|
20
|
+
assert_equal nil, score.phone
|
21
|
+
assert_equal nil, score.forwarded_ip
|
22
|
+
assert_equal nil, score.email
|
23
|
+
assert_equal nil, score.username
|
24
|
+
assert_equal nil, score.password
|
25
|
+
assert_equal nil, score.shipping_address
|
26
|
+
assert_equal nil, score.shipping_city
|
27
|
+
assert_equal nil, score.shipping_region
|
28
|
+
assert_equal nil, score.shipping_postal_code
|
29
|
+
assert_equal nil, score.shipping_country
|
30
|
+
assert_equal nil, score.transaction_id
|
31
|
+
assert_equal nil, score.session_id
|
32
|
+
assert_equal nil, score.user_agent
|
33
|
+
assert_equal nil, score.accept_language
|
34
|
+
assert_equal true, score.country_match
|
35
|
+
assert_equal 'US', score.country_code
|
36
|
+
assert_equal false, score.high_risk_country
|
37
|
+
assert_equal 20.0, score.distance
|
38
|
+
assert_equal 'FL', score.ip_region
|
39
|
+
assert_equal 'Orlando', score.ip_city
|
40
|
+
assert_equal 28.5341, score.ip_latitude
|
41
|
+
assert_equal -81.1647, score.ip_longitude
|
42
|
+
assert_equal 'PowerOne Internet LLC', score.ip_isp
|
43
|
+
assert_equal 'CoLabs', score.ip_org
|
44
|
+
assert_equal false, score.anonymous_proxy
|
45
|
+
assert_equal 0.0, score.proxy_score
|
46
|
+
assert_equal false, score.transparent_proxy
|
47
|
+
assert_equal false, score.freemail
|
48
|
+
assert_equal false, score.carder_email
|
49
|
+
assert_equal false, score.high_risk_username
|
50
|
+
assert_equal false, score.high_risk_password
|
51
|
+
assert_equal false, score.bin_match
|
52
|
+
assert_equal '', score.bin_country
|
53
|
+
assert_equal 'NA', score.bin_name_match
|
54
|
+
assert_equal '', score.bin_name
|
55
|
+
assert_equal false, score.bin_phone_match
|
56
|
+
assert_equal '', score.bin_phone
|
57
|
+
assert_equal false, score.phone_in_billing_location
|
58
|
+
assert_equal false, score.ship_forward
|
59
|
+
assert_equal false, score.city_postal_match
|
60
|
+
assert_equal false, score.ship_city_postal_match
|
61
|
+
assert_equal 'This order is low risk', score.explanation
|
62
|
+
assert_equal 0.1, score.risk_score
|
63
|
+
assert_equal 975, score.queries_remaining
|
64
|
+
assert_equal '', score.error
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|