diff options
| author | Robert | 2017-07-11 05:55:56 +0200 |
|---|---|---|
| committer | Robert | 2017-07-24 17:54:03 +0200 |
| commit | 6eb404b967e5cfa328fb4c4c435c18771f6ea417 (patch) | |
| tree | 24694bae452a227c5bbf95e1478e966afc6a303b /spec | |
| parent | 45226369543a8d7cb1f2152c07613c2f23d70813 (diff) | |
| download | chouette-core-6eb404b967e5cfa328fb4c4c435c18771f6ea417.tar.bz2 | |
Refs: #4019@1h; Adds spec for Permission Translation and implements it in lib/stif/permission_translator
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/lib/stif/permission_translator_spec.rb | 39 | ||||
| -rw-r--r-- | spec/support/permissions.rb | 1 |
2 files changed, 38 insertions, 2 deletions
diff --git a/spec/lib/stif/permission_translator_spec.rb b/spec/lib/stif/permission_translator_spec.rb index 3672c7937..1af21364c 100644 --- a/spec/lib/stif/permission_translator_spec.rb +++ b/spec/lib/stif/permission_translator_spec.rb @@ -1,10 +1,45 @@ RSpec.describe Stif::PermissionTranslator do - context "SSO Permission boiv:read:offer →" do + context "No SSO Permissions" do + it { expect(described_class.translate([])).to be_empty } + end + + 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}) + expect( described_class.translate(%w{boiv:read-offer}) ).to eq(%w{sessions:create}) + end + + end + + context "SSO Permission boiv:edit-offer →" do + + it "all permissions" do + expect( described_class.translate(%w{boiv:edit-offer}) ).to eq(Support::Permissions.all_permissions) + end + + it "all permissions, no doubletons" do + expect( described_class.translate(%w{boiv:edit-offer boiv:read-offer}) ).to eq(Support::Permissions.all_permissions) end + it "all permissions, input order agnostic" do + expect( described_class.translate(%w{boiv:read-offer boiv:edit-offer}) ).to eq(Support::Permissions.all_permissions) + end + end + + context "SSO Permission ignores garbage (no injection) →" do + it "remains empty" do + expect( described_class.translate(%w{referentials.create}) ).to be_empty + end + + it "remains at boiv:read-offer level" do + expect( described_class.translate(%w{referentials.create boiv:read-offer calendars.delete}) ).to eq(%w{sessions:create}) + end + + it "does not add garbage or doubletons for boiv:edit-offer level" do + expect( + described_class.translate(%w{xxx boiv:read-offer lines.delete boiv:edit-offer footnotes.update}) + ).to eq(Support::Permissions.all_permissions) + end end end diff --git a/spec/support/permissions.rb b/spec/support/permissions.rb index a13010f65..fcf9ae9c4 100644 --- a/spec/support/permissions.rb +++ b/spec/support/permissions.rb @@ -15,6 +15,7 @@ module Support %w[ access_points connection_links + calendars footnotes journey_patterns referentials |
