hmac_params_test.rb 755 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class HmacParamsTest < Test::Unit::TestCase
  4. test "cgi param keys are prepared for hmac validation by encoding equals, ampersand, and percent characters" do
  5. assert_equal(
  6. "abcd%26%3D%251234",
  7. ShopifyAPI::HmacParams.encode_key("abcd&=%1234")
  8. )
  9. end
  10. test "cgi param values are prepared for hmac validation by encoding ampersand and percent characters" do
  11. assert_equal(
  12. "abcd%26=%251234",
  13. ShopifyAPI::HmacParams.encode_value("abcd&=%1234")
  14. )
  15. end
  16. test "cgi params are encoded properly for hmac validation" do
  17. assert_equal(
  18. "abcd%26%3D%251234=abcd%26=%251234",
  19. ShopifyAPI::HmacParams.encode({"abcd&=%1234" => "abcd&=%1234"})
  20. )
  21. end
  22. end