2008-11-25 01:39:11 -05:00
|
|
|
require 'abstract_unit'
|
2007-11-28 14:36:59 -05:00
|
|
|
|
|
|
|
# Must set before requiring generator libs.
|
|
|
|
if defined?(RAILS_ROOT)
|
|
|
|
RAILS_ROOT.replace "#{File.dirname(__FILE__)}/fixtures"
|
|
|
|
else
|
|
|
|
RAILS_ROOT = "#{File.dirname(__FILE__)}/fixtures"
|
|
|
|
end
|
|
|
|
|
|
|
|
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
|
|
|
|
2008-04-01 12:54:30 -04:00
|
|
|
require 'initializer'
|
|
|
|
|
|
|
|
# Mocks out the configuration
|
|
|
|
module Rails
|
|
|
|
def self.configuration
|
|
|
|
Rails::Configuration.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-11-28 14:36:59 -05:00
|
|
|
require 'rails_generator'
|
|
|
|
require 'rails_generator/secret_key_generator'
|
|
|
|
require 'rails_generator/generators/applications/app/app_generator'
|
|
|
|
|
2008-11-15 15:26:37 -05:00
|
|
|
class SecretKeyGenerationTest < ActiveSupport::TestCase
|
2007-11-28 14:36:59 -05:00
|
|
|
SECRET_KEY_MIN_LENGTH = 128
|
|
|
|
APP_NAME = "foo"
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@generator = Rails::SecretKeyGenerator.new(APP_NAME)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_secret_key_generation
|
2008-08-28 06:47:18 -04:00
|
|
|
assert_deprecated /ActiveSupport::SecureRandom\.hex\(64\)/ do
|
|
|
|
assert @generator.generate_secret.length >= SECRET_KEY_MIN_LENGTH
|
|
|
|
end
|
2007-11-28 14:36:59 -05:00
|
|
|
end
|
|
|
|
end
|