File: request_token_spec.cr

package info (click to toggle)
crystal 1.14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,384 kB
  • sloc: javascript: 6,400; sh: 695; makefile: 269; ansic: 121; python: 105; cpp: 77; xml: 32
file content (46 lines) | stat: -rw-r--r-- 1,531 bytes parent folder | download
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require "spec"
require "oauth"

describe OAuth::RequestToken do
  it "creates from response" do
    token = OAuth::RequestToken.from_response("oauth_token_secret=p58A6bzyGaT8PR54gM0S4ZesOVC2ManiTmwHcho8&oauth_callback_confirmed=true&oauth_token=qyprd6Pe2PbnSxUcyHcWz0VnTF8bg1rxsBbUwOpkQ6bSQEyK")
    token.secret.should eq("p58A6bzyGaT8PR54gM0S4ZesOVC2ManiTmwHcho8")
    token.token.should eq("qyprd6Pe2PbnSxUcyHcWz0VnTF8bg1rxsBbUwOpkQ6bSQEyK")
  end

  describe "equality" do
    it "checks token" do
      foo1 = OAuth::RequestToken.new("foo", "secret")
      foo2 = OAuth::RequestToken.new("foo", "secret")
      bar1 = OAuth::RequestToken.new("bar", "secret")
      bar2 = OAuth::RequestToken.new("bar", "secret")

      foo1.should eq(foo2)
      foo1.should_not eq(bar2)
      bar1.should_not eq(foo2)
      bar1.should eq(bar2)

      foo1.hash.should eq(foo2.hash)
      foo1.hash.should_not eq(bar2.hash)
      bar1.hash.should_not eq(foo2.hash)
      bar1.hash.should eq(bar2.hash)
    end

    it "checks secret" do
      foo1 = OAuth::RequestToken.new("token", "foo")
      foo2 = OAuth::RequestToken.new("token", "foo")
      bar1 = OAuth::RequestToken.new("token", "bar")
      bar2 = OAuth::RequestToken.new("token", "bar")

      foo1.should eq(foo2)
      foo1.should_not eq(bar2)
      bar1.should_not eq(foo2)
      bar1.should eq(bar2)

      foo1.hash.should eq(foo2.hash)
      foo1.hash.should_not eq(bar2.hash)
      bar1.hash.should_not eq(foo2.hash)
      bar1.hash.should eq(bar2.hash)
    end
  end
end