Sha256: b0e29841a80f038aad471279189cbd2ddc7e09906d8fe5a1415305efbad6dfc3

Contents?: true

Size: 809 Bytes

Versions: 30

Compression:

Stored size: 809 Bytes

Contents

require 'mechanize/test_case'

class TestMechanizeFormKeygen < Mechanize::TestCase

  def setup
    super

    keygen = node('keygen',
                  'name' => 'userkey',
                  'challenge' => 'f4832e1d200df3df8c5c859edcabe52f')

    @keygen = Mechanize::Form::Keygen.new keygen
  end

  def test_challenge
    assert_equal "f4832e1d200df3df8c5c859edcabe52f", @keygen.challenge
  end

  def test_key
    assert @keygen.key.kind_of?(OpenSSL::PKey::PKey), "Not an OpenSSL key"
    assert @keygen.key.private?, "Not a private key"
  end

  def test_spki_signature
    spki = OpenSSL::Netscape::SPKI.new @keygen.value
    assert_equal @keygen.challenge, spki.challenge
    assert_equal @keygen.key.public_key.to_pem, spki.public_key.to_pem
    assert spki.verify(@keygen.key.public_key)
  end

end

Version data entries

30 entries across 30 versions & 5 rubygems

Version Path
mechanize-2.3 test/test_mechanize_form_keygen.rb
mechanize-2.2.1 test/test_mechanize_form_keygen.rb
mechanize-2.2 test/test_mechanize_form_keygen.rb
mechanize-2.1.1 test/test_mechanize_form_keygen.rb
domo-0.0.5 vendor/bundle/ruby/1.9.1/gems/mechanize-2.1/test/test_mechanize_form_keygen.rb
diamond-mechanize-2.4 test/test_mechanize_form_keygen.rb
diamond-mechanize-2.3 test/test_mechanize_form_keygen.rb
diamond-mechanize-2.1 test/test_mechanize_form_keygen.rb
mechanize-2.1 test/test_mechanize_form_keygen.rb
mechanize-2.1.pre.1 test/test_mechanize_form_keygen.rb