Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-exz committed Dec 30, 2024
1 parent 870674d commit ec977c5
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions test/functional/key_files_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
# plugins/vault/test/functional/key_files_controller_test.rb
require File.expand_path('../../test_helper', __FILE__)
require 'fileutils'
require 'byebug'

class KeyFilesControllerTest < Vault::ControllerTest
fixtures :projects, :users, :roles, :members, :member_roles
plugin_fixtures :keys, :vault_tags, :keys_vault_tags
class KeyFilesControllerTest < ActionController::TestCase
fixtures :projects, :users, :key_files

def setup
Role.find(1).add_permission! :view_keys
Role.find(1).add_permission! :edit_keys
Role.find(1).add_permission! :download_keys
Project.find(1).enabled_module_names = [:keys]
Setting.plugin_vault['use_null_encryption'] = 'on'
FileUtils.cp 'plugins/vault/test/fixtures/keyfile.txt', "#{Vault::KEYFILES_DIR}/server.key"
@controller = KeyFilesController.new
@request = ActionController::TestRequest.create
@response = ActionController::TestResponse.create
@project = projects(:one)
@key_file = key_files(:one)
@user = users(:one)
@request.session[:user_id] = @user.id
end

def test_download_keyfile
@request.session[:user_id] = 2

get :download, project_id: 1, id: 3

get :download, params: { project_id: @project.id, id: @key_file.id }
assert_response :success
assert_equal 'application/octet-stream', response.content_type
assert_equal "This is file for tests\n", response.body
assert_equal 'attachment; filename="ssh_access"', response.header["Content-Disposition"]
end

end
end

0 comments on commit ec977c5

Please sign in to comment.