spec/omniauth/strategies/auth0_spec.rb in omniauth-auth0-2.1.0 vs spec/omniauth/strategies/auth0_spec.rb in omniauth-auth0-2.2.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'spec_helper'
require 'jwt'
RSpec.shared_examples 'site has valid domain url' do |url|
it { expect(subject.site).to eq(url) }
@@ -77,10 +79,11 @@
expect(redirect_url).to start_with('https://samples.auth0.com/authorize')
expect(redirect_url).to have_query('response_type', 'code')
expect(redirect_url).to have_query('state')
expect(redirect_url).to have_query('client_id')
expect(redirect_url).to have_query('redirect_uri')
+ expect(redirect_url).not_to have_query('auth0Client')
end
it 'redirects to hosted login page' do
get 'auth/auth0?connection=abcd'
expect(last_response.status).to eq(302)
@@ -89,17 +92,19 @@
expect(redirect_url).to have_query('response_type', 'code')
expect(redirect_url).to have_query('state')
expect(redirect_url).to have_query('client_id')
expect(redirect_url).to have_query('redirect_uri')
expect(redirect_url).to have_query('connection', 'abcd')
+ expect(redirect_url).not_to have_query('auth0Client')
end
describe 'callback' do
let(:access_token) { 'access token' }
let(:expires_in) { 2000 }
let(:token_type) { 'bearer' }
let(:refresh_token) { 'refresh token' }
+ let(:telemetry_value) { Class.new.extend(OmniAuth::Auth0::Telemetry).telemetry_encoded }
let(:user_id) { 'user identifier' }
let(:state) { SecureRandom.hex(8) }
let(:name) { 'John' }
let(:nickname) { 'J' }
@@ -145,9 +150,10 @@
}
end
def stub_auth(body)
stub_request(:post, 'https://samples.auth0.com/oauth/token')
+ .with(headers: { 'Auth0-Client' => telemetry_value })
.to_return(
headers: { 'Content-Type' => 'application/json' },
body: MultiJson.encode(body)
)
end