1 # Copyright 2010 Google Inc.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 require 'google/api_client/auth/oauth_1'
20 describe Google::APIClient::OAuth1, 'in the default configuration' do
22 @oauth = Google::APIClient::OAuth1.new
25 it 'should have the correct request_token_uri' do
26 @oauth.request_token_uri.should ==
27 'https://www.google.com/accounts/OAuthGetRequestToken'
30 it 'should have the correct authorization_uri' do
31 @oauth.authorization_endpoint_uri.should ==
32 'https://www.google.com/accounts/OAuthAuthorizeToken'
35 it 'should have the correct access_token_uri' do
36 @oauth.access_token_uri.should ==
37 'https://www.google.com/accounts/OAuthGetAccessToken'
40 it 'should have the correct consumer_key' do
41 @oauth.consumer_key.should == 'anonymous'
44 it 'should have the correct consumer_secret' do
45 @oauth.consumer_secret.should == 'anonymous'
48 it 'should allow the request_token to be set manually' do
49 @oauth.request_token = OAuth::RequestToken.new(@oauth, 'key', 'secret')
50 @oauth.request_token.token.should == 'key'
51 @oauth.request_token.secret.should == 'secret'
54 it 'should not allow the request_token to be set to bogus value' do
56 @oauth.request_token = 42
57 end).should raise_error(TypeError)
61 describe Google::APIClient::OAuth1, 'configured for use with bogus service' do
63 @oauth = Google::APIClient::OAuth1.new(:service => :bogus)
66 it 'should have the default configuration' do
67 @oauth.request_token_uri.should ==
68 Google::APIClient::OAuth1::DEFAULTS[:request_token_uri]
69 @oauth.authorization_endpoint_uri.should ==
70 Google::APIClient::OAuth1::DEFAULTS[:authorization_uri]
71 @oauth.access_token_uri.should ==
72 Google::APIClient::OAuth1::DEFAULTS[:access_token_uri]
73 @oauth.scopes.should ==
74 Google::APIClient::OAuth1::DEFAULTS[:scopes]
75 @oauth.callback.should ==
76 Google::APIClient::OAuth1::DEFAULTS[:callback]
77 @oauth.display_name.should ==
78 Google::APIClient::OAuth1::DEFAULTS[:display_name]
79 @oauth.consumer_key.should ==
80 Google::APIClient::OAuth1::DEFAULTS[:consumer_key]
81 @oauth.consumer_secret.should ==
82 Google::APIClient::OAuth1::DEFAULTS[:consumer_secret]