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



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

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



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

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