summaryrefslogtreecommitdiff
path: root/test/functional/v1/certs_controller_test.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2014-04-25 12:15:37 +0200
committerazul <azul@riseup.net>2014-04-25 12:15:37 +0200
commit76ad25ba0ee344f185f8e8cdfe066685cd3b0447 (patch)
treed8122b5b5144c917f5e1924c1428a3a871e94149 /test/functional/v1/certs_controller_test.rb
parent2b6200f508ddb8e1c8a76fd3778881c39d787d8d (diff)
parentbe81b7430e0a2046125be7c3a4b01b8725f4afe6 (diff)
Merge pull request #148 from azul/feature/api-quota-support
Feature/api quota support + current_user null pattern
Diffstat (limited to 'test/functional/v1/certs_controller_test.rb')
-rw-r--r--test/functional/v1/certs_controller_test.rb46
1 files changed, 24 insertions, 22 deletions
diff --git a/test/functional/v1/certs_controller_test.rb b/test/functional/v1/certs_controller_test.rb
index 2c70e52..fb8e9c4 100644
--- a/test/functional/v1/certs_controller_test.rb
+++ b/test/functional/v1/certs_controller_test.rb
@@ -2,43 +2,45 @@ 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)
+ test "send unlimited cert without login" do
+ with_config allow_anonymous_certs: true do
+ cert = expect_cert('UNLIMITED')
get :show
assert_response :success
assert_equal cert.to_s, @response.body
end
end
- test "send unlimited cert" do
- with_config allow_unlimited_certs: true do
+ test "send limited cert" do
+ with_config allow_limited_certs: true do
login
- cert = stub :to_s => "unlimited cert"
- ClientCertificate.expects(:new).with(:prefix => APP_CONFIG[:unlimited_cert_prefix]).returns(cert)
+ cert = expect_cert('LIMITED')
get :show
assert_response :success
assert_equal cert.to_s, @response.body
end
end
- test "login required if anonymous certs disabled" do
- with_config allow_anonymous_certs: false do
- get :show
- assert_response :redirect
- end
+ test "send unlimited cert" do
+ 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 "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
+ test "redirect if no eip service offered" do
+ get :show
+ assert_response :redirect
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