google-api-client 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ # 0.6.1
2
+
3
+ * Fix impersonation with service accounts
4
+
1
5
  # 0.6
2
6
 
3
7
  * Apps strongly encouraged to set :application_name & :application_version when
@@ -112,7 +112,7 @@ module Google
112
112
  #
113
113
  # @see Signet::OAuth2::Client.fetch_access_token!
114
114
  def authorize(person = nil, options={})
115
- authorization = self.to_authorization
115
+ authorization = self.to_authorization(person)
116
116
  authorization.fetch_access_token!(options)
117
117
  return authorization
118
118
  end
@@ -22,7 +22,7 @@ if !defined?(::Google::APIClient::VERSION)
22
22
  module VERSION
23
23
  MAJOR = 0
24
24
  MINOR = 6
25
- TINY = 0
25
+ TINY = 1
26
26
  STRING = [MAJOR, MINOR, TINY].join('.')
27
27
  end
28
28
  end
@@ -471,7 +471,6 @@ describe Google::APIClient do
471
471
  end
472
472
  end
473
473
 
474
- =begin
475
474
  describe 'with the latitude API' do
476
475
  before do
477
476
  CLIENT.authorization = nil
@@ -510,7 +509,7 @@ describe Google::APIClient do
510
509
 
511
510
  it 'should generate requests against the correct URIs' do
512
511
  request = CLIENT.generate_request(
513
- :api_method => 'latitude.currentLocation.get',
512
+ :api_method => @latitude.current_location.get,
514
513
  :authenticated => false
515
514
  )
516
515
  request.to_env(Faraday.default_connection)[:url].to_s.should ===
@@ -528,74 +527,12 @@ describe Google::APIClient do
528
527
 
529
528
  it 'should not be able to execute requests without authorization' do
530
529
  result = CLIENT.execute(
531
- :api_method => 'latitude.currentLocation.get',
530
+ :api_method => @latitude.current_location.get,
532
531
  :authenticated => false
533
532
  )
534
533
  result.response.status.should == 401
535
534
  end
536
535
  end
537
- =end
538
-
539
- describe 'with the moderator API' do
540
- before do
541
- CLIENT.authorization = nil
542
- @moderator = CLIENT.discovered_api('moderator')
543
- end
544
-
545
- it 'should correctly determine the discovery URI' do
546
- CLIENT.discovery_uri('moderator').should ===
547
- 'https://www.googleapis.com/discovery/v1/apis/moderator/v1/rest'
548
- end
549
-
550
- it 'should find APIs that are in the discovery document' do
551
- CLIENT.discovered_api('moderator').name.should == 'moderator'
552
- CLIENT.discovered_api('moderator').version.should == 'v1'
553
- end
554
-
555
- it 'should find methods that are in the discovery document' do
556
- CLIENT.discovered_method(
557
- 'moderator.profiles.get', 'moderator'
558
- ).name.should == 'get'
559
- end
560
-
561
- it 'should define the origin API in discovered methods' do
562
- CLIENT.discovered_method(
563
- 'moderator.profiles.get', 'moderator'
564
- ).api.name.should == 'moderator'
565
- end
566
-
567
- it 'should not find methods that are not in the discovery document' do
568
- CLIENT.discovered_method('moderator.bogus', 'moderator').should == nil
569
- end
570
-
571
- it 'should return a batch path' do
572
- CLIENT.discovered_api('moderator').batch_path.should_not be_nil
573
- end
574
-
575
- it 'should generate requests against the correct URIs' do
576
- conn = stub_connection do |stub|
577
- stub.get('/moderator/v1/profiles/@me') do |env|
578
- end
579
- end
580
- request = CLIENT.execute(
581
- :api_method => @moderator.profiles.get,
582
- :authenticated => false,
583
- :connection => conn
584
- )
585
- conn.verify
586
- end
587
-
588
- it 'should not be able to execute requests without authorization' do
589
- result = CLIENT.execute(
590
- @moderator.profiles.get,
591
- {},
592
- '',
593
- [],
594
- {:authenticated => false}
595
- )
596
- result.response.status.should == 401
597
- end
598
- end
599
536
 
600
537
  describe 'with the adsense API' do
601
538
  before do
@@ -66,6 +66,26 @@ describe Google::APIClient::JWTAsserter do
66
66
  claim["scope"].should == 'scope1 scope2'
67
67
  end
68
68
 
69
+ it 'should allow impersonation' do
70
+ conn = stub_connection do |stub|
71
+ stub.post('/o/oauth2/token') do |env|
72
+ params = Addressable::URI.form_unencode(env[:body])
73
+ JWT.decode(params.assoc("assertion").last, @key.public_key)
74
+ params.assoc("grant_type").should == ['grant_type','urn:ietf:params:oauth:grant-type:jwt-bearer']
75
+ [200, {}, '{
76
+ "access_token" : "1/abcdef1234567890",
77
+ "token_type" : "Bearer",
78
+ "expires_in" : 3600
79
+ }']
80
+ end
81
+ end
82
+ asserter = Google::APIClient::JWTAsserter.new('client1', 'scope1 scope2', @key)
83
+ auth = asserter.authorize('user1@email.com', { :connection => conn })
84
+ auth.should_not == nil?
85
+ auth.person.should == 'user1@email.com'
86
+ conn.verify
87
+ end
88
+
69
89
  it 'should send valid access token request' do
70
90
  conn = stub_connection do |stub|
71
91
  stub.post('/o/oauth2/token') do |env|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-05 00:00:00.000000000Z
13
+ date: 2013-01-15 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: signet
17
- requirement: &70149072361020 !ruby/object:Gem::Requirement
17
+ requirement: &70316156653060 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.4.4
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70149072361020
25
+ version_requirements: *70316156653060
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: addressable
28
- requirement: &70149072360300 !ruby/object:Gem::Requirement
28
+ requirement: &70316156652460 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.3.2
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70149072360300
36
+ version_requirements: *70316156652460
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: uuidtools
39
- requirement: &70149072359760 !ruby/object:Gem::Requirement
39
+ requirement: &70316156651920 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 2.1.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70149072359760
47
+ version_requirements: *70316156651920
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: autoparse
50
- requirement: &70149072359200 !ruby/object:Gem::Requirement
50
+ requirement: &70316156651260 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.3.2
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70149072359200
58
+ version_requirements: *70316156651260
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: faraday
61
- requirement: &70149072358480 !ruby/object:Gem::Requirement
61
+ requirement: &70316156650560 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.8.4
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *70149072358480
69
+ version_requirements: *70316156650560
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: multi_json
72
- requirement: &70149072357900 !ruby/object:Gem::Requirement
72
+ requirement: &70316156650060 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 1.0.0
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *70149072357900
80
+ version_requirements: *70316156650060
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: extlib
83
- requirement: &70149072357260 !ruby/object:Gem::Requirement
83
+ requirement: &70316156649400 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 0.9.15
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *70149072357260
91
+ version_requirements: *70316156649400
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: jwt
94
- requirement: &70149072356600 !ruby/object:Gem::Requirement
94
+ requirement: &70316156648780 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 0.1.5
100
100
  type: :runtime
101
101
  prerelease: false
102
- version_requirements: *70149072356600
102
+ version_requirements: *70316156648780
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: launchy
105
- requirement: &70149072356100 !ruby/object:Gem::Requirement
105
+ requirement: &70316156648260 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: 2.1.1
111
111
  type: :runtime
112
112
  prerelease: false
113
- version_requirements: *70149072356100
113
+ version_requirements: *70316156648260
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rake
116
- requirement: &70149072355480 !ruby/object:Gem::Requirement
116
+ requirement: &70316156647620 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: 0.9.0
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *70149072355480
124
+ version_requirements: *70316156647620
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
- requirement: &70149072354900 !ruby/object:Gem::Requirement
127
+ requirement: &70316156647100 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ! '>='
@@ -132,7 +132,7 @@ dependencies:
132
132
  version: 2.11.0
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *70149072354900
135
+ version_requirements: *70316156647100
136
136
  description: ! 'The Google API Ruby Client makes it trivial to discover and access
137
137
  supported
138
138