googleauth 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,4 +100,35 @@ describe Signet::OAuth2::Client do
100
100
  expect(stub).to have_been_requested
101
101
  end
102
102
  end
103
+
104
+ describe "#fetch_access_token!" do
105
+ it "retries when orig_fetch_access_token! raises Signet::RemoteServerError" do
106
+ mocked_responses = [:raise, :raise, "success"]
107
+ allow(@client).to receive(:orig_fetch_access_token!).exactly(3).times do
108
+ response = mocked_responses.shift
109
+ response == :raise ? raise(Signet::RemoteServerError) : response
110
+ end
111
+ expect(@client.fetch_access_token!).to eq("success")
112
+ end
113
+
114
+ it "raises when the max retry count is exceeded" do
115
+ mocked_responses = [:raise, :raise, :raise, :raise, :raise, :raise, "success"]
116
+ allow(@client).to receive(:orig_fetch_access_token!).exactly(6).times do
117
+ response = mocked_responses.shift
118
+ response == :raise ? raise(Signet::RemoteServerError) : response
119
+ end
120
+ expect { @client.fetch_access_token! }.to raise_error Signet::AuthorizationError
121
+ end
122
+
123
+ it "does not retry and raises right away if it encounters a Signet::AuthorizationError" do
124
+ allow(@client).to receive(:orig_fetch_access_token!).at_most(:once)
125
+ .and_raise(Signet::AuthorizationError.new("Some Message"))
126
+ expect { @client.fetch_access_token! }.to raise_error Signet::AuthorizationError
127
+ end
128
+
129
+ it "does not retry and raises right away if it encounters a Signet::ParseError" do
130
+ allow(@client).to receive(:orig_fetch_access_token!).at_most(:once).and_raise(Signet::ParseError)
131
+ expect { @client.fetch_access_token! }.to raise_error Signet::ParseError
132
+ end
133
+ end
103
134
  end
@@ -63,6 +63,12 @@ describe Google::Auth::WebUserAuthorizer do
63
63
  )
64
64
  end
65
65
 
66
+ it "should allow adding custom state key-value pairs" do
67
+ url = authorizer.get_authorization_url request: request, state: { james: "bond", kind: 1 }
68
+ expect(url).to match(%r{%22james%22:%22bond%22})
69
+ expect(url).to match(%r{%22kind%22:1})
70
+ end
71
+
66
72
  it "should include request forgery token in state" do
67
73
  expect(SecureRandom).to receive(:base64).and_return("aGVsbG8=")
68
74
  url = authorizer.get_authorization_url request: request
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googleauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Emiola
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -132,8 +132,8 @@ files:
132
132
  - ".kokoro/presubmit/osx.cfg"
133
133
  - ".kokoro/presubmit/windows.cfg"
134
134
  - ".kokoro/release.cfg"
135
+ - ".kokoro/trampoline.bat"
135
136
  - ".kokoro/trampoline.sh"
136
- - ".kokoro/windows.sh"
137
137
  - ".rspec"
138
138
  - ".rubocop.yml"
139
139
  - CHANGELOG.md
@@ -197,7 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  requirements: []
200
- rubygems_version: 3.0.3
200
+ rubyforge_project:
201
+ rubygems_version: 2.7.6.2
201
202
  signing_key:
202
203
  specification_version: 4
203
204
  summary: Google Auth Library for Ruby
@@ -1,4 +0,0 @@
1
- #!/bin/bash
2
-
3
- script_url="https://raw.githubusercontent.com/googleapis/google-cloud-ruby/master/.kokoro/windows.sh"
4
- curl -o master-windows.sh $script_url && source master-windows.sh