Merge pull request #1281 from okriuchykhin/ok_SCI_2686

Make API V1 togglable [SCI-2686]
This commit is contained in:
Alex Kriuchykhin 2018-08-24 14:22:29 +02:00 committed by GitHub
commit 10a650c3c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 2 deletions

View file

@ -16,12 +16,14 @@ module Api
attr_accessor :core_api_token_ttl
attr_accessor :core_api_token_iss
attr_accessor :azure_ad_apps
attr_accessor :core_api_v1_preview
def initialize
@core_api_sign_alg = 'HS256'
@core_api_token_ttl = 30.minutes
@core_api_token_iss = 'SciNote'
@azure_ad_apps = {}
@core_api_v1_preview = false
end
end
end

View file

@ -9,6 +9,8 @@ Api.configure do |config|
config.core_api_token_iss = ENV['CORE_API_TOKEN_ISS']
end
config.core_api_v1_preview = true if ENV['CORE_API_V1_PREVIEW']
vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ }
vars.each do |name, value|
app_name = name.sub('_AZURE_AD_APP_ID', '')

View file

@ -540,8 +540,10 @@ Rails.application.routes.draw do
get 'health', to: 'api#health'
get 'status', to: 'api#status'
post 'auth/token', to: 'api#authenticate'
namespace :v1 do
resources :teams, only: %i(index show) do
if Api.configuration.core_api_v1_preview
namespace :v1 do
resources :teams, only: %i(index show) do
end
end
end
end

View file

@ -5,6 +5,9 @@ require 'database_cleaner'
require 'devise'
require_relative 'support/controller_macros'
ENV['RAILS_ENV'] = 'test'
ENV['CORE_API_V1_PREVIEW'] = 'true'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort('The Rails environment is running in production mode!') if Rails.env.production?