Skip to content
Browse files

add tests for #verify_webhook_signature

  • Loading branch information...
1 parent aacd511 commit 57bd83f69c0f8402a11e325ccbf36c83c8acc800 @jackowayed jackowayed committed with Jul 13, 2010
Showing with 28 additions and 0 deletions.
  1. +10 −0 test/assets/webhook_params.yaml
  2. +11 −0 test/notifo_test.rb
  3. +7 −0 test/test_helper.rb
View
10 test/assets/webhook_params.yaml
@@ -0,0 +1,10 @@
+---
+notifo_service: Message
+notifo_title: ""
+notifo_uri: http://test.com/
+notifo_to_username: testing42
+notifo_signature: 853bbc06ccae3491f3b9e5617f8b2b9dce6f65d5
+notifo_unix_time: "1278988965"
+notifo_message: Test
+notifo_id: "1043960"
+notifo_webhook_url: http://jackowayed-notifo.oncloud.org/
View
11 test/notifo_test.rb
@@ -4,4 +4,15 @@ class NotifoTest < Test::Unit::TestCase
should "probably rename this file and start testing for real" do
flunk "hey buddy, you should probably rename this file and start testing for real"
end
+
+ context "#verify_webhook_sigature" do
+ should "return true if given the right API secret" do
+ assert NOTIFO.verify_webhook_signature(WEBHOOK)
+ end
+
+ should "return false if given the wrong API secret" do
+ bad_notifo = Notifo.new NOTIFO_USERNAME, 'thisisntthesecret'
+ assert !bad_notifo.verify_webhook_signature(WEBHOOK)
+ end
+ end
end
View
7 test/test_helper.rb
@@ -8,3 +8,10 @@
class Test::Unit::TestCase
end
+
+NOTIFO_USERNAME = 'testing42'
+NOTIFO_API_SECRET = 'x96cb52807a33bafc8fd741eeba5e40ff89f05896'
+
+NOTIFO = Notifo.new NOTIFO_USERNAME, NOTIFO_API_SECRET
+
+WEBHOOK = YAML::load(File.read('test/assets/webhook_params.yaml'))

0 comments on commit 57bd83f

Please sign in to comment.
Something went wrong with that request. Please try again.