summaryrefslogtreecommitdiff
path: root/test/functional/v1
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/v1')
-rw-r--r--test/functional/v1/certs_controller_test.rb46
-rw-r--r--test/functional/v1/services_controller_test.rb31
2 files changed, 55 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
diff --git a/test/functional/v1/services_controller_test.rb b/test/functional/v1/services_controller_test.rb
new file mode 100644
index 0000000..e4058c0
--- /dev/null
+++ b/test/functional/v1/services_controller_test.rb
@@ -0,0 +1,31 @@
+require 'test_helper'
+
+class V1::ServicesControllerTest < ActionController::TestCase
+
+ test "anonymous user gets login required service info" do
+ get :show, format: :json
+ assert_json_response name: 'anonymous',
+ eip_rate_limit: false,
+ description: 'please login to access our services'
+ end
+
+ test "anonymous user gets vpn service info" do
+ with_config allow_anonymous_certs: true do
+ get :show, format: :json
+ assert_json_response name: 'anonymous',
+ eip_rate_limit: false,
+ description: 'anonymous access to the VPN'
+ end
+ end
+
+ test "user can see their service info" do
+ login
+ get :show, format: :json
+ assert_json_response name: 'free',
+ eip_rate_limit: true,
+ description: 'free account, with rate limited VPN',
+ storage: 100
+ end
+
+end
+