Sha256: e52fb79b92dbb041be88a3db5268ca5366d8384cb3f88528c106bec6f077c028

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'test_helper'

class GoogleSignIn::AuthorizationsControllerTest < ActionDispatch::IntegrationTest
  test "redirecting to Google for authorization" do
    post google_sign_in.authorization_url, params: { proceed_to: 'http://www.example.com/login' }
    assert_response :redirect
    assert_match 'https://accounts.google.com/o/oauth2/auth', response.location

    params = extract_query_params_from(response.location)
    assert_equal FAKE_GOOGLE_CLIENT_ID, params[:client_id]
    assert_equal 'login', params[:prompt]
    assert_equal 'code', params[:response_type]
    assert_equal 'http://www.example.com/google_sign_in/callback', params[:redirect_uri]
    assert_equal 'openid profile email', params[:scope]
    assert_match /[A-Za-z0-9+\/]{22}==/, params[:state]

    assert_equal 'http://www.example.com/login', flash[:proceed_to]
    assert_equal params[:state], flash[:state]
  end

  private
    def extract_query_params_from(url)
      query = URI(url).query
      Rack::Utils.parse_query(query).symbolize_keys
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
google_sign_in-1.0.2 test/controllers/authorizations_controller_test.rb
google_sign_in-1.0.1 test/controllers/authorizations_controller_test.rb
google_sign_in-1.0.0 test/controllers/authorizations_controller_test.rb