Sha256: 387a1f523b88ddb3d52a766e694c8dc70cad1652567673bef9d663d9e8229ec3

Contents?: true

Size: 565 Bytes

Versions: 3

Compression:

Stored size: 565 Bytes

Contents

require 'test_helper.rb'

# Test HMAC Authorization Method
class HMACFailTest < MiniTest::Unit::TestCase
  include Rack::Test::Methods

  def setup
  	@secret = 'test_secret'
    @signature = 'test_signature'
  end

  def app
    Rack::SimpleAuth.failapp
  end

  def test_fail
    uri = '/'
    content = { 'method' => 'GET', 'data' => uri }.to_json
    hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @secret, content)

    assert_raises(RuntimeError) { get uri, {}, 'HTTP_AUTHORIZATION' => "#{hash}:#{@signature}" }
  end

  def teardown
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-simple_auth-0.0.9 test/rack/simple_auth/hmac_fail_test.rb
rack-simple_auth-0.0.8 test/rack/simple_auth/hmac_fail_test.rb
rack-simple_auth-0.0.7 test/rack/simple_auth/hmac_fail_test.rb