diff options
| -rw-r--r-- | config/environments/development.rb | 10 | ||||
| -rw-r--r-- | lib/stif/permission_translator.rb | 7 | ||||
| -rw-r--r-- | spec/lib/stif/permission_translator_spec.rb | 10 | ||||
| -rw-r--r-- | spec/support/permissions.rb | 28 |
4 files changed, 50 insertions, 5 deletions
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 |
