Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Improve the subscription process signature verification #75

Merged
merged 1 commit into from Mar 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/instagram/client/subscriptions.rb
Expand Up @@ -41,7 +41,7 @@ def subscriptions(options={})
# @option options [String, Integer] :object_id When specifying a location or tag use the location's ID or tag name respectively
# @option options [String, Float] :lat The center latitude of an area, used when subscribing to a geography object
# @option options [String, Float] :lng The center longitude of an area, used when subscribing to a geography object
# @option options [String, Integer] :radius The distance in meters you'd like to capture around a given point
# @option options [String, Integer] :radius The distance in meters you'd like to capture around a given point
#
# Note that we only support "media" at this time, but we might support other types of subscriptions in the future.
# @return [Hashie::Mash] The subscription created.
Expand Down Expand Up @@ -124,7 +124,7 @@ def delete_subscription(*args)
def process_subscription(json, options={}, &block)
raise ArgumentError, "callbacks block expected" unless block_given?

if options[:signature]
if options.has_key?(:signature)
if !client_secret
raise ArgumentError, "client_secret must be set during configure"
end
Expand Down
13 changes: 8 additions & 5 deletions spec/instagram/client/subscriptions_spec.rb
Expand Up @@ -136,11 +136,14 @@
end

it "should raise an Instagram::InvalidSignature error" do
lambda do
@client.process_subscription(@json, :signature => "31337H4X0R") do |handler|
# hi
end
end.should raise_error(Instagram::InvalidSignature)
invalid_signatures = ["31337H4X0R", nil]
invalid_signatures.each do |signature|
lambda do
@client.process_subscription(@json, :signature => signature ) do |handler|
# hi
end
end.should raise_error(Instagram::InvalidSignature)
end
end
end
end
Expand Down