summaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-15 11:17:47 +0200
committerAzul <azul@leap.se>2014-05-19 14:24:47 +0200
commit71dcf3f4e5d423b78b47f675297fc98b28ef3442 (patch)
tree7415f1f5825abf2d21b2232ccd1ff820f1f513d2 /test/functional
parent5dd6c1529f8f4fc5089c71b0a44e360acaea900d (diff)
SmtpCertsController, routes and tests
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/v1/smtp_certs_controller_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/functional/v1/smtp_certs_controller_test.rb b/test/functional/v1/smtp_certs_controller_test.rb
new file mode 100644
index 0000000..f9ba26f
--- /dev/null
+++ b/test/functional/v1/smtp_certs_controller_test.rb
@@ -0,0 +1,35 @@
+require 'test_helper'
+
+class V1::SmtpCertsControllerTest < ActionController::TestCase
+
+ test "no smtp cert without login" do
+ with_config allow_anonymous_certs: true do
+ get :show, format: 'json'
+ assert_access_denied
+ end
+ end
+
+ test "require service level with email" do
+ login
+ get :show
+ assert_access_denied
+ end
+
+ test "send cert with username" do
+ login effective_service_level: ServiceLevel.new(id: 2)
+ cert = expect_cert(@current_user.email_address)
+ get :show
+ assert_response :success
+ assert_equal cert.to_s, @response.body
+ 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