Sha256: 04565578d5a89492542b27702ff6a17bd5c4826bdc97264e397cce4d02f39545

Contents?: true

Size: 1.95 KB

Versions: 12

Compression:

Stored size: 1.95 KB

Contents

module Ddr::Jobs
  RSpec.describe MigrateLegacyAuthorization do

    let(:obj) { FactoryGirl.build(:collection) }

    before do
      @deprecation_behavior = Deprecation.default_deprecation_behavior
      Deprecation.default_deprecation_behavior = :silence
      obj.permissions_attributes = [{access: "edit", type: "person", name: "bob@example.com"}]
      obj.adminMetadata.downloader = ["Downloaders", "sally@example.com"]
      obj.default_permissions = [{access: "edit", type: "group", name: "Editors"},
                                 {access: "discover", type: "group", name: "public"},
                                 {access: "read", type: "group", name: "registered"}]
      obj.save!
    end

    after do
      Deprecation.default_deprecation_behavior = @deprecation_behavior
    end

    it "should migrate the authorization data to roles" do
      Resque.enqueue(described_class, obj.pid)
      obj.reload
      expect(obj.legacy_authorization).to be_clear
      expect(obj.roles)
        .to eq(Ddr::Auth::Roles::DetachedRoleSet.new(
                [ Ddr::Auth::Roles::Role.build(type: "Curator", agent: "Editors", scope: "policy"),
                  Ddr::Auth::Roles::Role.build(type: "Viewer", agent: "public", scope: "policy"),
                  Ddr::Auth::Roles::Role.build(type: "Viewer", agent: "registered", scope: "policy"),
                  Ddr::Auth::Roles::Role.build(type: "Editor", agent: "bob@example.com", scope: "resource"),
                  Ddr::Auth::Roles::Role.build(type: "Downloader", agent: "Downloaders", scope: "resource"),
                  Ddr::Auth::Roles::Role.build(type: "Downloader", agent: "sally@example.com", scope: "resource")
                ]
              ))
      event = obj.update_events.last
      expect(event).to be_success
      expect(event.summary).to eq("Legacy authorization data migrated to roles")
      expect(event.detail).to match(/LEGACY AUTHORIZATION DATA/)
      expect(event.detail).to match(/ROLES/)
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ddr-models-2.0.1 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.rc6 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.rc5 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.rc4 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.rc3 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.rc2 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.rc1 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.pre.5 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.pre.4 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.pre.3 spec/jobs/migrate_legacy_authorization_spec.rb
ddr-models-2.0.0.pre.2 spec/jobs/migrate_legacy_authorization_spec.rb