Module: ShopifyApp::TestHelpers::WebhookVerificationHelper

Defined in:
lib/shopify_app/test_helpers/webhook_verification_helper.rb

Instance Method Summary collapse

Instance Method Details

#authorized_webhook_verification_headers!(params = {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/shopify_app/test_helpers/webhook_verification_helper.rb', line 4

def authorized_webhook_verification_headers!(params = {})
  digest = OpenSSL::Digest.new('sha256')
  secret = ShopifyApp.configuration.secret
  valid_hmac = Base64.encode64(OpenSSL::HMAC.digest(digest, secret, params.to_query)).strip
  @request.headers['HTTP_X_SHOPIFY_HMAC_SHA256'] = valid_hmac
end

#unauthorized_webhook_verification_headers!(params = {}) ⇒ Object



11
12
13
# File 'lib/shopify_app/test_helpers/webhook_verification_helper.rb', line 11

def unauthorized_webhook_verification_headers!(params = {})
  @request.headers['HTTP_X_SHOPIFY_HMAC_SHA256'] = "invalid_hmac"
end