require File.dirname(__FILE__) + "/../test_helper" class ClientCertificateTest < Test::Unit::TestCase def setup # skip the tests if we're not sending to a HTTPS location (i.e PROD) return true if @@credentials.config['location'].match(/https/i).nil? end def test_cert_raises_without_key assert_raises(ArgumentError) { transporter = ::EWS::Transporter.new(@@credentials.config['location'], { :client_cert => File.dirname(__FILE__)+"/../samples/rsa_cert.pem", }) } end def test_rsa_raises_with_non_matching_key assert_raises(OpenSSL::PKey::RSAError) { transporter = ::EWS::Transporter.new(@@credentials.config['location'], { :client_cert => File.dirname(__FILE__)+"/../samples/rsa_cert.pem", :client_key => File.dirname(__FILE__)+"/../samples/dsa_key.pem" }) } end def test_dsa_raises_with_non_matching_key assert_raises(OpenSSL::PKey::DSAError) { transporter = ::EWS::Transporter.new(@@credentials.config['location'], { :client_cert => File.dirname(__FILE__)+"/../samples/dsa_cert.pem", :client_key => File.dirname(__FILE__)+"/../samples/rsa_key.pem" }) } end def test_rsa_certificate transporter = nil assert_nothing_raised { transporter = ::EWS::Transporter.new(@@credentials.config['location'], { :client_cert => File.dirname(__FILE__)+"/../samples/rsa_cert.pem", :client_key => File.dirname(__FILE__)+"/../samples/rsa_key.pem" }) } request = EWS::Transaction::Request.new(basic_params) response = transporter.submit(request) assert response.approved? end def test_dsa_certificate transporter = nil assert_nothing_raised { transporter = ::EWS::Transporter.new(@@credentials.config['location'], { :client_cert => File.dirname(__FILE__)+"/../samples/dsa_cert.pem", :client_key => File.dirname(__FILE__)+"/../samples/dsa_key.pem" }) } request = EWS::Transaction::Request.new(basic_params) response = transporter.submit(request) assert response.approved? end end