[ENV] Configure Api Entreprise token

This commit is contained in:
Mathieu Magnin 2018-03-16 13:07:20 +01:00 committed by Paul Chavard
parent 5ff869e1bc
commit db8e750f1a
5 changed files with 18 additions and 18 deletions

View file

@ -1,8 +1,4 @@
class ApiEntreprise::API
class << self
attr_accessor :token
end
ENTREPRISE_RESOURCE_NAME = "entreprises"
ETABLISSEMENT_RESOURCE_NAME = "etablissements"
EXERCICES_RESOURCE_NAME = "exercices"
@ -49,7 +45,7 @@ class ApiEntreprise::API
end
def self.url(resource_name, siret_or_siren)
[API_ENTREPRISE_URL, resource_name, siret_or_siren].join("/")
[base_url, resource_name, siret_or_siren].join("/")
end
def self.params(siret_or_siren, procedure_id)
@ -57,7 +53,17 @@ class ApiEntreprise::API
context: "demarches-simplifiees.fr",
recipient: siret_or_siren,
object: "procedure_id: #{procedure_id}",
token: SIADETOKEN
token: token
}
end
private
def self.token
Rails.application.secrets.api_entreprise[:key]
end
def self.base_url
Rails.application.secrets.api_entreprise[:base_url]
end
end

View file

@ -1,7 +1,5 @@
API_CARTO_URL = "https://apicarto.sgmap.fr"
API_ENTREPRISE_URL = 'https://entreprise.api.gouv.fr/v2'
API_GEO_URL = "https://geo.api.gouv.fr"
PIPEDRIVE_API_URL = 'https://api.pipedrive.com/v1'

View file

@ -28,6 +28,9 @@ defaults: &defaults
mailjet:
api_key: <%= ENV['MAILJET_API_KEY'] %>
secret_key: <%= ENV['MAILJET_SECRET_KEY'] %>
api_entreprise:
key: <%= ENV['API_ENTREPRISE_KEY'] %>
base_url: <%= ENV['API_ENTREPRISE_BASE_URL'] %>
development:
<<: *defaults
@ -36,6 +39,9 @@ development:
test:
<<: *defaults
secret_key_base: aa52abc3f3a629d04a61e9899a24c12f52b24c679cbf45f8ec0cdcc64ab9526d673adca84212882dff3911ac98e0c32ec4729ca7b3429ba18ef4dfd1bd18bc7a
api_entreprise:
key: api_entreprise_test_key
base_url: https://entreprise.api.gouv.fr/v2
france_connect_particulier:
identifier: france_connect_test_identifier
secret: france_connect_test_secret

View file

@ -2,7 +2,6 @@ namespace :dev do
desc 'Initialise dev environment'
task :init do
puts 'start initialisation'
Rake::Task['dev:generate_token_file'].invoke
Rake::Task['dev:generate_franceconnect_file'].invoke
Rake::Task['dev:generate_fog_credentials_file'].invoke
Rake::Task['dev:generate_features_file'].invoke
@ -10,14 +9,6 @@ namespace :dev do
puts 'end initialisation'
end
task :generate_token_file do
puts 'creating token.rb file'
res = `rake secret`.delete("\n")
file = File.new('config/initializers/token.rb', 'w+')
file.write("TPS::Application.config.SIADETOKEN = '#{res}'")
file.close
end
task :generate_franceconnect_file do
file = File.new('config/france_connect.yml', 'w+')
comment = <<~EOF

View file

@ -81,7 +81,6 @@ DatabaseCleaner.strategy = :transaction
TPS::Application.load_tasks
SIADETOKEN = :valid_token if !defined? SIADETOKEN
PIPEDRIVE_TOKEN = :pipedrive_test_token if !defined? PIPEDRIVE_TOKEN
include Warden::Test::Helpers