mirror of
https://github.com/samsonjs/simple_oauth.git
synced 2026-03-25 08:45:54 +00:00
Test whether OAuth header attributes are parsed and re-keyed correctly.
This commit is contained in:
parent
501f7d8cde
commit
e1ecd99f42
1 changed files with 18 additions and 0 deletions
|
|
@ -32,4 +32,22 @@ class SimpleOAuthTest < Test::Unit::TestCase
|
|||
assert_equal 'HMAC-SHA1', default_options[:signature_method]
|
||||
assert_equal '1.0', default_options[:version]
|
||||
end
|
||||
|
||||
def test_attributes
|
||||
attribute_options = SimpleOAuth::Header::ATTRIBUTE_KEYS.inject({}){|o,a| o.merge(a => a.to_s.upcase) }
|
||||
options = attribute_options.merge(:other => 'OTHER')
|
||||
header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/statuses/friendships.json', {}, options)
|
||||
attributes = header.send(:attributes)
|
||||
|
||||
# OAuth header attributes are all to begin with the "oauth_" prefix.
|
||||
assert attributes.all?{|k,v| k.to_s =~ /^oauth_/ }
|
||||
|
||||
# Custom options not included in the list of valid attribute keys should
|
||||
# not be included in the header attributes.
|
||||
assert !attributes.key?(:oauth_other)
|
||||
|
||||
# Valid attribute option values should be preserved.
|
||||
assert_equal attribute_options.size, attributes.size
|
||||
assert attributes.all?{|k,v| k.to_s == "oauth_#{v.downcase}" }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue