From e8de4f2f9e5dc77710692e3f44b60555e91b50b6 Mon Sep 17 00:00:00 2001 From: raecoo Date: Mon, 29 Aug 2011 20:07:57 +0800 Subject: [PATCH] renew the test codes --- oa-enterprise/oa-enterprise.gemspec | 1 + .../spec/omniauth/strategies/saml_spec.rb | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 oa-enterprise/spec/omniauth/strategies/saml_spec.rb diff --git a/oa-enterprise/oa-enterprise.gemspec b/oa-enterprise/oa-enterprise.gemspec index 540176c55..0eb4c47ae 100644 --- a/oa-enterprise/oa-enterprise.gemspec +++ b/oa-enterprise/oa-enterprise.gemspec @@ -8,6 +8,7 @@ Gem::Specification.new do |gem| gem.add_dependency 'oa-core', OmniAuth::Version::STRING gem.add_dependency 'pyu-ruby-sasl', '~> 0.0.3.1' gem.add_dependency 'rubyntlm', '~> 0.1.1' + gem.add_dependency 'uuid' gem.add_dependency 'XMLCanonicalizer', '~> 1.0.1' gem.add_development_dependency 'rack-test', '~> 0.5' gem.add_development_dependency 'rake', '~> 0.8' diff --git a/oa-enterprise/spec/omniauth/strategies/saml_spec.rb b/oa-enterprise/spec/omniauth/strategies/saml_spec.rb new file mode 100644 index 000000000..2bd1776f8 --- /dev/null +++ b/oa-enterprise/spec/omniauth/strategies/saml_spec.rb @@ -0,0 +1,37 @@ +require File.expand_path('../../../spec_helper', __FILE__) + +describe OmniAuth::Strategies::SAML, :type => :strategy do + + include OmniAuth::Test::StrategyTestCase + + def strategy + [OmniAuth::Strategies::SAML, { + :assertion_consumer_service_url => "http://consumer.service.url/auth/saml/callback", + :issuer => "https://saml.issuer.url/issuers/29490", + :idp_sso_target_url => "https://idp.sso.target_url/signon/29490", + :idp_cert_fingerprint => "E7:91:B2:E1:4C:65:2C:49:F3:33:74:0A:58:5A:7E:55:F7:15:7A:33", + :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" + }] + end + + describe 'GET /auth/saml' do + before do + get '/auth/saml' + end + + it 'should get authentication page' do + last_response.should be_redirect + end + end + + describe 'POST /auth/saml/callback' do + + it 'should raise ArgumentError exception without the SAMLResponse parameter' do + post '/auth/saml/callback' + last_response.should be_redirect + last_response.location.should == '/auth/failure?message=invalid_ticket' + end + + end + +end \ No newline at end of file