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



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

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!Object



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

def unauthorized_webhook_verification_headers!
  @request.headers['HTTP_X_SHOPIFY_HMAC_SHA256'] = "invalid_hmac"
end