Module: SuperIdentity::TestStub

Defined in:
lib/super_identity/test_stub.rb

Overview

Mixin for stubbing IdE during test suites

Instance Method Summary collapse

Instance Method Details

#stub_ide(shared_token:, entitlements: []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/super_identity/test_stub.rb', line 6

def stub_ide(shared_token:, entitlements: [], **)
  host = ide_config[:host]
  url = "https://#{host}/api/subjects/#{shared_token}/attributes"

  attrs = entitlements.map do |v|
    { name: 'eduPersonEntitlement', value: v }
  end

  json = JSON.generate(attributes: attrs)
  WebMock::API.stub_request(:get, url).to_return(status: 200, body: json)
end