Skip to content

Commit

Permalink
add a standards-compliant Chrome endpoint authorization header test
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedhafez committed Sep 12, 2016
1 parent 159f582 commit 4818cd5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion spec/webpush/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
end

describe 'from :api_key' do
it 'inserts Authorization header when api_key present, and endpoint is for Chrome' do
it 'inserts Authorization header when api_key present, and endpoint is for Chrome\'s non-standards-compliant GCM endpoints' do
request = Webpush::Request.new('https://gcm-http.googleapis.com/gcm/xyz', api_key: "api_key")

expect(request.headers['Authorization']).to eq("key=api_key")
end

it 'does not insert Authorization header for Chrome\'s new standards-compliant endpoints, even if api_key is present' do
request = Webpush::Request.new('https://fcm.googleapis.com/fcm/send/ABCD1234', api_key: "api_key")

expect(request.headers['Authorization']).to be_nil
end

it 'does not insert Authorization header when endpoint is not for Chrome, even if api_key is present' do
request = Webpush::Request.new('https://some.random.endpoint.com/xyz', api_key: "api_key")

Expand Down

0 comments on commit 4818cd5

Please sign in to comment.