service object to write out config files
This commit is contained in:
12
test/fixtures/accounts.yml
vendored
12
test/fixtures/accounts.yml
vendored
@ -5,3 +5,15 @@ account1:
|
||||
password: <%= CryptSerializer.dump('1q2w3e4r5t6y7u') %>
|
||||
home_folder: client_one
|
||||
contact_email: ftp-user@mailinator.com
|
||||
|
||||
account2:
|
||||
username: client-two
|
||||
password: <%= CryptSerializer.dump('azsxdcfvgbhnjmk,l.;/') %>
|
||||
home_folder: client_two
|
||||
contact_email: ftp-user@mailinator.com
|
||||
|
||||
account3:
|
||||
username: client-three
|
||||
password: <%= CryptSerializer.dump('p0o9i8u7y6t5r4e3w2q1') %>
|
||||
home_folder: client_three
|
||||
contact_email: ftp-user@mailinator.com
|
||||
|
21
test/services/ftp_config_test.rb
Normal file
21
test/services/ftp_config_test.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class FtpConfigTest < ActiveSupport::TestCase
|
||||
test 'should write new password file' do
|
||||
config = FtpConfig.new
|
||||
config.build_password_list Account.all
|
||||
|
||||
assert_match "#{accounts(:account2).username}:", File.read(AppConfig.htpasswd)
|
||||
end
|
||||
|
||||
test 'should build user config files' do
|
||||
config = FtpConfig.new
|
||||
config.build_user_configs Account.all
|
||||
|
||||
account = accounts(:account1)
|
||||
fconfig = File.read("#{AppConfig.ftpusers}#{account.username}")
|
||||
|
||||
assert_match account.home_folder, fconfig
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user