Sha256: 6f0a48a635d7e76df34bc1647651fdcf69b453bb26623f93c228b7b3be9d05ef

Contents?: true

Size: 1.36 KB

Versions: 34

Compression:

Stored size: 1.36 KB

Contents

require 'net/http'

module Signonotron2IntegrationHelpers
  def wait_for_signonotron_to_start
    retries = 0
    url = GDS::SSO::Config.oauth_root_url
    puts "Waiting for signonotron to start at #{url}"
    while ! signonotron_started?(url)
      print '.'
      if retries > 20
        raise "Signonotron is not running at #{url}. Please start with 'bundle exec rake signonotron:start'. Under jenkins this should have been run automatically"
      end
      retries += 1
      sleep 1
    end
    puts "Signonotron is now running at #{url}"
  end

  def signonotron_started?(url)
    uri = URI.parse(url)
    conn = Net::HTTP.start(uri.host, uri.port)
    true
  rescue Errno::ECONNREFUSED
    false
  ensure
    conn.try(:finish)
  end

  def load_signonotron_setup_fixture
    load_signonotron_fixture("signonotron2.sql")
  end

  def authorize_signonotron_api_user
    load_signonotron_fixture("authorize_api_users.sql")
  end

  def load_signonotron_fixture(fixture_sql_file)
    fixtures_path = Pathname.new(File.join(File.dirname(__FILE__), '../fixtures/integration'))
    app = "signonotron2"
    path_to_app = Rails.root.join('..','..','tmp',app)

    db = YAML.load_file(fixtures_path + "#{app}_database.yml")['test']
    cmd = "sqlite3 #{path_to_app + db['database']} < #{fixtures_path + "#{fixture_sql_file}"}"
    system cmd or raise "Error loading signonotron fixture"
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
gds-sso-11.0.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-10.1.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-10.0.1 spec/support/signonotron2_integration_helpers.rb
gds-sso-10.0.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.4.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.3.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.2.7 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.2.6 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.2.5 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.2.4 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.2.3 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.2.2 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.2.1 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.2.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.1.2 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.1.1 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.1.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-9.0.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-8.0.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-7.0.0 spec/support/signonotron2_integration_helpers.rb