class Icalia::StubbedSSOService

Constants

CODE
FIND_AVAILABLE_PORT

Public Class Methods

boot(port = find_available_port) click to toggle source

Taken from Bootable at fake_stripe gem: ================================

# File lib/icalia/stubbed_sso_service.rb, line 191
def boot(port = find_available_port)
  instance = new
  Capybara::Server.new(instance, port: port).tap(&:boot)
end
boot_once() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 196
def boot_once
  @boot_once ||= boot(server_port)
end
do_not_sign_in_on_authorize() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 164
def do_not_sign_in_on_authorize
  @@sign_in_user_on_authorize = false
end
example_resource_owner_full_name() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 124
def example_resource_owner_full_name
  [example_resource_owner_given_name, example_resource_owner_family_name]
    .compact.join(' ').strip
end
find_available_port() click to toggle source

Taken from FakeStripe::Utils at fake_stripe gem: =======================

# File lib/icalia/stubbed_sso_service.rb, line 183
def find_available_port
  server = TCPServer.new(FIND_AVAILABLE_PORT)
  server.addr[1]
ensure
  server.close if server
end
oauth_flows() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 110
def oauth_flows
  @oauth_flows ||= []
end
prepare() { |self| ... } click to toggle source

Taken from FakeStripe.stub_stripe at fake_stripe gem:

# File lib/icalia/stubbed_sso_service.rb, line 142
def prepare
  reset

  yield self if block_given?

  # Since the OAuth flow is performed by the browser, we'll need to boot
  # the Sinatra app instead of just stubbing the app with WebMock...
  boot_once

  OmniAuth::Strategies::Icalia.instances.each do |strategy|
    strategy.options.client_options.tap do |options|
      options.site = url
      options.token_url = "#{url}/oauth/token"
      options.authorize_url = "#{url}/oauth/authorize"
    end
  end
end
reset() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 114
def reset
  oauth_flows.clear

  self.example_resource_owner_id = SecureRandom.uuid
  self.example_resource_owner_given_name = 'Example Person'
  self.example_resource_owner_family_name = 'From Artanis'
  self.example_resource_owner_gender_type = 'male'
  self.example_resource_owner_custom_gender = nil
end
server_port() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 200
def server_port
  @server_port ||= find_available_port
end
sign_in_on_authorize() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 160
def sign_in_on_authorize
  @@sign_in_user_on_authorize = true
end
sign_in_url() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 137
def sign_in_url
  "#{url}/sign-in"
end
store_oauth_flow_data(data) click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 129
def store_oauth_flow_data(data)
  oauth_flows << data
end
teardown() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 168
def teardown
  default_client_options = OmniAuth::Strategies::Icalia
    .default_options
    .client_options
  
  OmniAuth::Strategies::Icalia.instances.each do |strategy|
    strategy.options.client_options.tap do |options|
      options.site = default_client_options.site
      options.token_url = default_client_options.token_url
      options.authorize_url = default_client_options.authorize_url
    end
  end
end
url() click to toggle source
# File lib/icalia/stubbed_sso_service.rb, line 133
def url
  "http://localhost:#{server_port}"
end