Sha256: dbbc14d5088d08430c05ac9761380d21c10ebe58665377b6bb27a2447f5d7389

Contents?: true

Size: 1.78 KB

Versions: 19

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Osso::GraphQL::Schema do
  describe 'Identity Provider' do
    let(:id) { Faker::Internet.uuid }
    let(:domain) { Faker::Internet.domain_name }
    let(:variables) { { id: id } }
    let(:query) do
      <<~GRAPHQL
        query IdentityProvider($id: ID!) {
          identityProvider(id: $id) {            
            id
            service
            domain
            acsUrl
            ssoCert
            ssoUrl
            status
          }
        }
      GRAPHQL
    end

    before do
      create(:identity_provider)
      create(:identity_provider, id: id, domain: domain)
    end

    subject do
      described_class.execute(
        query,
        variables: variables,
        context: current_context,
      )
    end

    describe 'for an admin user' do
      let(:current_context) do
        { scope: 'admin' }
      end
      it 'returns Identity Provider for id' do
        expect(subject['errors']).to be_nil
        expect(subject.dig('data', 'identityProvider', 'id')).to eq(id)
      end
    end

    describe 'for an email scoped user' do
      let(:current_context) do
        {
          scope: 'end-user',
          email: "user@#{domain}",
        }
      end
      it 'returns Enterprise Account for domain' do
        expect(subject['errors']).to be_nil
        expect(subject.dig('data', 'identityProvider', 'domain')).to eq(domain)
      end
    end

    describe 'for the wrong email scoped user' do
      let(:current_context) do
        {
          scope: 'end-user',
          email: 'user@bar.com',
        }
      end
      it 'returns Enterprise Account for domain' do
        expect(subject['errors']).to_not be_empty
        expect(subject.dig('data', 'enterpriseAccount')).to be_nil
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
osso-0.0.5.pre.eta spec/graphql/query/identity_provider_spec.rb
osso-0.0.5.pre.zeta spec/graphql/query/identity_provider_spec.rb
osso-0.0.5.pre.epsilon spec/graphql/query/identity_provider_spec.rb
osso-0.0.5.pre.delta spec/graphql/query/identity_provider_spec.rb
osso-0.0.5.pre.gamma spec/graphql/query/identity_provider_spec.rb
osso-0.0.5.pre.beta spec/graphql/query/identity_provider_spec.rb
osso-0.0.5.pre.alpha spec/graphql/query/identity_provider_spec.rb
osso-0.0.4 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.27 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.26 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.25 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.24 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.23 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.22 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.21 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.20 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.19 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.18 spec/graphql/query/identity_provider_spec.rb
osso-0.0.3.17 spec/graphql/query/identity_provider_spec.rb