Sha256: ffc1ce0778056b706362b6cee9277f8799c8df30c3b34fa28d6c3ecafdd54eb1

Contents?: true

Size: 961 Bytes

Versions: 3

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

RSpec.describe KeycloakRack::Session do
  let(:session) { FactoryBot.create :session }

  subject { session }

  context "with a session built from a valid token" do
    it { is_expected.to be_authenticated }

    it { is_expected.not_to be_anonymous }

    it "can authorize realm roles" do
      expect(session.authorize_realm!("foo")).to be_a_success
    end

    it "can authorize resource roles" do
      expect(session.authorize_resource!("widgets", "bar")).to be_a_success
    end
  end

  context "with an anonymous session" do
    let(:session) { FactoryBot.create :session, :anonymous }

    it { is_expected.to be_anonymous }

    it { is_expected.not_to be_authenticated }

    it "can authorize realm roles" do
      expect(session.authorize_realm!("foo")).to be_a_failure
    end

    it "can authorize resource roles" do
      expect(session.authorize_resource!("widgets", "bar")).to be_a_failure
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keycloak_rack-1.1.1 spec/keycloak_rack/session_spec.rb
keycloak_rack-1.1.0 spec/keycloak_rack/session_spec.rb
keycloak_rack-1.0.0 spec/keycloak_rack/session_spec.rb