googleauth 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e97bb2d3af353d706c6b608e1743fb3f571e62530201ffa3bebcae2c7e6460bb
4
- data.tar.gz: 3c06cad2ea956d09a37783516292c61f754706366a2b8bf03ef7928769762070
3
+ metadata.gz: db5eb8767a7eae3ca209e8a6eeebc6e8e3b0b8724ce456734fbb4f10fc62319a
4
+ data.tar.gz: 36501fbb7a1963cde692f1122d40fcbc02d6f98d517736ffd11745c42649dcef
5
5
  SHA512:
6
- metadata.gz: 68ad7978f7d5abcc14fbd4ca668ba24f69e4bef2c184427b1a70a8c57e2d742b636d5c0b8da10f4d62f8762adb0075d20c1eb75a76302f9f9b6e61cd1b989685
7
- data.tar.gz: 25333a0a26181c8f8f0464642eccfe0340ed591a4c11f9fe3ed4b85179524c37100431f686a16a75f2985ade010e3b488aeb60a6c1a06e0109db46efa9e1d620
6
+ metadata.gz: fd87ff90b92d1906310f9bebeffa84a692b11bd54c114d597e19c02968955922c0202b87cf6fb6b6e172804234ffb5f4b642ac1415b562013cbd789b942025a0
7
+ data.tar.gz: 444ce4532265ff0b8ecdd384653384579c0d99730fa0c415c957c8a956d603fdc1667e2dd2c112efa062b7c11c55285d783a85894e84c440c74f5c6923140c10
@@ -13,3 +13,13 @@ env_vars: {
13
13
  key: "TRAMPOLINE_BUILD_FILE"
14
14
  value: "github/google-auth-library-ruby/.kokoro/build.sh"
15
15
  }
16
+
17
+ env_vars: {
18
+ key: "TRAMPOLINE_SCRIPT"
19
+ value: "trampoline_v1.py"
20
+ }
21
+
22
+ env_vars: {
23
+ key: "OS"
24
+ value: "linux"
25
+ }
@@ -1,3 +1,8 @@
1
1
  # Format: //devtools/kokoro/config/proto/build.proto
2
2
 
3
3
  build_file: "google-auth-library-ruby/.kokoro/osx.sh"
4
+
5
+ env_vars: {
6
+ key: "OS"
7
+ value: "osx"
8
+ }
@@ -13,7 +13,17 @@ env_vars: {
13
13
  value: "github/google-auth-library-ruby/.kokoro/build.bat"
14
14
  }
15
15
 
16
+ env_vars: {
17
+ key: "TRAMPOLINE_SCRIPT"
18
+ value: "trampoline_windows.py"
19
+ }
20
+
16
21
  env_vars: {
17
22
  key: "REPO_DIR"
18
23
  value: "google-auth-library-ruby"
19
24
  }
25
+
26
+ env_vars: {
27
+ key: "OS"
28
+ value: "windows"
29
+ }
@@ -12,3 +12,13 @@ env_vars: {
12
12
  key: "TRAMPOLINE_BUILD_FILE"
13
13
  value: "github/google-auth-library-ruby/.kokoro/build.sh"
14
14
  }
15
+
16
+ env_vars: {
17
+ key: "TRAMPOLINE_SCRIPT"
18
+ value: "trampoline_v1.py"
19
+ }
20
+
21
+ env_vars: {
22
+ key: "OS"
23
+ value: "linux"
24
+ }
@@ -1,3 +1,8 @@
1
1
  # Format: //devtools/kokoro/config/proto/build.proto
2
2
 
3
3
  build_file: "google-auth-library-ruby/.kokoro/osx.sh"
4
+
5
+ env_vars: {
6
+ key: "OS"
7
+ value: "osx"
8
+ }
@@ -13,7 +13,17 @@ env_vars: {
13
13
  value: "github/google-auth-library-ruby/.kokoro/build.bat"
14
14
  }
15
15
 
16
+ env_vars: {
17
+ key: "TRAMPOLINE_SCRIPT"
18
+ value: "trampoline_windows.py"
19
+ }
20
+
16
21
  env_vars: {
17
22
  key: "REPO_DIR"
18
23
  value: "google-auth-library-ruby"
19
24
  }
25
+
26
+ env_vars: {
27
+ key: "OS"
28
+ value: "windows"
29
+ }
@@ -17,6 +17,37 @@ before_action {
17
17
  }
18
18
  }
19
19
 
20
+ # Fetch magictoken to use with Magic Github Proxy
21
+ before_action {
22
+ fetch_keystore {
23
+ keystore_resource {
24
+ keystore_config_id: 73713
25
+ keyname: "releasetool-magictoken"
26
+ backend_type: FASTCONFIGPUSH
27
+ }
28
+ }
29
+ }
30
+
31
+ # Fetch api key to use with Magic Github Proxy
32
+ before_action {
33
+ fetch_keystore {
34
+ keystore_resource {
35
+ keystore_config_id: 73713
36
+ keyname: "magic-github-proxy-api-key"
37
+ backend_type: FASTCONFIGPUSH
38
+ }
39
+ }
40
+ }
41
+
42
+ before_action {
43
+ fetch_keystore {
44
+ keystore_resource {
45
+ keystore_config_id: 73713
46
+ keyname: "docuploader_service_account"
47
+ }
48
+ }
49
+ }
50
+
20
51
  # Download resources for system tests (service account key, etc.)
21
52
  gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby"
22
53
 
@@ -37,6 +68,11 @@ env_vars: {
37
68
  value: "github/google-auth-library-ruby/.kokoro/build.sh"
38
69
  }
39
70
 
71
+ env_vars: {
72
+ key: "TRAMPOLINE_SCRIPT"
73
+ value: "trampoline_v1.py"
74
+ }
75
+
40
76
  env_vars: {
41
77
  key: "JOB_TYPE"
42
78
  value: "release"
@@ -51,3 +87,8 @@ env_vars: {
51
87
  key: "REPO_DIR"
52
88
  value: "github/google-auth-library-ruby"
53
89
  }
90
+
91
+ env_vars: {
92
+ key: "PACKAGE"
93
+ value: "googleauth"
94
+ }
@@ -1,42 +1,18 @@
1
+ inherit_gem:
2
+ google-style: google-style.yml
3
+
1
4
  AllCops:
2
5
  Exclude:
3
6
  - "spec/**/*"
4
7
  - "Rakefile"
5
-
6
- Metrics/AbcSize:
7
- Max: 25
8
+ Metrics/ClassLength:
9
+ Max: 110
10
+ Exclude:
11
+ - "lib/googleauth/credentials.rb"
12
+ Metrics/ModuleLength:
13
+ Max: 110
8
14
  Metrics/BlockLength:
9
15
  Exclude:
10
16
  - "googleauth.gemspec"
11
- Metrics/CyclomaticComplexity:
12
- Max: 8
13
- Metrics/PerceivedComplexity:
14
- Max: 8
15
- Metrics/LineLength:
16
- Max: 120
17
- Metrics/MethodLength:
18
- Max: 21
19
- Metrics/ModuleLength:
20
- Max: 150
21
- Metrics/ClassLength:
22
- Enabled: false
23
- Layout/IndentHeredoc:
24
- Enabled: false
25
- Style/FormatString:
26
- Enabled: false
27
- Style/GuardClause:
28
- Enabled: false
29
- Style/PercentLiteralDelimiters: # Contradicting rule
30
- Enabled: false
31
- Style/StringLiterals:
32
- EnforcedStyle: double_quotes
33
- Style/SymbolArray: # Undefined syntax in Ruby 1.9.3
34
- Enabled: false
35
- Style/MethodDefParentheses:
36
- Enabled: false
37
- Style/WordArray:
38
- Enabled: false
39
- Style/TrivialAccessors:
40
- Enabled: false
41
- Style/RescueModifier:
17
+ Style/SafeNavigation:
42
18
  Enabled: false
@@ -1,3 +1,13 @@
1
+ ### 0.10.0 / 2019-10-09
2
+
3
+ Note: This release now requires Ruby 2.4 or later
4
+
5
+ * Increase metadata timeout to improve reliability in some hosting environments
6
+ * Support an environment variable to suppress Cloud SDK credentials warnings
7
+ * Make the header check case insensitive
8
+ * Set instance variables at initialization to avoid spamming warnings
9
+ * Pass "Metadata-Flavor" header to metadata server when checking for GCE
10
+
1
11
  ### 0.9.0 / 2019-08-05
2
12
 
3
13
  * Restore compatibility with Ruby 2.0. This is the last release that will work on end-of-lifed versions of Ruby. The 0.10 release will require Ruby 2.4 or later.
data/Gemfile CHANGED
@@ -8,12 +8,12 @@ group :development do
8
8
  gem "coveralls", "~> 0.7"
9
9
  gem "fakefs", "~> 0.6"
10
10
  gem "fakeredis", "~> 0.5"
11
+ gem "google-style", "~> 1.24.0"
11
12
  gem "logging", "~> 2.0"
12
13
  gem "rack-test", "~> 0.6"
13
14
  gem "rake", "~> 10.0"
14
15
  gem "redis", "~> 3.2"
15
16
  gem "rspec", "~> 3.0"
16
- gem "rubocop", ">= 0.41", "< 0.50"
17
17
  gem "simplecov", "~> 0.9"
18
18
  gem "sinatra"
19
19
  gem "webmock", "~> 1.21"
@@ -23,3 +23,5 @@ platforms :jruby do
23
23
  group :development do
24
24
  end
25
25
  end
26
+
27
+ gem "gems", "~> 1.2"
data/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  # Google Auth Library for Ruby
2
2
 
3
3
  <dl>
4
- <dt>Homepage</dt><dd><a href="http://www.github.com/google/google-auth-library-ruby">http://www.github.com/google/google-auth-library-ruby</a></dd>
4
+ <dt>Homepage</dt><dd><a href="http://www.github.com/googleapis/google-auth-library-ruby">http://www.github.com/googleapis/google-auth-library-ruby</a></dd>
5
5
  <dt>Authors</dt><dd><a href="mailto:temiola@google.com">Tim Emiola</a></dd>
6
6
  <dt>Copyright</dt><dd>Copyright © 2015 Google, Inc.</dd>
7
7
  <dt>License</dt><dd>Apache 2.0</dd>
8
8
  </dl>
9
9
 
10
10
  [![Gem Version](https://badge.fury.io/rb/googleauth.svg)](http://badge.fury.io/rb/googleauth)
11
- [![Coverage Status](https://coveralls.io/repos/google/google-auth-library-ruby/badge.svg)](https://coveralls.io/r/google/google-auth-library-ruby)
12
11
 
13
12
  ## Description
14
13
 
@@ -183,11 +182,9 @@ Custom storage implementations can also be used. See
183
182
 
184
183
  ## Supported Ruby Versions
185
184
 
186
- This library is currently supported on Ruby 2.3+.
185
+ This library requires Ruby 2.4 or later.
187
186
 
188
- However, Ruby 2.4 or later is strongly recommended, as earlier releases have
189
- reached or are nearing end-of-life. After March 31, 2019, Google will provide
190
- official support only for Ruby versions that are considered current and
187
+ In general, this library supports Ruby versions that are considered current and
191
188
  supported by Ruby Core (that is, Ruby versions that are either in normal
192
189
  maintenance or in security maintenance).
193
190
  See https://www.ruby-lang.org/en/downloads/branches/ for further details.
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # -*- ruby -*-
2
+ require "json"
2
3
  require "bundler/gem_tasks"
3
4
 
4
5
  task :ci do
@@ -7,12 +8,12 @@ task :ci do
7
8
  sh "bundle exec rspec"
8
9
  end
9
10
 
10
- task :release, :tag do |_t, args|
11
+ task :release_gem, :tag do |_t, args|
11
12
  tag = args[:tag]
12
13
  raise "You must provide a tag to release." if tag.nil?
13
14
 
14
15
  # Verify the tag format "vVERSION"
15
- m = tag.match(/v(?<version>\S*)/)
16
+ m = tag.match(/google-auth-library-ruby\/v(?<version>\S*)/)
16
17
  raise "Tag #{tag} does not match the expected format." if m.nil?
17
18
 
18
19
  version = m[:version]
@@ -33,7 +34,7 @@ task :release, :tag do |_t, args|
33
34
  sh "bundle exec rake build"
34
35
  end
35
36
 
36
- path_to_be_pushed = "pkg/#{version}.gem"
37
+ path_to_be_pushed = "pkg/googleauth-#{version}.gem"
37
38
  if File.file? path_to_be_pushed
38
39
  begin
39
40
  ::Gems.push File.new(path_to_be_pushed)
@@ -75,7 +76,7 @@ namespace :kokoro do
75
76
  .first.split("(").last.split(")").first || "0.1.0"
76
77
  end
77
78
  Rake::Task["kokoro:load_env_vars"].invoke
78
- Rake::Task["release"].invoke "v/#{version}"
79
+ Rake::Task["release_gem"].invoke "google-auth-library-ruby/v#{version}"
79
80
  end
80
81
  end
81
82
 
@@ -1,7 +1,7 @@
1
1
  # -*- ruby -*-
2
2
  # encoding: utf-8
3
3
 
4
- $LOAD_PATH.push File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
5
5
  require "googleauth/version"
6
6
 
7
7
  Gem::Specification.new do |gem|
@@ -25,11 +25,12 @@ Gem::Specification.new do |gem|
25
25
  end
26
26
  gem.require_paths = ["lib"]
27
27
  gem.platform = Gem::Platform::RUBY
28
+ gem.required_ruby_version = ">= 2.4.0"
28
29
 
29
30
  gem.add_dependency "faraday", "~> 0.12"
30
31
  gem.add_dependency "jwt", ">= 1.4", "< 3.0"
31
32
  gem.add_dependency "memoist", "~> 0.16"
32
33
  gem.add_dependency "multi_json", "~> 1.11"
33
34
  gem.add_dependency "os", ">= 0.9", "< 2.0"
34
- gem.add_dependency "signet", "~> 0.7"
35
+ gem.add_dependency "signet", "~> 0.12"
35
36
  end
@@ -34,11 +34,13 @@ module Google
34
34
  # Module Auth provides classes that provide Google-specific authorization
35
35
  # used to access Google APIs.
36
36
  module Auth
37
- NOT_FOUND_ERROR = <<-ERROR_MESSAGE.freeze
38
- Could not load the default credentials. Browse to
39
- https://developers.google.com/accounts/docs/application-default-credentials
40
- for more information
41
- ERROR_MESSAGE
37
+ NOT_FOUND_ERROR = <<~ERROR_MESSAGE.freeze
38
+ Could not load the default credentials. Browse to
39
+ https://developers.google.com/accounts/docs/application-default-credentials
40
+ for more information
41
+ ERROR_MESSAGE
42
+
43
+ module_function
42
44
 
43
45
  # Obtains the default credentials implementation to use in this
44
46
  # environment.
@@ -75,7 +77,5 @@ ERROR_MESSAGE
75
77
  end
76
78
  GCECredentials.new
77
79
  end
78
-
79
- module_function :get_application_default
80
80
  end
81
81
  end
@@ -35,16 +35,16 @@ module Google
35
35
  # Module Auth provides classes that provide Google-specific authorization
36
36
  # used to access Google APIs.
37
37
  module Auth
38
- NO_METADATA_SERVER_ERROR = <<-ERROR.freeze
39
- Error code 404 trying to get security access token
40
- from Compute Engine metadata for the default service account. This
41
- may be because the virtual machine instance does not have permission
42
- scopes specified.
43
- ERROR
44
- UNEXPECTED_ERROR_SUFFIX = <<-ERROR.freeze
45
- trying to get security access token from Compute Engine metadata for
46
- the default service account
47
- ERROR
38
+ NO_METADATA_SERVER_ERROR = <<~ERROR.freeze
39
+ Error code 404 trying to get security access token
40
+ from Compute Engine metadata for the default service account. This
41
+ may be because the virtual machine instance does not have permission
42
+ scopes specified.
43
+ ERROR
44
+ UNEXPECTED_ERROR_SUFFIX = <<~ERROR.freeze
45
+ trying to get security access token from Compute Engine metadata for
46
+ the default service account
47
+ ERROR
48
48
 
49
49
  # Extends Signet::OAuth2::Client so that the auth token is obtained from
50
50
  # the GCE metadata server.
@@ -59,22 +59,16 @@ ERROR
59
59
  extend Memoist
60
60
 
61
61
  # Detect if this appear to be a GCE instance, by checking if metadata
62
- # is available
62
+ # is available.
63
63
  def on_gce? options = {}
64
+ # TODO: This should use google-cloud-env instead.
64
65
  c = options[:connection] || Faraday.default_connection
65
- resp = c.get COMPUTE_CHECK_URI do |req|
66
- # Comment from: oauth2client/client.py
67
- #
68
- # Note: the explicit `timeout` below is a workaround. The underlying
69
- # issue is that resolving an unknown host on some networks will take
70
- # 20-30 seconds; making this timeout short fixes the issue, but
71
- # could lead to false negatives in the event that we are on GCE, but
72
- # the metadata resolution was particularly slow. The latter case is
73
- # "unlikely".
74
- req.options.timeout = 0.1
66
+ headers = { "Metadata-Flavor" => "Google" }
67
+ resp = c.get COMPUTE_CHECK_URI, nil, headers do |req|
68
+ req.options.timeout = 1.0
69
+ req.options.open_timeout = 0.1
75
70
  end
76
71
  return false unless resp.status == 200
77
- return false unless resp.headers.key? "Metadata-Flavor"
78
72
  resp.headers["Metadata-Flavor"] == "Google"
79
73
  rescue Faraday::TimeoutError, Faraday::ConnectionFailed
80
74
  false
@@ -257,6 +257,9 @@ module Google
257
257
  CredentialsLoader.warn_if_cloud_sdk_credentials @client.client_id
258
258
  @project_id ||= CredentialsLoader.load_gcloud_project_id
259
259
  @client.fetch_access_token!
260
+ @env_vars = nil
261
+ @paths = nil
262
+ @scope = nil
260
263
  end
261
264
  # rubocop:enable Metrics/AbcSize
262
265
 
@@ -64,13 +64,13 @@ module Google
64
64
  CLOUD_SDK_CLIENT_ID = "764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.app"\
65
65
  "s.googleusercontent.com".freeze
66
66
 
67
- CLOUD_SDK_CREDENTIALS_WARNING = "Your application has authenticated "\
68
- "using end user credentials from Google Cloud SDK. We recommend that "\
69
- "most server applications use service accounts instead. If your "\
70
- "application continues to use end user credentials from Cloud SDK, "\
71
- 'you might receive a "quota exceeded" or "API not enabled" error. For'\
72
- " more information about service accounts, see "\
73
- "https://cloud.google.com/docs/authentication/.".freeze
67
+ CLOUD_SDK_CREDENTIALS_WARNING = "Your application has authenticated using end user "\
68
+ "credentials from Google Cloud SDK. We recommend that most server applications use "\
69
+ "service accounts instead. If your application continues to use end user credentials "\
70
+ 'from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For '\
71
+ "more information about service accounts, see "\
72
+ "https://cloud.google.com/docs/authentication/. To suppress this message, set the "\
73
+ "GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS environment variable.".freeze
74
74
 
75
75
  # make_creds proxies the construction of a credentials instance
76
76
  #
@@ -163,11 +163,13 @@ module Google
163
163
  raise "#{SYSTEM_DEFAULT_ERROR}: #{e}"
164
164
  end
165
165
 
166
+ module_function
167
+
166
168
  # Issues warning if cloud sdk client id is used
167
169
  def warn_if_cloud_sdk_credentials client_id
170
+ return if ENV["GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS"]
168
171
  warn CLOUD_SDK_CREDENTIALS_WARNING if client_id == CLOUD_SDK_CLIENT_ID
169
172
  end
170
- module_function :warn_if_cloud_sdk_credentials
171
173
 
172
174
  # Finds project_id from gcloud CLI configuration
173
175
  def load_gcloud_project_id
@@ -179,7 +181,6 @@ module Google
179
181
  rescue StandardError
180
182
  nil
181
183
  end
182
- module_function :load_gcloud_project_id
183
184
 
184
185
  private
185
186
 
@@ -193,15 +194,13 @@ module Google
193
194
  end
194
195
 
195
196
  def service_account_env_vars?
196
- [PRIVATE_KEY_VAR, CLIENT_EMAIL_VAR].all? do |key|
197
- ENV[key] && !ENV[key].empty?
198
- end
197
+ ([PRIVATE_KEY_VAR, CLIENT_EMAIL_VAR] - ENV.keys).empty? &&
198
+ !ENV.to_h.fetch_values(PRIVATE_KEY_VAR, CLIENT_EMAIL_VAR).join(" ").empty?
199
199
  end
200
200
 
201
201
  def authorized_user_env_vars?
202
- [CLIENT_ID_VAR, CLIENT_SECRET_VAR, REFRESH_TOKEN_VAR].all? do |key|
203
- ENV[key] && !ENV[key].empty?
204
- end
202
+ ([CLIENT_ID_VAR, CLIENT_SECRET_VAR, REFRESH_TOKEN_VAR] - ENV.keys).empty? &&
203
+ !ENV.to_h.fetch_values(CLIENT_ID_VAR, CLIENT_SECRET_VAR, REFRESH_TOKEN_VAR).join(" ").empty?
205
204
  end
206
205
  end
207
206
  end
@@ -66,7 +66,7 @@ module Signet
66
66
  end
67
67
 
68
68
  def on_refresh &block
69
- @refresh_listeners ||= []
69
+ @refresh_listeners = [] unless defined? @refresh_listeners
70
70
  @refresh_listeners << block
71
71
  end
72
72
 
@@ -84,15 +84,16 @@ module Signet
84
84
  end
85
85
 
86
86
  def notify_refresh_listeners
87
- listeners = @refresh_listeners || []
87
+ listeners = defined?(@refresh_listeners) ? @refresh_listeners : []
88
88
  listeners.each do |block|
89
89
  block.call self
90
90
  end
91
91
  end
92
92
 
93
93
  def build_default_connection
94
- return nil unless defined?(@connection_info)
95
- if @connection_info.respond_to? :call
94
+ if !defined?(@connection_info)
95
+ nil
96
+ elsif @connection_info.respond_to? :call
96
97
  @connection_info.call
97
98
  else
98
99
  @connection_info
@@ -129,8 +129,8 @@ module Google
129
129
  data = MultiJson.load saved_token
130
130
 
131
131
  if data.fetch("client_id", @client_id.id) != @client_id.id
132
- raise sprintf(MISMATCHED_CLIENT_ID_ERROR,
133
- data["client_id"], @client_id.id)
132
+ raise format(MISMATCHED_CLIENT_ID_ERROR,
133
+ data["client_id"], @client_id.id)
134
134
  end
135
135
 
136
136
  credentials = UserRefreshCredentials.new(
@@ -31,6 +31,6 @@ module Google
31
31
  # Module Auth provides classes that provide Google-specific authorization
32
32
  # used to access Google APIs.
33
33
  module Auth
34
- VERSION = "0.9.0".freeze
34
+ VERSION = "0.10.0".freeze
35
35
  end
36
36
  end
@@ -171,7 +171,7 @@ module Google
171
171
  options[:state] = MultiJson.dump(state.merge(
172
172
  SESSION_ID_KEY => request.session[XSRF_KEY],
173
173
  CURRENT_URI_KEY => redirect_to
174
- ))
174
+ ))
175
175
  options[:base_url] = request.url
176
176
  super options
177
177
  end
@@ -97,6 +97,7 @@ describe Google::Auth::GCECredentials do
97
97
  describe "#on_gce?" do
98
98
  it "should be true when Metadata-Flavor is Google" do
99
99
  stub = stub_request(:get, "http://169.254.169.254")
100
+ .with(headers: { "Metadata-Flavor" => "Google" })
100
101
  .to_return(status: 200,
101
102
  headers: { "Metadata-Flavor" => "Google" })
102
103
  expect(GCECredentials.on_gce?({}, true)).to eq(true)
@@ -105,6 +106,7 @@ describe Google::Auth::GCECredentials do
105
106
 
106
107
  it "should be false when Metadata-Flavor is not Google" do
107
108
  stub = stub_request(:get, "http://169.254.169.254")
109
+ .with(headers: { "Metadata-Flavor" => "Google" })
108
110
  .to_return(status: 200,
109
111
  headers: { "Metadata-Flavor" => "NotGoogle" })
110
112
  expect(GCECredentials.on_gce?({}, true)).to eq(false)
@@ -113,6 +115,7 @@ describe Google::Auth::GCECredentials do
113
115
 
114
116
  it "should be false if the response is not 200" do
115
117
  stub = stub_request(:get, "http://169.254.169.254")
118
+ .with(headers: { "Metadata-Flavor" => "Google" })
116
119
  .to_return(status: 404,
117
120
  headers: { "Metadata-Flavor" => "NotGoogle" })
118
121
  expect(GCECredentials.on_gce?({}, true)).to eq(false)
@@ -128,6 +128,7 @@ describe Google::Auth::Credentials, :private do
128
128
  DEFAULT_PATHS = ["~/default/path/to/file.txt"].freeze
129
129
  end
130
130
 
131
+ allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
131
132
  allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
132
133
  allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
133
134
  allow(::ENV).to receive(:[]).with("PATH_ENV_TEST") { "/unknown/path/to/file.txt" }
@@ -164,6 +165,7 @@ describe Google::Auth::Credentials, :private do
164
165
  DEFAULT_PATHS = ["~/default/path/to/file.txt"].freeze
165
166
  end
166
167
 
168
+ allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
167
169
  allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
168
170
  allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
169
171
  allow(::File).to receive(:file?).with(test_json_env_val) { false }
@@ -198,6 +200,7 @@ describe Google::Auth::Credentials, :private do
198
200
  DEFAULT_PATHS = ["~/default/path/to/file.txt"].freeze
199
201
  end
200
202
 
203
+ allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
201
204
  allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
202
205
  allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
203
206
  allow(::ENV).to receive(:[]).with("JSON_ENV_DUMMY") { nil }
@@ -232,6 +235,7 @@ describe Google::Auth::Credentials, :private do
232
235
  DEFAULT_PATHS = ["~/default/path/to/file.txt"].freeze
233
236
  end
234
237
 
238
+ allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
235
239
  allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
236
240
  allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
237
241
  allow(::ENV).to receive(:[]).with("JSON_ENV_DUMMY") { nil }
@@ -310,6 +314,7 @@ describe Google::Auth::Credentials, :private do
310
314
  self.paths = ["~/default/path/to/file.txt"]
311
315
  end
312
316
 
317
+ allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
313
318
  allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
314
319
  allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
315
320
  allow(::ENV).to receive(:[]).with("PATH_ENV_TEST") { "/unknown/path/to/file.txt" }
@@ -345,6 +350,7 @@ describe Google::Auth::Credentials, :private do
345
350
  self.paths = ["~/default/path/to/file.txt"]
346
351
  end
347
352
 
353
+ allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
348
354
  allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
349
355
  allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
350
356
  allow(::File).to receive(:file?).with(test_json_env_val) { false }
@@ -378,6 +384,7 @@ describe Google::Auth::Credentials, :private do
378
384
  self.paths = ["~/default/path/to/file.txt"]
379
385
  end
380
386
 
387
+ allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
381
388
  allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
382
389
  allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
383
390
  allow(::ENV).to receive(:[]).with("JSON_ENV_DUMMY") { nil }
@@ -411,6 +418,7 @@ describe Google::Auth::Credentials, :private do
411
418
  self.paths = ["~/default/path/to/file.txt"]
412
419
  end
413
420
 
421
+ allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
414
422
  allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
415
423
  allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
416
424
  allow(::ENV).to receive(:[]).with("JSON_ENV_DUMMY") { nil }
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.9.0
4
+ version: 0.10.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-08-06 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -98,14 +98,14 @@ dependencies:
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '0.7'
101
+ version: '0.12'
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '0.7'
108
+ version: '0.12'
109
109
  description: |2
110
110
  Allows simple authorization for accessing Google APIs.
111
111
  Provide support for Application Default Credentials, as described at
@@ -190,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
190
  requirements:
191
191
  - - ">="
192
192
  - !ruby/object:Gem::Version
193
- version: '0'
193
+ version: 2.4.0
194
194
  required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  requirements:
196
196
  - - ">="
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  requirements: []
200
200
  rubyforge_project:
201
- rubygems_version: 2.7.6.2
201
+ rubygems_version: 2.7.6
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: Google Auth Library for Ruby