signet 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -19
- data/lib/signet/oauth_2/client.rb +82 -50
- data/lib/signet/oauth_2.rb +9 -2
- data/lib/signet/version.rb +2 -2
- data/signet.gemspec +38 -0
- data/spec/signet/oauth_1/client_spec.rb +231 -243
- data/spec/signet/oauth_1/credential_spec.rb +30 -30
- data/spec/signet/oauth_1/server_spec.rb +128 -129
- data/spec/signet/oauth_1/services/google_spec.rb +24 -25
- data/spec/signet/oauth_1/signature_methods/hmac_sha1_spec.rb +4 -4
- data/spec/signet/oauth_1/signature_methods/plaintext_spec.rb +4 -4
- data/spec/signet/oauth_1/signature_methods/rsa_sha1_spec.rb +6 -6
- data/spec/signet/oauth_1_spec.rb +190 -192
- data/spec/signet/oauth_2/client_spec.rb +296 -181
- data/spec/signet/oauth_2_spec.rb +58 -48
- data/spec/signet_spec.rb +23 -23
- data/spec/spec_helper.rb +3 -1
- data/tasks/gem.rake +3 -55
- data/tasks/spec.rake +0 -25
- metadata +99 -38
@@ -26,8 +26,8 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
26
26
|
"oauth_token" => "dpf43f3p2l4k3l03",
|
27
27
|
"oauth_token_secret" => "kd94hf93k423kf44"
|
28
28
|
})
|
29
|
-
token.key.
|
30
|
-
token.secret.
|
29
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
30
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should accept :oauth_token and :oauth_token_secret pairs' do
|
@@ -35,8 +35,8 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
35
35
|
:oauth_token => "dpf43f3p2l4k3l03",
|
36
36
|
:oauth_token_secret => "kd94hf93k423kf44"
|
37
37
|
})
|
38
|
-
token.key.
|
39
|
-
token.secret.
|
38
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
39
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should accept "key" and "secret" pairs' do
|
@@ -44,8 +44,8 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
44
44
|
"key" => "dpf43f3p2l4k3l03",
|
45
45
|
"secret" => "kd94hf93k423kf44"
|
46
46
|
})
|
47
|
-
token.key.
|
48
|
-
token.secret.
|
47
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
48
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should accept :key and :secret pairs' do
|
@@ -53,8 +53,8 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
53
53
|
:key => "dpf43f3p2l4k3l03",
|
54
54
|
:secret => "kd94hf93k423kf44"
|
55
55
|
)
|
56
|
-
token.key.
|
57
|
-
token.secret.
|
56
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
57
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should not complain about additional parameters' do
|
@@ -63,8 +63,8 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
63
63
|
"oauth_token_secret" => "kd94hf93k423kf44",
|
64
64
|
"oauth_version" => "1.0"
|
65
65
|
})
|
66
|
-
token.key.
|
67
|
-
token.secret.
|
66
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
67
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'should allow parameters to be specified as an implicit Hash' do
|
@@ -83,8 +83,8 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
83
83
|
"oauth_token_secret" => "kd94hf93k423kf44",
|
84
84
|
"oauth_version" => "1.0"
|
85
85
|
}))
|
86
|
-
token.key.
|
87
|
-
token.secret.
|
86
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
87
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'should allow parameters to be specified as an Enumerable' do
|
@@ -93,8 +93,8 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
93
93
|
["oauth_token_secret", "kd94hf93k423kf44"],
|
94
94
|
["oauth_version", "1.0"]
|
95
95
|
])
|
96
|
-
token.key.
|
97
|
-
token.secret.
|
96
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
97
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'should allow parameters to be specified as an implicit Array' do
|
@@ -113,47 +113,47 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
113
113
|
["oauth_token_secret", "kd94hf93k423kf44"],
|
114
114
|
["oauth_version", "1.0"]
|
115
115
|
]))
|
116
|
-
token.key.
|
117
|
-
token.secret.
|
116
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
117
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'should raise an error if key and secret are not present' do
|
121
|
-
(lambda do
|
121
|
+
expect(lambda do
|
122
122
|
Signet::OAuth1::Credential.new({})
|
123
|
-
end).
|
123
|
+
end).to raise_error(ArgumentError)
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'should allow key and secret to be passed in as a tuple' do
|
127
127
|
token = Signet::OAuth1::Credential.new(
|
128
128
|
["dpf43f3p2l4k3l03", "kd94hf93k423kf44"]
|
129
129
|
)
|
130
|
-
token.key.
|
131
|
-
token.secret.
|
130
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
131
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'should allow key and secret to be passed in as normal parameters' do
|
135
135
|
token = Signet::OAuth1::Credential.new(
|
136
136
|
"dpf43f3p2l4k3l03", "kd94hf93k423kf44"
|
137
137
|
)
|
138
|
-
token.key.
|
139
|
-
token.secret.
|
138
|
+
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
139
|
+
expect(token.secret).to eq "kd94hf93k423kf44"
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'should raise an error if key or secret are of the wrong type' do
|
143
|
-
(lambda do
|
143
|
+
expect(lambda do
|
144
144
|
Signet::OAuth1::Credential.new("dpf43f3p2l4k3l03", 42)
|
145
|
-
end).
|
146
|
-
(lambda do
|
145
|
+
end).to raise_error(TypeError)
|
146
|
+
expect(lambda do
|
147
147
|
Signet::OAuth1::Credential.new(42, "kd94hf93k423kf44")
|
148
|
-
end).
|
148
|
+
end).to raise_error(TypeError)
|
149
149
|
end
|
150
150
|
|
151
151
|
it 'should raise an error if the wrong number of arguments are passed' do
|
152
|
-
(lambda do
|
152
|
+
expect(lambda do
|
153
153
|
Signet::OAuth1::Credential.new(
|
154
154
|
"dpf43f3p2l4k3l03", "kd94hf93k423kf44", "something else"
|
155
155
|
)
|
156
|
-
end).
|
156
|
+
end).to raise_error(ArgumentError)
|
157
157
|
end
|
158
158
|
|
159
159
|
it 'should convert to a Hash object' do
|
@@ -161,7 +161,7 @@ describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
|
|
161
161
|
"dpf43f3p2l4k3l03", "kd94hf93k423kf44"
|
162
162
|
)
|
163
163
|
parameters = token.to_h
|
164
|
-
parameters['oauth_token'].
|
165
|
-
parameters['oauth_token_secret'].
|
164
|
+
expect(parameters['oauth_token']).to eq "dpf43f3p2l4k3l03"
|
165
|
+
expect(parameters['oauth_token_secret']).to eq "kd94hf93k423kf44"
|
166
166
|
end
|
167
167
|
end
|