signet 0.14.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.md +31 -0
- data/CODE_OF_CONDUCT.md +43 -0
- data/README.md +10 -7
- data/SECURITY.md +7 -0
- data/lib/signet/oauth_1/client.rb +51 -72
- data/lib/signet/oauth_1/credential.rb +3 -11
- data/lib/signet/oauth_1/server.rb +8 -30
- data/lib/signet/oauth_1/signature_methods/hmac_sha1.rb +1 -1
- data/lib/signet/oauth_1/signature_methods/plaintext.rb +1 -1
- data/lib/signet/oauth_1/signature_methods/rsa_sha1.rb +2 -2
- data/lib/signet/oauth_1.rb +12 -22
- data/lib/signet/oauth_2/client.rb +37 -58
- data/lib/signet/oauth_2.rb +10 -14
- data/lib/signet/version.rb +1 -1
- data/lib/signet.rb +5 -8
- metadata +25 -39
- data/Gemfile +0 -8
- data/Rakefile +0 -112
- data/signet.gemspec +0 -44
- data/spec/signet/oauth_1/client_spec.rb +0 -810
- data/spec/signet/oauth_1/credential_spec.rb +0 -169
- data/spec/signet/oauth_1/server_spec.rb +0 -839
- data/spec/signet/oauth_1/signature_methods/hmac_sha1_spec.rb +0 -61
- data/spec/signet/oauth_1/signature_methods/plaintext_spec.rb +0 -61
- data/spec/signet/oauth_1/signature_methods/rsa_sha1_spec.rb +0 -126
- data/spec/signet/oauth_1_spec.rb +0 -1010
- data/spec/signet/oauth_2/client_spec.rb +0 -1254
- data/spec/signet/oauth_2_spec.rb +0 -194
- data/spec/signet_spec.rb +0 -78
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -10
- data/spec/spec_helper_spec.rb +0 -17
- data/website/index.html +0 -95
@@ -1,169 +0,0 @@
|
|
1
|
-
# Copyright (C) 2010 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
require "spec_helper"
|
15
|
-
require "signet/oauth_1/credential"
|
16
|
-
|
17
|
-
describe Signet::OAuth1::Credential, "with a Hash for initialization" do
|
18
|
-
it 'should accept "oauth_token" and "oauth_token_secret" pairs' do
|
19
|
-
token = Signet::OAuth1::Credential.new(
|
20
|
-
"oauth_token" => "dpf43f3p2l4k3l03",
|
21
|
-
"oauth_token_secret" => "kd94hf93k423kf44"
|
22
|
-
)
|
23
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
24
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should accept :oauth_token and :oauth_token_secret pairs" do
|
28
|
-
token = Signet::OAuth1::Credential.new(
|
29
|
-
oauth_token: "dpf43f3p2l4k3l03",
|
30
|
-
oauth_token_secret: "kd94hf93k423kf44"
|
31
|
-
)
|
32
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
33
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should accept "key" and "secret" pairs' do
|
37
|
-
token = Signet::OAuth1::Credential.new(
|
38
|
-
"key" => "dpf43f3p2l4k3l03",
|
39
|
-
"secret" => "kd94hf93k423kf44"
|
40
|
-
)
|
41
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
42
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should accept :key and :secret pairs" do
|
46
|
-
token = Signet::OAuth1::Credential.new(
|
47
|
-
key: "dpf43f3p2l4k3l03",
|
48
|
-
secret: "kd94hf93k423kf44"
|
49
|
-
)
|
50
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
51
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should not complain about additional parameters" do
|
55
|
-
token = Signet::OAuth1::Credential.new(
|
56
|
-
"oauth_token" => "dpf43f3p2l4k3l03",
|
57
|
-
"oauth_token_secret" => "kd94hf93k423kf44",
|
58
|
-
"oauth_version" => "1.0"
|
59
|
-
)
|
60
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
61
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should allow parameters to be specified as an implicit Hash" do
|
65
|
-
class ParameterHashSet
|
66
|
-
def initialize parameters
|
67
|
-
@parameters = parameters.each_with_object({}) { |(k, v), h| h[k] = v; }
|
68
|
-
end
|
69
|
-
|
70
|
-
def to_hash
|
71
|
-
@parameters
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
token = Signet::OAuth1::Credential.new(
|
76
|
-
ParameterHashSet.new(
|
77
|
-
"oauth_token" => "dpf43f3p2l4k3l03",
|
78
|
-
"oauth_token_secret" => "kd94hf93k423kf44",
|
79
|
-
"oauth_version" => "1.0"
|
80
|
-
)
|
81
|
-
)
|
82
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
83
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should allow parameters to be specified as an Enumerable" do
|
87
|
-
token = Signet::OAuth1::Credential.new(
|
88
|
-
[
|
89
|
-
%w[oauth_token dpf43f3p2l4k3l03],
|
90
|
-
%w[oauth_token_secret kd94hf93k423kf44],
|
91
|
-
["oauth_version", "1.0"]
|
92
|
-
]
|
93
|
-
)
|
94
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
95
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should allow parameters to be specified as an implicit Array" do
|
99
|
-
class ParameterArraySet
|
100
|
-
def initialize parameters
|
101
|
-
@parameters = parameters
|
102
|
-
end
|
103
|
-
|
104
|
-
def to_ary
|
105
|
-
@parameters
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
token = Signet::OAuth1::Credential.new(
|
110
|
-
ParameterArraySet.new(
|
111
|
-
[
|
112
|
-
%w[oauth_token dpf43f3p2l4k3l03],
|
113
|
-
%w[oauth_token_secret kd94hf93k423kf44],
|
114
|
-
["oauth_version", "1.0"]
|
115
|
-
]
|
116
|
-
)
|
117
|
-
)
|
118
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
119
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should raise an error if key and secret are not present" do
|
123
|
-
expect(lambda do
|
124
|
-
Signet::OAuth1::Credential.new({})
|
125
|
-
end).to raise_error(ArgumentError)
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should allow key and secret to be passed in as a tuple" do
|
129
|
-
token = Signet::OAuth1::Credential.new(
|
130
|
-
%w[dpf43f3p2l4k3l03 kd94hf93k423kf44]
|
131
|
-
)
|
132
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
133
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should allow key and secret to be passed in as normal parameters" do
|
137
|
-
token = Signet::OAuth1::Credential.new(
|
138
|
-
"dpf43f3p2l4k3l03", "kd94hf93k423kf44"
|
139
|
-
)
|
140
|
-
expect(token.key).to eq "dpf43f3p2l4k3l03"
|
141
|
-
expect(token.secret).to eq "kd94hf93k423kf44"
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should raise an error if key or secret are of the wrong type" do
|
145
|
-
expect(lambda do
|
146
|
-
Signet::OAuth1::Credential.new "dpf43f3p2l4k3l03", 42
|
147
|
-
end).to raise_error(TypeError)
|
148
|
-
expect(lambda do
|
149
|
-
Signet::OAuth1::Credential.new 42, "kd94hf93k423kf44"
|
150
|
-
end).to raise_error(TypeError)
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should raise an error if the wrong number of arguments are passed" do
|
154
|
-
expect(lambda do
|
155
|
-
Signet::OAuth1::Credential.new(
|
156
|
-
"dpf43f3p2l4k3l03", "kd94hf93k423kf44", "something else"
|
157
|
-
)
|
158
|
-
end).to raise_error(ArgumentError)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should convert to a Hash object" do
|
162
|
-
token = Signet::OAuth1::Credential.new(
|
163
|
-
"dpf43f3p2l4k3l03", "kd94hf93k423kf44"
|
164
|
-
)
|
165
|
-
parameters = token.to_h
|
166
|
-
expect(parameters["oauth_token"]).to eq "dpf43f3p2l4k3l03"
|
167
|
-
expect(parameters["oauth_token_secret"]).to eq "kd94hf93k423kf44"
|
168
|
-
end
|
169
|
-
end
|