Skip to content

Commit

Permalink
Ruby hash syntax update
Browse files Browse the repository at this point in the history
  • Loading branch information
rossta committed May 12, 2016
1 parent fb5eaca commit 3e98470
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task default: :spec
6 changes: 3 additions & 3 deletions lib/webpush/encryption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def encrypt(message, p256dh, auth)

client_auth_token = Base64.urlsafe_decode64(auth)

prk = HKDF.new(shared_secret, :salt => client_auth_token, :algorithm => 'SHA256', :info => "Content-Encoding: auth\0").next_bytes(32)
prk = HKDF.new(shared_secret, salt: client_auth_token, algorithm: 'SHA256', info: "Content-Encoding: auth\0").next_bytes(32)

context = create_context(client_public_key_bn, server_public_key_bn)

content_encryption_key_info = create_info('aesgcm', context)
content_encryption_key = HKDF.new(prk, :salt => salt, :info => content_encryption_key_info).next_bytes(16)
content_encryption_key = HKDF.new(prk, salt: salt, info: content_encryption_key_info).next_bytes(16)

nonce_info = create_info('nonce', context)
nonce = HKDF.new(prk, :salt => salt, :info => nonce_info).next_bytes(12)
nonce = HKDF.new(prk, salt: salt, info: nonce_info).next_bytes(12)

ciphertext = encrypt_payload(message, content_encryption_key, nonce)

Expand Down
8 changes: 4 additions & 4 deletions spec/webpush_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

stub_request(:post, expected_endpoint).
with(body: expected_body, headers: expected_headers).
to_return(:status => 201, :body => "", :headers => {})
to_return(status: 201, body: "", headers: {})

result = Webpush.payload_send(message: message, endpoint: endpoint, p256dh: p256dh, auth: auth)

Expand All @@ -46,7 +46,7 @@

it 'returns false for unsuccessful status code by default' do
stub_request(:post, expected_endpoint).
to_return(:status => 401, :body => "", :headers => {})
to_return(status: 401, body: "", headers: {})

result = Webpush.payload_send(message: message, endpoint: endpoint, p256dh: p256dh, auth: auth)

Expand All @@ -67,15 +67,15 @@

stub_request(:post, expected_endpoint).
with(body: expected_body, headers: expected_headers).
to_return(:status => 201, :body => "", :headers => {})
to_return(status: 201, body: "", headers: {})

Webpush.payload_send(message: message, endpoint: endpoint, p256dh: p256dh, auth: auth, api_key: api_key)
end

it 'does not insert Authorization header when blank' do
stub_request(:post, expected_endpoint).
with(body: expected_body, headers: expected_headers).
to_return(:status => 201, :body => "", :headers => {})
to_return(status: 201, body: "", headers: {})

Webpush.payload_send(message: message, endpoint: endpoint, p256dh: p256dh, auth: auth, api_key: "")
Webpush.payload_send(message: message, endpoint: endpoint, p256dh: p256dh, auth: auth, api_key: nil)
Expand Down

0 comments on commit 3e98470

Please sign in to comment.