summaryrefslogtreecommitdiff
path: root/test/functional/v1
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-04-17 19:27:47 +0200
committerAzul <azul@leap.se>2014-04-17 19:27:47 +0200
commit7a9ece43bd61246b450471ed6bb1089570321e38 (patch)
treea20362ee5512e160498902ef7c0a094b3135201d /test/functional/v1
parent614745c84cab37dd03f2bd8f06160fd01c7fabdb (diff)
make use of the UnauthorizedUser
Null Pattern for current_user - use it to get rid of some conditionals
Diffstat (limited to 'test/functional/v1')
-rw-r--r--test/functional/v1/certs_controller_test.rb54
1 files changed, 27 insertions, 27 deletions
diff --git a/test/functional/v1/certs_controller_test.rb b/test/functional/v1/certs_controller_test.rb
index 2c70e52..3631947 100644
--- a/test/functional/v1/certs_controller_test.rb
+++ b/test/functional/v1/certs_controller_test.rb
@@ -3,42 +3,42 @@ require 'test_helper'
class V1::CertsControllerTest < ActionController::TestCase
test "send limited cert without login" do
- with_config allow_limited_certs: true, allow_anonymous_certs: true do
- cert = stub :to_s => "limited cert"
- ClientCertificate.expects(:new).with(:prefix => APP_CONFIG[:limited_cert_prefix]).returns(cert)
- get :show
- assert_response :success
- assert_equal cert.to_s, @response.body
- end
+ cert = expect_cert('LIMITED')
+ get :show
+ assert_response :success
+ assert_equal cert.to_s, @response.body
+ end
+
+ test "send limited cert" do
+ login
+ cert = expect_cert('LIMITED')
+ get :show
+ assert_response :success
+ assert_equal cert.to_s, @response.body
end
test "send unlimited cert" do
- with_config allow_unlimited_certs: true do
- login
- cert = stub :to_s => "unlimited cert"
- ClientCertificate.expects(:new).with(:prefix => APP_CONFIG[:unlimited_cert_prefix]).returns(cert)
- get :show
- assert_response :success
- assert_equal cert.to_s, @response.body
- end
+ login effective_service_level: ServiceLevel.new(id: 2)
+ cert = expect_cert('UNLIMITED')
+ get :show
+ assert_response :success
+ assert_equal cert.to_s, @response.body
end
- test "login required if anonymous certs disabled" do
- with_config allow_anonymous_certs: false do
+ test "redirect if no eip service offered" do
+ with_config({service_levels: {0 => {services: []}}}) do
get :show
assert_response :redirect
end
end
- test "send limited cert" do
- with_config allow_limited_certs: true, allow_unlimited_certs: false do
- login
- cert = stub :to_s => "real cert"
- ClientCertificate.expects(:new).with(:prefix => APP_CONFIG[:limited_cert_prefix]).returns(cert)
- get :show
- assert_response :success
- assert_equal cert.to_s, @response.body
- end
- end
+ protected
+ def expect_cert(prefix)
+ cert = stub :to_s => "#{prefix.downcase} cert"
+ ClientCertificate.expects(:new).
+ with(:prefix => prefix).
+ returns(cert)
+ return cert
+ end
end