Skip to content

Commit

Permalink
[api] accept missing secret.key file in test environment and use hard…
Browse files Browse the repository at this point in the history
…coded "secret"
  • Loading branch information
adrianschroeter committed Oct 23, 2013
1 parent aa21bd6 commit 5f5e1c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 0 additions & 2 deletions dist/ci/obs_testsuite_common.sh
Expand Up @@ -35,7 +35,6 @@ setup_api() {
echo "Setup additional configuration"
cp config/options.yml.example config/options.yml
cp config/thinking_sphinx.yml.example config/thinking_sphinx.yml
echo "dummy" > config/secret.key
chmod a+x script/start_test_backend

echo "Initialize test database, load seed data"
Expand All @@ -52,7 +51,6 @@ setup_webui() {

echo "Setup additional configuration"
cp config/options.yml.example config/options.yml
echo "dummy" > config/secret.key

chmod +x script/start_test_api

Expand Down
9 changes: 8 additions & 1 deletion src/api/config/initializers/secret_token.rb
Expand Up @@ -6,4 +6,11 @@
# no regular words or you'll be exposed to dictionary attacks.

# obs-api package is generating this file during installation
OBSApi::Application.config.secret_key_base = File.read "#{Rails.root}/config/secret.key" || 'assad'
if File.exists? "#{Rails.root}/config/secret.key"
OBSApi::Application.config.secret_key_base = File.read "#{Rails.root}/config/secret.key"
elsif Rails.env.production?
raise "Missing config/secret.key file!"
else
# for development and test environment
OBSApi::Application.config.secret_key_base = '92b2ed725cb4d68cc5fbf86d6ba204f1dec4172086ee7eac8f083fb62ef34057f1b770e0722ade7b298837be7399c6152938627e7d15aca5fcda7a4faef91fc7'
end

0 comments on commit 5f5e1c8

Please sign in to comment.