sterling_api 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,143 @@
1
+ require 'rubygems'
2
+
3
+ ENV["RAILS_ENV"] = "test"
4
+ require File.expand_path(File.dirname(__FILE__) + "../../../../../config/environment")
5
+ require 'test_help'
6
+
7
+ require 'test/unit'
8
+ require 'active_support'
9
+ require 'active_support/test_case'
10
+ require File.dirname(__FILE__) + '/../lib/sterling_api'
11
+ require File.dirname(__FILE__) + '/../lib/sterling_api/xml_samples'
12
+ require 'rexml/document'
13
+
14
+ def address_hash(options={})
15
+ {
16
+ :type => 'current',
17
+ :valid_from => '2010-01-02',
18
+ :valid_to => '2020-12-31',
19
+ :municipality => 'Madison',
20
+ :region => 'WI',
21
+ :postal_code => '53711',
22
+ :country_code => 'US',
23
+ :address1 => '1234 Main St',
24
+ :address2 => '',
25
+ }.merge(options)
26
+ end
27
+
28
+
29
+ #
30
+ # xml: the XML string to search
31
+ #
32
+ # node_name: the name of the node to find in given XML
33
+ #
34
+ # options:
35
+ # :attributes => { :attr_name => :attr_value }
36
+ #
37
+ # :content => 'content of this node'
38
+ #
39
+ # :child => {
40
+ # :node_name => 'ChildNodeName',
41
+ # :attributes => { :attr_name => :attr_value },
42
+ # :content => 'Child content'
43
+ # }
44
+ #
45
+ def assert_node(xml, node_name, options={})
46
+ # we're using REXML here because it seems that neither Nokogiri nor Hpricot
47
+ # parse the multi-element XPath query properly, returning false positives.
48
+ # I did validate the query against an external XPath validator too.
49
+ doc = REXML::Document.new(xml)
50
+ q = xpath_query_for(node_name, options)
51
+ assert REXML::XPath.match(doc, q).size > 0, "Could not find < #{q} > in:\n#{xml}"
52
+ end
53
+
54
+ def assert_no_node(xml, node_name, options={})
55
+ doc = REXML::Document.new(xml)
56
+ q = xpath_query_for(node_name, options)
57
+ assert REXML::XPath.match(doc, q).empty?, "Expected not to find < #{q} > in:\n#{xml}"
58
+ end
59
+
60
+ def background_check_hash(options={})
61
+ {
62
+ :account => '123456',
63
+ :password => 'Secret',
64
+ :position_applied_for => 'Pastor',
65
+ :package_id => '2112',
66
+ :client_reference1 => '',
67
+ :client_reference2 => '',
68
+ :order_as_user_id => 'joeuser',
69
+ :order_as_account_suffix => 'TST',
70
+ :contact_email => 'me@example.com',
71
+ :licenses => [],
72
+ :person_names => [],
73
+ :postal_addresses => [],
74
+ }.merge(options)
75
+ end
76
+
77
+ def license_hash(options={})
78
+ {
79
+ :valid_from => '2001-02-03',
80
+ :valid_to => '2004-05-06',
81
+ :country_code => 'US',
82
+ :license_number => 'A1B2C3D4',
83
+ :license_region => 'CA',
84
+ }.merge(options)
85
+ end
86
+
87
+ def name_hash(options={})
88
+ {
89
+ :type => 'subject',
90
+ :first_name => 'Joe',
91
+ :middle_name => 'X',
92
+ :last_name => 'Tester',
93
+ }.merge(options)
94
+ end
95
+
96
+ def ssnv_hash(options={})
97
+ {
98
+ :ssn => '123456789',
99
+ :date_of_birth => '1950-01-02'
100
+ }.merge(options)
101
+ end
102
+
103
+ #
104
+ # constructs an XPath query like:
105
+ # //License[@validFrom="1999-01-01" and @validTo="2001-02-03"]
106
+ #
107
+ # or
108
+ #
109
+ # //LicenseNumber[.="1234ABC"]
110
+ #
111
+ # or
112
+ #
113
+ # //PersonName[@type="subject"]/GivenName[.="First1"]
114
+ #
115
+ def xpath_query_for(node_name, options={})
116
+ xpath_query = "#{options[:is_child] ? '/' : '//'}#{node_name}"
117
+ extras = []
118
+ extras += [%Q{.="#{options[:content]}"}] if options[:content]
119
+
120
+ extras += options[:attributes].map do |k,v|
121
+ %Q{@#{k}="#{v}"}
122
+ end if options[:attributes]
123
+
124
+ xpath_query << "[#{extras.join(' and ')}]" unless extras.empty?
125
+
126
+ if options[:child]
127
+ child = options.delete(:child)
128
+ child_options = {
129
+ :is_child => true,
130
+ :attributes => child[:attributes],
131
+ :content => child[:content],
132
+ :child => child[:child]
133
+ }
134
+ return xpath_query << "#{xpath_query_for(child[:node_name], child_options)}"
135
+ else
136
+ xpath_query
137
+ end
138
+ end
139
+
140
+ def xtest(*args)
141
+ file = File.basename(caller.first)
142
+ puts "Disabled test [#{file}]: #{args.first}"
143
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sterling_api
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 4
10
+ version: 1.0.4
11
+ platform: ruby
12
+ authors:
13
+ - Manny Rodriguez
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-07-30 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: nokogiri
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: net/http
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: net/https
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ description: For requesting background checks
64
+ email:
65
+ - manny@7compass.com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files: []
71
+
72
+ files:
73
+ - .gitignore
74
+ - Gemfile
75
+ - MIT-LICENSE
76
+ - README.md
77
+ - Rakefile
78
+ - doc/AdminRequest.xsd
79
+ - doc/AdminResponse.xsd
80
+ - doc/CPBackgroundReports.xsd
81
+ - doc/CPScreenings.xsd
82
+ - doc/admin.wsdl
83
+ - init.rb
84
+ - install.rb
85
+ - lib/sterling_api.rb
86
+ - lib/sterling_api/background_check.rb
87
+ - lib/sterling_api/password_change.rb
88
+ - lib/sterling_api/remote_actions.rb
89
+ - lib/sterling_api/version.rb
90
+ - lib/sterling_api/xml_helper.rb
91
+ - lib/sterling_api/xml_samples.rb
92
+ - lib/tasks/sterling_api_tasks.rake
93
+ - sterling_api.gemspec
94
+ - test/background_check_test.rb
95
+ - test/password_change_test.rb
96
+ - test/remote_actions_test.rb
97
+ - test/sterling_api_test.rb
98
+ - test/test_helper.rb
99
+ - uninstall.rb
100
+ has_rdoc: true
101
+ homepage: https://github.com/7compass/sterling_api
102
+ licenses:
103
+ - MIT
104
+ post_install_message:
105
+ rdoc_options: []
106
+
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 3
124
+ segments:
125
+ - 0
126
+ version: "0"
127
+ requirements: []
128
+
129
+ rubyforge_project: sterling_api
130
+ rubygems_version: 1.3.7
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Sterling Api
134
+ test_files:
135
+ - test/background_check_test.rb
136
+ - test/password_change_test.rb
137
+ - test/remote_actions_test.rb
138
+ - test/sterling_api_test.rb
139
+ - test/test_helper.rb