Skip to content

Commit

Permalink
Add test to ensure authentication requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
oneiros committed Jan 31, 2022
1 parent f9b752c commit 7fd8e29
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/integration/required_authentication_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
require "test_helper"

class RequiredAuthenticationTest < ActionDispatch::IntegrationTest

test "authentication requirements for environments" do
authentication_required_for :get, environments_path
end

test "authentication requiremens for nodes" do
authentication_required_for :get, environment_nodes_path("development")
end

test "authentication requirements for keys" do
authentication_required_for :get,
environment_node_keys_path("development", "testhost")
authentication_required_for :get,
environment_node_key_path("development", "testhost", "hdm::integer")
authentication_required_for :patch,
environment_node_key_path("development", "testhost", "hdm::integer")
authentication_required_for :delete,
environment_node_key_path("development", "testhost", "hdm::integer")
end

test "authentication requirements for decrypted values" do
authentication_required_for :post,
environment_node_decrypted_values_path("development", "testhost")
end

test "authentication requirements for encrypted values" do
authentication_required_for :post,
environment_node_encrypted_values_path("development", "testhost")
end

test "authentication requirements for users" do
user = FactoryBot.create(:user, admin: true)

authentication_required_for :get, users_path
authentication_required_for :get, user_path(user)
authentication_required_for :get, new_user_path
authentication_required_for :post, users_path
authentication_required_for :get, edit_user_path(user)
authentication_required_for :patch, user_path(user)
authentication_required_for :delete, user_path(user)
end

private

def authentication_required_for(method, path)
send(method, path)
assert_redirected_to login_path
end
end

0 comments on commit 7fd8e29

Please sign in to comment.