From 64e16e9525961066a8d4f2770e8ccb8472a15956 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 10 Jul 2017 17:38:50 +0200 Subject: hotfix --- config/environments/development.rb | 10 +++++----- lib/stif/permission_translator.rb | 7 +++++++ spec/lib/stif/permission_translator_spec.rb | 10 ++++++++++ spec/support/permissions.rb | 28 ++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 lib/stif/permission_translator.rb create mode 100644 spec/lib/stif/permission_translator_spec.rb create mode 100644 spec/support/permissions.rb diff --git a/config/environments/development.rb b/config/environments/development.rb index 2ca9c828f..59cb9eefa 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -61,13 +61,13 @@ Rails.application.configure do config.reflex_api_url = "https://pprod.reflex.stif.info/ws/reflex/V1/service=getData" config.codifligne_api_url = "https://pprod.codifligne.stif.info/rest/v1/lc/getlist" - config.chouette_authentication_settings = { - type: "database" - } # config.chouette_authentication_settings = { - # type: "cas", - # cas_server: "http://stif-portail-dev.af83.priv/sessions" + # type: "database" # } + config.chouette_authentication_settings = { + type: "cas", + cas_server: "http://stif-portail-dev.af83.priv/sessions" + } config.stif_portail_api = { key: "Ohphie1Voo6the5hohpi", diff --git a/lib/stif/permission_translator.rb b/lib/stif/permission_translator.rb new file mode 100644 index 000000000..7032f910a --- /dev/null +++ b/lib/stif/permission_translator.rb @@ -0,0 +1,7 @@ +module Stif + module PermissionTranslator extend self + def translate(sso_extra_permissions) + %w{sessions:create} + end + end +end diff --git a/spec/lib/stif/permission_translator_spec.rb b/spec/lib/stif/permission_translator_spec.rb new file mode 100644 index 000000000..3672c7937 --- /dev/null +++ b/spec/lib/stif/permission_translator_spec.rb @@ -0,0 +1,10 @@ +RSpec.describe Stif::PermissionTranslator do + + context "SSO Permission boiv:read:offer →" do + + it "sessions:create only" do + expect( described_class.translate(%w{boiv:read:offer}) ).to eq(%w{sessions:create}) + end + + end +end diff --git a/spec/support/permissions.rb b/spec/support/permissions.rb new file mode 100644 index 000000000..a13010f65 --- /dev/null +++ b/spec/support/permissions.rb @@ -0,0 +1,28 @@ +module Support + module Permissions extend self + + def all_permissions + @__all_permissions__ ||= _destructive_permissions << 'sessions:create' + end + + private + + def _destructive_permissions + _permitted_resources.product( %w{create destroy update} ).map{ |model_action| model_action.join('.') } + end + + def _permitted_resources + %w[ + access_points + connection_links + footnotes + journey_patterns + referentials + routes + routing_constraint_zones + time_tables + vehicle_journeys + ] + end + end +end -- cgit v1.2.3