checkr-official 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +16 -0
- data/Gemfile +8 -0
- data/History.txt +4 -0
- data/README.md +58 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/bin/checkr-console +7 -0
- data/checkr-official.gemspec +28 -0
- data/gemfiles/default-with-activesupport.gemfile +10 -0
- data/gemfiles/json.gemfile +12 -0
- data/gemfiles/yajl.gemfile +12 -0
- data/lib/checkr.rb +241 -0
- data/lib/checkr/api_class.rb +395 -0
- data/lib/checkr/api_list.rb +78 -0
- data/lib/checkr/api_resource.rb +18 -0
- data/lib/checkr/api_singleton.rb +5 -0
- data/lib/checkr/candidate.rb +35 -0
- data/lib/checkr/county_criminal_search.rb +19 -0
- data/lib/checkr/document.rb +13 -0
- data/lib/checkr/document_list.rb +25 -0
- data/lib/checkr/errors/api_connection_error.rb +4 -0
- data/lib/checkr/errors/api_error.rb +10 -0
- data/lib/checkr/errors/authentication_error.rb +4 -0
- data/lib/checkr/errors/checkr_error.rb +20 -0
- data/lib/checkr/errors/invalid_request_error.rb +10 -0
- data/lib/checkr/geo.rb +19 -0
- data/lib/checkr/motor_vehicle_report.rb +31 -0
- data/lib/checkr/national_criminal_search.rb +17 -0
- data/lib/checkr/report.rb +43 -0
- data/lib/checkr/report_list.rb +27 -0
- data/lib/checkr/sex_offender_search.rb +18 -0
- data/lib/checkr/ssn_trace.rb +18 -0
- data/lib/checkr/subscription.rb +27 -0
- data/lib/checkr/terrorist_watchlist_search.rb +17 -0
- data/lib/checkr/util.rb +91 -0
- data/lib/checkr/version.rb +3 -0
- data/mclovin.jpg +0 -0
- data/tasks/api_test.rb +192 -0
- data/test/checkr/api_class_test.rb +426 -0
- data/test/checkr/api_list_test.rb +27 -0
- data/test/checkr/api_resource_test.rb +28 -0
- data/test/checkr/api_singleton_test.rb +12 -0
- data/test/checkr/authentication_test.rb +50 -0
- data/test/checkr/candidate_test.rb +164 -0
- data/test/checkr/county_criminal_search_test.rb +82 -0
- data/test/checkr/document_test.rb +90 -0
- data/test/checkr/geo_test.rb +73 -0
- data/test/checkr/motor_vehicle_report_test.rb +130 -0
- data/test/checkr/national_criminal_search_test.rb +74 -0
- data/test/checkr/report_test.rb +124 -0
- data/test/checkr/sex_offender_search_test.rb +75 -0
- data/test/checkr/ssn_trace_test.rb +78 -0
- data/test/checkr/status_codes_test.rb +63 -0
- data/test/checkr/subscription_test.rb +96 -0
- data/test/checkr/terrorist_watchlist_search_test.rb +74 -0
- data/test/checkr/util_test.rb +50 -0
- data/test/mock_resource.rb +88 -0
- data/test/test_data.rb +413 -0
- data/test/test_helper.rb +43 -0
- metadata +230 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Checkr
|
4
|
+
class ApiListTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
should 'have an object attribute' do
|
7
|
+
assert(APIList.method_defined?(:object))
|
8
|
+
assert(APIList.method_defined?(:object=))
|
9
|
+
end
|
10
|
+
|
11
|
+
should 'have an data attribute' do
|
12
|
+
assert(APIList.method_defined?(:data))
|
13
|
+
assert(APIList.method_defined?(:data=))
|
14
|
+
end
|
15
|
+
|
16
|
+
should 'be refreshable' do
|
17
|
+
lambda = APIList.constructor(:MockResource)
|
18
|
+
list = lambda.call({})
|
19
|
+
list.construct(test_mock_resource_list)
|
20
|
+
assert(list.length > 0)
|
21
|
+
list.each do |mr|
|
22
|
+
assert(mr.is_a?(MockResource))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Checkr
|
4
|
+
class ApiResourceTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
should 'have an id attribute' do
|
7
|
+
assert(APIResource.method_defined?(:id))
|
8
|
+
assert(APIResource.method_defined?(:id=))
|
9
|
+
end
|
10
|
+
|
11
|
+
should 'have an object attribute' do
|
12
|
+
assert(APIResource.method_defined?(:object))
|
13
|
+
assert(APIResource.method_defined?(:object=))
|
14
|
+
end
|
15
|
+
|
16
|
+
should 'have a default path' do
|
17
|
+
mr = MockResource.new('fake_id')
|
18
|
+
assert_equal("#{MockResource.path}/fake_id", mr.path)
|
19
|
+
end
|
20
|
+
|
21
|
+
should 'raise an InvalidRequestError when no ID is present for instance path' do
|
22
|
+
@mock.expects(:get).never
|
23
|
+
c = MockResource.new
|
24
|
+
assert_raises(InvalidRequestError) { c.refresh }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Checkr
|
4
|
+
class ApiSingletonTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
should 'have an object attribute' do
|
7
|
+
assert(APISingleton.method_defined?(:object))
|
8
|
+
assert(APISingleton.method_defined?(:object=))
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path('../../test_helper', __FILE__)
|
3
|
+
|
4
|
+
module Checkr
|
5
|
+
class StatusCodesTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context 'AuthenticationError' do
|
8
|
+
should 'be raised with no API credentials' do
|
9
|
+
Checkr.api_key = nil
|
10
|
+
assert_raises(AuthenticationError) do
|
11
|
+
MockResource.retrieve('fake_id')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'be raised with invalid credentials' do
|
16
|
+
Checkr.api_key = 'invalid api key' # spaces aren't valid
|
17
|
+
assert_raises(AuthenticationError) do
|
18
|
+
MockResource.new('fake_id').refresh
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'that has been raised' do
|
23
|
+
setup do
|
24
|
+
Checkr.api_key = 'invalid'
|
25
|
+
response = test_response(test_invalid_api_key_error, 401)
|
26
|
+
begin
|
27
|
+
@mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 401))
|
28
|
+
MockResource.retrieve('failing')
|
29
|
+
rescue AuthenticationError => e
|
30
|
+
@error = e
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'have an http status of 401' do
|
35
|
+
assert_equal(401, @error.http_status)
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'have an http body' do
|
39
|
+
assert(!!@error.http_body)
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'have a JSON body with an error message' do
|
43
|
+
assert(!!@error.json_body[:error][:message])
|
44
|
+
assert_equal(test_invalid_api_key_error[:error][:message], @error.json_body[:error][:message])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Checkr
|
4
|
+
class CandidateTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
@candidate_url = "#{Checkr.api_base}/v1/candidates"
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'Candidate class' do
|
10
|
+
should 'be retrieveable' do
|
11
|
+
id = "candidate_id"
|
12
|
+
@mock.expects(:get).once.with("#{@candidate_url}/#{id}", anything, anything).returns(test_response(test_candidate))
|
13
|
+
candidate = Candidate.retrieve(id)
|
14
|
+
assert(candidate.is_a?(Candidate))
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'be createable' do
|
18
|
+
@mock.expects(:post).once.with(@candidate_url, anything, test_candidate).returns(test_response(test_candidate))
|
19
|
+
candidate = Candidate.create(test_candidate)
|
20
|
+
assert(candidate.is_a?(Candidate))
|
21
|
+
assert_equal(test_candidate[:id], candidate.id)
|
22
|
+
end
|
23
|
+
|
24
|
+
should 'be listable' do
|
25
|
+
@mock.expects(:get).once.returns(test_response(test_candidate_list))
|
26
|
+
|
27
|
+
candidates = Candidate.all
|
28
|
+
|
29
|
+
assert(candidates.is_a?(APIList))
|
30
|
+
candidates.each do |candidate|
|
31
|
+
assert(candidate.is_a?(Candidate))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'Candidate instance' do
|
37
|
+
should 'be refreshable' do
|
38
|
+
@mock.expects(:get).once.with("#{@candidate_url}/#{test_candidate[:id]}", anything, anything).returns(test_response(test_candidate))
|
39
|
+
candidate = Candidate.new(test_candidate[:id])
|
40
|
+
candidate.refresh
|
41
|
+
assert_equal(test_candidate[:email], candidate.email)
|
42
|
+
end
|
43
|
+
|
44
|
+
should 'include an empty documents list' do
|
45
|
+
# TODO(joncalhoun): Implement this when test docs are available.
|
46
|
+
|
47
|
+
# candidate = Candidate.new(test_candidate)
|
48
|
+
# @mock.expects(:get).once.with("#{Checkr.api_base}#{Transaction.path}?candidate=#{candidate.id}", anything, anything).returns(test_response(test_transaction_list))
|
49
|
+
|
50
|
+
# transactions = candidate.transactions
|
51
|
+
# assert(transactions.is_a?(APIList))
|
52
|
+
# transactions.each do |transaction|
|
53
|
+
# assert(transaction.is_a?(Transaction))
|
54
|
+
# end
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'include a filled documents list' do
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
context 'Retrieved Candidate instance' do
|
64
|
+
setup do
|
65
|
+
@mock.expects(:get).once.returns(test_response(test_candidate))
|
66
|
+
@candidate = Candidate.retrieve('candidate_id')
|
67
|
+
end
|
68
|
+
|
69
|
+
should 'have the id attribute' do
|
70
|
+
assert_equal(test_candidate[:id], @candidate.id)
|
71
|
+
end
|
72
|
+
|
73
|
+
should 'have the object attribute' do
|
74
|
+
assert_equal(test_candidate[:object], @candidate.object)
|
75
|
+
end
|
76
|
+
|
77
|
+
should 'have the uri attribute' do
|
78
|
+
assert_equal(test_candidate[:uri], @candidate.uri)
|
79
|
+
end
|
80
|
+
|
81
|
+
should 'have the created_at attribute' do
|
82
|
+
assert_equal(test_candidate[:created_at], @candidate.created_at)
|
83
|
+
end
|
84
|
+
|
85
|
+
should 'have the middle_name attribute' do
|
86
|
+
assert_equal(test_candidate[:middle_name], @candidate.middle_name)
|
87
|
+
end
|
88
|
+
|
89
|
+
should 'have the last_name attribute' do
|
90
|
+
assert_equal(test_candidate[:last_name], @candidate.last_name)
|
91
|
+
end
|
92
|
+
|
93
|
+
should 'have the email attribute' do
|
94
|
+
assert_equal(test_candidate[:email], @candidate.email)
|
95
|
+
end
|
96
|
+
|
97
|
+
should 'have the phone attribute' do
|
98
|
+
assert_equal(test_candidate[:phone], @candidate.phone)
|
99
|
+
end
|
100
|
+
|
101
|
+
should 'have the zipcode attribute' do
|
102
|
+
assert_equal(test_candidate[:zipcode], @candidate.zipcode)
|
103
|
+
end
|
104
|
+
|
105
|
+
should 'have the dob attribute' do
|
106
|
+
assert_equal(test_candidate[:dob], @candidate.dob)
|
107
|
+
end
|
108
|
+
|
109
|
+
should 'have the ssn attribute' do
|
110
|
+
assert_equal(test_candidate[:ssn], @candidate.ssn)
|
111
|
+
end
|
112
|
+
|
113
|
+
should 'have the driver_license_number attribute' do
|
114
|
+
assert_equal(test_candidate[:driver_license_number], @candidate.driver_license_number)
|
115
|
+
end
|
116
|
+
|
117
|
+
should 'have the driver_license_state attribute' do
|
118
|
+
assert_equal(test_candidate[:driver_license_state], @candidate.driver_license_state)
|
119
|
+
end
|
120
|
+
|
121
|
+
should 'have the previous_driver_license_number attribute' do
|
122
|
+
assert_equal(test_candidate[:previous_driver_license_number], @candidate.previous_driver_license_number)
|
123
|
+
end
|
124
|
+
|
125
|
+
should 'have the previous_driver_license_state attribute' do
|
126
|
+
assert_equal(test_candidate[:previous_driver_license_state], @candidate.previous_driver_license_state)
|
127
|
+
end
|
128
|
+
|
129
|
+
should 'have the copy_requested attribute' do
|
130
|
+
assert_equal(test_candidate[:copy_requested], @candidate.copy_requested)
|
131
|
+
end
|
132
|
+
|
133
|
+
should 'have the adjudication attribute' do
|
134
|
+
assert_equal(test_candidate[:adjudication], @candidate.adjudication)
|
135
|
+
end
|
136
|
+
|
137
|
+
should 'have the custom_id attribute' do
|
138
|
+
assert_equal(test_candidate[:custom_id], @candidate.custom_id)
|
139
|
+
end
|
140
|
+
|
141
|
+
should 'have the reports attribute' do
|
142
|
+
assert_equal(test_candidate[:report_ids], @candidate.reports.json)
|
143
|
+
assert(@candidate.reports.is_a?(APIList))
|
144
|
+
end
|
145
|
+
|
146
|
+
should 'have the geos attribute' do
|
147
|
+
assert_equal(test_candidate[:geo_ids], @candidate.geos.json)
|
148
|
+
assert(@candidate.geos.is_a?(APIList))
|
149
|
+
end
|
150
|
+
|
151
|
+
should 'have the documents attribute' do
|
152
|
+
assert(!@candidate.documents.any?)
|
153
|
+
assert(@candidate.documents.is_a?(DocumentList))
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
should 'be registered' do
|
159
|
+
assert(APIClass.subclasses.include?(Candidate))
|
160
|
+
assert_equal(Candidate, APIClass.subclass_fetch("candidate"))
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Checkr
|
4
|
+
class CountyCriminalSearchTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
@county_criminal_search_url = "#{Checkr.api_base}/v1/county_criminal_searches"
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'CountyCriminalSearch class' do
|
10
|
+
should 'be retrieveable' do
|
11
|
+
id = "county_criminal_search_id"
|
12
|
+
@mock.expects(:get).once.with("#{@county_criminal_search_url}/#{id}", anything, anything).returns(test_response(test_county_criminal_search))
|
13
|
+
county_criminal_search = CountyCriminalSearch.retrieve(id)
|
14
|
+
assert(county_criminal_search.is_a?(CountyCriminalSearch))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'CountyCriminalSearch instance' do
|
19
|
+
should 'be refreshable' do
|
20
|
+
@mock.expects(:get).once.with("#{@county_criminal_search_url}/#{test_county_criminal_search[:id]}", anything, anything).returns(test_response(test_county_criminal_search))
|
21
|
+
county_criminal_search = CountyCriminalSearch.new(test_county_criminal_search[:id])
|
22
|
+
county_criminal_search.refresh
|
23
|
+
assert_equal(test_county_criminal_search[:status], county_criminal_search.status)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
context 'Retrieved CountyCriminalSearch instance' do
|
29
|
+
setup do
|
30
|
+
@mock.expects(:get).once.returns(test_response(test_county_criminal_search))
|
31
|
+
@county_criminal_search = CountyCriminalSearch.retrieve('county_criminal_search_id')
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'have the id attribute' do
|
35
|
+
assert_equal(test_county_criminal_search[:id], @county_criminal_search.id)
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'have the object attribute' do
|
39
|
+
assert_equal(test_county_criminal_search[:object], @county_criminal_search.object)
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'have the uri attribute' do
|
43
|
+
assert_equal(test_county_criminal_search[:uri], @county_criminal_search.uri)
|
44
|
+
end
|
45
|
+
|
46
|
+
should 'have the status attribute' do
|
47
|
+
assert_equal(test_county_criminal_search[:status], @county_criminal_search.status)
|
48
|
+
end
|
49
|
+
|
50
|
+
should 'have the created_at attribute' do
|
51
|
+
assert_equal(test_county_criminal_search[:created_at], @county_criminal_search.created_at)
|
52
|
+
end
|
53
|
+
|
54
|
+
should 'have the completed_at attribute' do
|
55
|
+
assert_equal(test_county_criminal_search[:completed_at], @county_criminal_search.completed_at)
|
56
|
+
end
|
57
|
+
|
58
|
+
should 'have the turnaround_time attribute' do
|
59
|
+
assert_equal(test_county_criminal_search[:turnaround_time], @county_criminal_search.turnaround_time)
|
60
|
+
end
|
61
|
+
|
62
|
+
should 'have the county attribute' do
|
63
|
+
assert_equal(test_county_criminal_search[:county], @county_criminal_search.county)
|
64
|
+
end
|
65
|
+
|
66
|
+
should 'have the state attribute' do
|
67
|
+
assert_equal(test_county_criminal_search[:state], @county_criminal_search.state)
|
68
|
+
end
|
69
|
+
|
70
|
+
should 'have the records attribute' do
|
71
|
+
assert_equal(test_county_criminal_search[:records], @county_criminal_search.records)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
should 'be registered' do
|
77
|
+
assert(APIClass.subclasses.include?(CountyCriminalSearch))
|
78
|
+
assert_equal(CountyCriminalSearch, APIClass.subclass_fetch("county_criminal_search"))
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Checkr
|
4
|
+
class DocumentTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
@candidate = Candidate.construct(test_candidate)
|
7
|
+
@document_url = "#{Checkr.api_base}#{@candidate.path}/documents"
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'Document class' do
|
11
|
+
should 'be createable' do
|
12
|
+
new_doc = {
|
13
|
+
:type => "driver_license",
|
14
|
+
:file => "fake_file"
|
15
|
+
}
|
16
|
+
@mock.expects(:post).once.with(@document_url, anything, new_doc).returns(test_response(test_document))
|
17
|
+
document = @candidate.documents.create(new_doc)
|
18
|
+
assert(document.is_a?(Document))
|
19
|
+
assert_equal(test_document[:id], document.id)
|
20
|
+
end
|
21
|
+
|
22
|
+
should 'be listable' do
|
23
|
+
@mock.expects(:get).once.with(@document_url, anything, anything).returns(test_response(test_document_list))
|
24
|
+
|
25
|
+
documents = @candidate.documents.all
|
26
|
+
|
27
|
+
assert(documents.is_a?(DocumentList))
|
28
|
+
documents.each do |document|
|
29
|
+
assert(document.is_a?(Document))
|
30
|
+
end
|
31
|
+
assert(documents.length > 0)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'Document instance' do
|
36
|
+
# should 'be refreshable' do
|
37
|
+
# @mock.expects(:get).once.with("#{@document_url}/#{test_document[:id]}", anything, anything).returns(test_response(test_document))
|
38
|
+
# document = Document.new(test_document[:id])
|
39
|
+
# document.refresh
|
40
|
+
# assert_equal(test_document[:filename], document.filename)
|
41
|
+
# end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
context 'Constructed Document instance' do
|
46
|
+
setup do
|
47
|
+
@document = Document.construct(test_document)
|
48
|
+
end
|
49
|
+
|
50
|
+
should 'have the id attribute' do
|
51
|
+
assert_equal(test_document[:id], @document.id)
|
52
|
+
end
|
53
|
+
|
54
|
+
should 'have the object attribute' do
|
55
|
+
assert_equal(test_document[:object], @document.object)
|
56
|
+
end
|
57
|
+
|
58
|
+
should 'have the uri attribute' do
|
59
|
+
assert_equal(test_document[:uri], @document.uri)
|
60
|
+
end
|
61
|
+
|
62
|
+
should 'have the created_at attribute' do
|
63
|
+
assert_equal(test_document[:created_at], @document.created_at)
|
64
|
+
end
|
65
|
+
|
66
|
+
should 'have the download_uri attribute' do
|
67
|
+
assert_equal(test_document[:download_uri], @document.download_uri)
|
68
|
+
end
|
69
|
+
|
70
|
+
should 'have the filesize attribute' do
|
71
|
+
assert_equal(test_document[:filesize], @document.filesize)
|
72
|
+
end
|
73
|
+
|
74
|
+
should 'have the filename attribute' do
|
75
|
+
assert_equal(test_document[:filename], @document.filename)
|
76
|
+
end
|
77
|
+
|
78
|
+
should 'have the content_type attribute' do
|
79
|
+
assert_equal(test_document[:content_type], @document.content_type)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
should 'be registered' do
|
85
|
+
assert(APIClass.subclasses.include?(Document))
|
86
|
+
assert_equal(Document, APIClass.subclass_fetch("document"))
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|