Permalink
Browse files

create mini test tool for COVR

  • Loading branch information...
1 parent 6f70433 commit e2298b7b8fe1e5ddaa696d93ec1acba6c22b04a1 Alex Mekelburg committed Mar 3, 2014
View
@@ -1,7 +1,5 @@
source 'http://rubygems.org'
-gem 'lolsoap'
-
gem "rake", "10.0.3"
gem "figaro"
@@ -27,7 +25,9 @@ gem 'jquery-rails', '~> 2.1'
gem 'wkhtmltopdf-binary'
gem 'wicked_pdf'
-gem 'savon'
+gem 'rest-client'
+gem 'diffy'
+
group :development, :test do
gem "rspec-rails", "~> 2.10.1"
View
@@ -33,9 +33,6 @@ GEM
activesupport
builder
json
- akami (1.2.1)
- gyoku (>= 0.4.0)
- nokogiri
arel (3.0.2)
assert_difference (0.5.0)
authlogic (3.3.0)
@@ -87,6 +84,7 @@ GEM
activerecord (>= 2.1.0, < 4)
delayed_job (~> 3.0)
diff-lcs (1.1.3)
+ diffy (3.0.2)
domain_name (0.5.12)
unf (>= 0.0.5, < 1.0.0)
dotenv (0.7.0)
@@ -106,18 +104,13 @@ GEM
rails (>= 3, < 5)
gherkin (2.11.8)
multi_json (~> 1.3)
- gyoku (1.1.1)
- builder (>= 2.1.2)
haml (4.0.2)
tilt
highline (1.6.19)
hike (1.2.2)
hpricot (0.8.6)
http-cookie (1.0.1)
domain_name (~> 0.5)
- httpi (2.1.0)
- rack
- rubyntlm (~> 0.3.2)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.3.0)
@@ -127,8 +120,6 @@ GEM
ledermann-rails-settings (2.0.3)
activerecord (~> 3.1)
libv8 (3.11.8.17)
- lolsoap (0.5.1)
- nokogiri (~> 1.5)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -156,7 +147,6 @@ GEM
net-ssh (>= 2.6.5)
newrelic_rpm (3.6.0.83)
nokogiri (1.5.9)
- nori (2.3.0)
ntlm-http (0.1.1)
paperclip (3.4.1)
activemodel (>= 3.0.0)
@@ -195,6 +185,8 @@ GEM
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.4)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
rr (0.10.11)
rspec (2.10.0)
rspec-core (~> 2.10.0)
@@ -212,7 +204,6 @@ GEM
rspec-spies (2.1.1)
rspec (~> 2.0)
rspec-spies
- rubyntlm (0.3.4)
rubyzip (0.9.9)
rvm-capistrano (1.3.0)
capistrano (>= 2.0.0)
@@ -221,14 +212,6 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
- savon (2.3.3)
- akami (~> 1.2.0)
- builder (>= 2.1.2)
- gyoku (~> 1.1.0)
- httpi (~> 2.1.0)
- nokogiri (>= 1.4.0)
- nori (~> 2.3.0)
- wasabi (~> 3.2.2)
selenium-webdriver (2.32.1)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
@@ -255,10 +238,6 @@ GEM
unf (0.1.1)
unf_ext
unf_ext (0.0.6)
- wasabi (3.2.3)
- httpi (~> 2.0)
- mime-types (< 2.0.0)
- nokogiri (>= 1.4.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
@@ -286,6 +265,7 @@ DEPENDENCIES
daemons (= 1.0.10)
database_cleaner
delayed_job_active_record
+ diffy
dotenv-rails
factory_girl_rails
figaro
@@ -294,7 +274,6 @@ DEPENDENCIES
jquery-rails (~> 2.1)
json
ledermann-rails-settings
- lolsoap
mechanize (= 2.7.1)
mysql2
newrelic_rpm (= 3.6.0.83)
@@ -304,13 +283,13 @@ DEPENDENCIES
rails-i18n
rails_config
rake (= 10.0.3)
+ rest-client
rr (= 0.10.11)
rspec-rails (~> 2.10.1)
rspec-spies (= 2.1.1)
rubyzip
rvm-capistrano
sass-rails
- savon
sqlite3
therubyracer
treetop (= 1.4.10)
View
@@ -0,0 +1,3 @@
+module Integrations
+
+end
@@ -0,0 +1,76 @@
+# require './lib/integrations/ca/covr/ca_covr_tests'
+
+class CaCovrTests
+
+ TESTS = %w(success-max success-min fail-max-lastname fail-min-agencycode fail-min-disclosures fail-min-residentid)
+
+ attr_reader :test_name
+ attr_reader :response
+ attr_writer :url
+ attr_writer :key
+
+ def initialize(test_name)
+ raise "Test #{test_name} not supported" unless TESTS.include?(test_name.to_s)
+ @test_name = test_name
+ end
+
+ TESTS.each do |t|
+ define_method("self.test_#{t.underscore}") do
+ self.new(t).test!
+ end
+ end
+
+ def test!
+ make_request
+ compare_response
+ return_test_results
+ end
+
+ def make_request
+ @response = Integrations::Soap.make_request(url, xml_request_contents)
+ end
+
+ def compare_resposne
+ @expected_response = xml_response_contents
+ @diff = Diffy::Diff.new(@response, @expected_response)
+ end
+
+ def return_test_results
+ puts @diff
+ puts "#{test_name} test done."
+ end
+
+ def url
+ @url ||= "https://covrapitest.sos.ca.gov/PostingEntityInterfaceService.svc"
+ end
+
+ def key
+ @key ||= "d2DE1Nht8I"
+ end
+
+ def xml_request_contents
+ self.class.xml_request_contents(self.test_name)
+ end
+
+ def xml_response_contents
+ self.class.xml_response_contents(self.test_name)
+ end
+
+
+ def self.xml_request_contents(test_name)
+ contents = ''
+ File.open(Rails.root.join("lib/integrations/ca/covr/fixtures","#{test_name}-req.xml")) do |f|
+ contents = f.read
+ end
+ return contents
+ end
+
+ def self.xml_response_contents(test_name)
+ contents = ''
+ File.open(Rails.root.join("lib/integrations/ca/covr/fixtures","#{test_name}-resp.xml")) do |f|
+ contents = f.read
+ end
+ return contents
+ end
+
+end
@@ -3,7 +3,14 @@ curl -d @soapreq.xml -H "Content-Type:application/soap+xml;charset=UTF-8" https:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/IPostingEntityInterfaceService/GetTokenNumberResponse</a:Action></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetTokenNumberResponse xmlns="http://tempuri.org/"><GetTokenNumberResult><Token>F9B91DDE-BD95-41Z-905Z-9143511C32C27C190A</Token><Success>true</Success><ErrorCode>0</ErrorCode><ErrorMessage/></GetTokenNumberResult></GetTokenNumberResponse></s:Body>
+<!--
+Step 2 URL: http://covrtest.sos.ca.gov/?language=en-US&t=p&CovrAgencyKey=RTV&PostingAgencyRecordId=F9B91DDE-BD95-41Z-905Z-9143511C32C27C190A
+//-->
+
+<!-- Step 2 URL:
+http://covrtest.sos.ca.gov/?language=en-US&t=p&CovrAgencyKey=RTV&PostingAgencyRecordId=81BC7465-6937-41Z-905Z-9143511C05C12C400A
+//-->
Ethnicity/Race
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<s:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tem="http://tempuri.org/" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:ins0="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
+ <s:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Action>http://tempuri.org/IPostingEntityInterfaceService/GetTokenNumber</wsa:Action>
+ <wsa:To>https://covrapitest.sos.ca.gov/PostingEntityInterfaceService.svc</wsa:To>
+ </s:Header>
+ <s:Body>
+ <tem:GetTokenNumber>
+ <tem:postingEntity>
+ <tem:PostingAgencyKey>d2DE1Nht8I</tem:PostingAgencyKey>
+ <tem:CovrAgencyKey>RTV</tem:CovrAgencyKey>
+
+ <tem:IsUsCitizen>1</tem:IsUsCitizen>
+ <tem:IsEighteenOrOlder>1</tem:IsEighteenOrOlder>
+ <tem:IsDisclosureDisplayed>1</tem:IsDisclosureDisplayed>
+
+ <tem:VoterResidentType>1</tem:VoterResidentType>
+
+ <tem:DobDay>1</tem:DobDay>
+ <tem:DobMonth>1</tem:DobMonth>
+ <tem:DobYear>1980</tem:DobYear>
+
+ <tem:EthnicityId>1</tem:EthnicityId>
+ <tem:ElectionMaterialLanguageId>1</tem:ElectionMaterialLanguageId>
+
+
+
+
+ <tem:PrefixId>1</tem:PrefixId>
+ <tem:CurrentFirstName>John</tem:CurrentFirstName>
+ <tem:CurrentMiddleName>A</tem:CurrentMiddleName>
+ <tem:CurrentLastName>!Doe</tem:CurrentLastName>
+
+ <tem:PreviousFirstName>Jonathan</tem:PreviousFirstName>
+ <tem:PreviousMiddleName>Z</tem:PreviousMiddleName>
+ <tem:PreviousLastName>Zoe</tem:PreviousLastName>
+
+ <tem:IsHomeAddress>1</tem:IsHomeAddress>
+ <tem:HomeAddressStreetLine1>401 Market St</tem:HomeAddressStreetLine1>
+ <tem:HomeAddressStreetLine2>APT 1</tem:HomeAddressStreetLine2>
+ <tem:HomeAddressCity>San Francisco</tem:HomeAddressCity>
+ <tem:HomeAddressState>California</tem:HomeAddressState>
+ <tem:HomeAddressZip>94111</tem:HomeAddressZip>
+
+ <tem:IsMailingAddress>1</tem:IsMailingAddress>
+ <tem:MailingAddressStreetLine1>402 Market St</tem:MailingAddressStreetLine1>
+ <tem:MailingAddressStreetLine2>APT 2</tem:MailingAddressStreetLine2>
+ <tem:MailingAddressCity>San Francisco</tem:MailingAddressCity>
+ <tem:MailingAddressState>California</tem:MailingAddressState>
+ <tem:MailingAddressZip>9411</tem:MailingAddressZip>
+
+ <tem:IsPreviouslyRegistered>1</tem:IsPreviouslyRegistered>
+ <tem:PreviousAddressStreetLine1>1 Main St</tem:PreviousAddressStreetLine1>
+ <tem:PreviousAddressStreetLine2>APT 3</tem:PreviousAddressStreetLine2>
+ <tem:PreviousAddressCity>Boston</tem:PreviousAddressCity>
+ <tem:PreviousAddressState>MA</tem:PreviousAddressState>
+ <tem:PreviousAddressZip>02110</tem:PreviousAddressZip>
+
+ <tem:PhoneNumber>1231231234</tem:PhoneNumber>
+ <tem:EmailId>registrant@example.com</tem:EmailId>
+ <tem:EmailIdConfirmation>registrant@example.com</tem:EmailIdConfirmation>
+
+
+
+ </tem:postingEntity>
+ </tem:GetTokenNumber>
+ </s:Body>
+</s:Envelope>
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<s:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tem="http://tempuri.org/" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:ins0="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
+ <s:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Action>http://tempuri.org/IPostingEntityInterfaceService/GetTokenNumber</wsa:Action>
+ <wsa:To>https://covrapitest.sos.ca.gov/PostingEntityInterfaceService.svc</wsa:To>
+ </s:Header>
+ <s:Body>
+ <tem:GetTokenNumber>
+ <tem:postingEntity>
+ <tem:PostingAgencyKey>a</tem:PostingAgencyKey>
+ <tem:CovrAgencyKey>RTV</tem:CovrAgencyKey>
+
+ <tem:IsUsCitizen>1</tem:IsUsCitizen>
+ <tem:IsEighteenOrOlder>1</tem:IsEighteenOrOlder>
+ <tem:IsDisclosureDisplayed>1</tem:IsDisclosureDisplayed>
+
+ <tem:VoterResidentType>1</tem:VoterResidentType>
+
+ <tem:DobDay>1</tem:DobDay>
+ <tem:DobMonth>1</tem:DobMonth>
+ <tem:DobYear>1980</tem:DobYear>
+
+ <tem:EthnicityId>1</tem:EthnicityId>
+ <tem:ElectionMaterialLanguageId>1</tem:ElectionMaterialLanguageId>
+
+ </tem:postingEntity>
+ </tem:GetTokenNumber>
+ </s:Body>
+</s:Envelope>
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<s:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tem="http://tempuri.org/" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:ins0="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
+ <s:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Action>http://tempuri.org/IPostingEntityInterfaceService/GetTokenNumber</wsa:Action>
+ <wsa:To>https://covrapitest.sos.ca.gov/PostingEntityInterfaceService.svc</wsa:To>
+ </s:Header>
+ <s:Body>
+ <tem:GetTokenNumber>
+ <tem:postingEntity>
+ <tem:PostingAgencyKey>d2DE1Nht8I</tem:PostingAgencyKey>
+ <tem:CovrAgencyKey>RTV</tem:CovrAgencyKey>
+
+ <tem:IsUsCitizen>1</tem:IsUsCitizen>
+ <tem:IsEighteenOrOlder>1</tem:IsEighteenOrOlder>
+ <!--
+ <tem:IsDisclosureDisplayed>1</tem:IsDisclosureDisplayed>
+ //-->
+
+ <tem:VoterResidentType>1</tem:VoterResidentType>
+
+ <tem:DobDay>1</tem:DobDay>
+ <tem:DobMonth>1</tem:DobMonth>
+ <tem:DobYear>1980</tem:DobYear>
+
+ <tem:EthnicityId>1</tem:EthnicityId>
+ <tem:ElectionMaterialLanguageId>1</tem:ElectionMaterialLanguageId>
+
+ </tem:postingEntity>
+ </tem:GetTokenNumber>
+ </s:Body>
+</s:Envelope>
Oops, something went wrong.

0 comments on commit e2298b7

Please sign in to comment.