Sha256: 398d400e8c58dda0a5efb01146c654d0ab318f6c2ff82ef1874eae6d6076b877

Contents?: true

Size: 786 Bytes

Versions: 7

Compression:

Stored size: 786 Bytes

Contents

require "test/unit"

require "openid/extensions"
require "openid/sreg"
require "openid/util"

class UtilTestCase < Test::Unit::TestCase

  def test_sreg 
    secret = 'foo'
    openid_sig = 'xxx'

    ext_content = "openid.sig:xxx\nsreg.dob:0000-00-00\nsreg.email:foo@bar.com\n"
    ext_sig = OpenID::Util.to_base64(OpenID::Util.hmac_sha1(secret, ext_content))    
    query = {
      'openid.sig' => openid_sig,
      'sreg.email' => 'foo@bar.com',
      'sreg.dob' => '0000-00-00',
      'sreg.sig' => ext_sig
    }

    sreg = OpenID::SREG.create(secret, query)
    assert_not_nil(sreg)
    assert_equal(ext_content, sreg.ext_content)
    assert_equal(ext_sig, sreg.gen_sig)
    assert_equal(true, sreg.check_sig)
    assert_equal(true, OpenID::SREG.check(secret, query))
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby-openid-1.1.1 test/extensions.rb
ruby-openid-1.0 test/extensions.rb
ruby-openid-1.0.1 test/extensions.rb
ruby-openid-1.1.3 test/extensions.rb
ruby-openid-1.1.4 test/extensions.rb
ruby-openid-1.1.2 test/extensions.rb
ruby-openid-1.0.2 test/extensions.rb