require 'test_helper'
require 'xi_wechat_corp/sha1_signer'

module XiWechatCorp
  class SHA1SignerTest < Minitest::Test
    TEST_TOKEN = 'QDG6eK'
    TEST_TIME_STAMP = '1409659589'
    TEST_NONCE = '263014780'
    TEST_ECHO_STR = 'P9nAzCzyDtyTWESHep1vC5X9xho/qYX3Zpb4yKa9SKld1DsH3Iyt3tP3zNdtp+4RPcs8TgAE7OaBO+FZXvnaqQ=='
    TEST_SIGNATURE = '5c45ff5e21c57e6ad56bac8758b79b1d9ac89fd3'
    def signer
      SHA1Signer.new(TEST_TOKEN)
    end

    def test_sign_example
      assert_equal TEST_SIGNATURE, signer.sign(TEST_TIME_STAMP, TEST_NONCE, TEST_ECHO_STR)
    end
  end
end
