class Object

Constants

NEW_PASSWORD
PASSWORD

Public Instance Methods

env() click to toggle source

TODO: make it DRY

# File spec/requests/api_directories_spec.rb, line 34
def env
  {
    'Accept' => 'text/plain',
    'Content-Type' => 'text/plain'
  }
end
get_test_user_password(username) click to toggle source
# File spec/spec_helper.rb, line 140
def get_test_user_password(username)
  password_file = Rails.root.join('.test_user_password')
  if File.exists?(password_file)
    File.read(password_file).chomp.decrypt(:symmetric, :password => EnvstatFc::Application.config.secret_key_base)
  else
    begin
      password  = ask("Enter  the password for the #{username}:  ") { |q| q.echo = "*" }
      password2 = ask("Retype the password for the #{username}:  ") { |q| q.echo = "*" }
    end while password != password2
    File.write(password_file, password.encrypt(:symmetric, :password => EnvstatFc::Application.config.secret_key_base))
    password
  end
end
secure_token() click to toggle source
# File config/initializers/secret_token.rb, line 3
def secure_token
  secret_file = Rails.root.join('.secret')
  if File.exist?(secret_file)
    return YAML::load_file(secret_file)
  else
    cipher = OpenSSL::Cipher::AES256.new(:CBC)
    key, iv = cipher.random_key, cipher.random_iv
    y = [key, iv]
    File.write(secret_file, y.to_yaml)
    return key, iv
  end
end