File: test_signature_plain_text.rb

package info (click to toggle)
ruby-oauth 0.5.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 584 kB
  • sloc: ruby: 4,070; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 1,762 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require File.expand_path('../../test_helper', __FILE__)

require 'oauth/signature/plaintext'

class TestSignaturePlaintext < Minitest::Test
  def test_that_plaintext_implements_plaintext
    assert OAuth::Signature.available_methods.include?('plaintext')
  end

  def test_that_get_request_from_oauth_test_cases_produces_matching_signature
    request = Net::HTTP::Get.new('/photos?file=vacation.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_token=nnch734d00sl2jdk&oauth_signature=kd94hf93k423kf44%26&oauth_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT')

    consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03','kd94hf93k423kf44')
    token = OAuth::Token.new('nnch734d00sl2jdk', nil)

    assert OAuth::Signature.verify(request, { :consumer => consumer,
                                                :token => token,
                                                :uri => 'http://photos.example.net/photos' } )
  end

  def test_that_get_request_from_oauth_test_cases_produces_matching_signature_part_two
    request = Net::HTTP::Get.new('/photos?file=vacation.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_token=nnch734d00sl2jdk&oauth_signature=kd94hf93k423kf44%26pfkkdhi9sl3r4s00&oauth_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT')

    consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03','kd94hf93k423kf44')
    token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00')

    assert OAuth::Signature.verify(request, { :consumer => consumer,
                                                :token => token,
                                                :uri => 'http://photos.example.net/photos' } )
  end

end