googleauth 0.6.6 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.kokoro/build.bat +8 -0
- data/.kokoro/build.sh +36 -0
- data/.kokoro/common.cfg +22 -0
- data/.kokoro/continuous/common.cfg +19 -0
- data/.kokoro/continuous/linux.cfg +15 -0
- data/.kokoro/continuous/osx.cfg +3 -0
- data/.kokoro/continuous/windows.cfg +3 -0
- data/.kokoro/osx.sh +35 -0
- data/.kokoro/presubmit/common.cfg +19 -0
- data/.kokoro/presubmit/linux.cfg +14 -0
- data/.kokoro/presubmit/osx.cfg +3 -0
- data/.kokoro/presubmit/windows.cfg +3 -0
- data/.kokoro/trampoline.sh +24 -0
- data/.kokoro/windows.sh +32 -0
- data/CHANGELOG.md +4 -0
- data/googleauth.gemspec +3 -3
- data/lib/googleauth/compute_engine.rb +4 -4
- data/lib/googleauth/version.rb +1 -1
- data/spec/googleauth/get_application_default_spec.rb +19 -7
- data/spec/googleauth/service_account_spec.rb +17 -1
- data/spec/googleauth/user_refresh_spec.rb +16 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 05003f9b094636f9937a9f94fd9abcc6eddb55610218b3e96a81d8cf0e2063e1
|
4
|
+
data.tar.gz: 852e87ca3688a90a6e623fd896b340a7c2540d237d8884056b98a1000f4c3d44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbcc424cf05e996efcd94a3f8012c61cacd37228da6723860fd6d6110e93316c246c534fc3be3af5f511afc6944ef52ced8e4c40f0b8299de75de38772257b5b
|
7
|
+
data.tar.gz: 86356649a35b0f3e3ac1137f4af792a0c6e37fd4a9f3a5cfbed3030eea67dcbca8132b07565c493b23f4872fddf8426c2f704c84fd679242db92ef6d47b17b0b
|
data/.kokoro/build.bat
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
REM This file runs tests for merges, PRs, and nightlies.
|
2
|
+
REM There are a few rules for what tests are run:
|
3
|
+
REM * PRs run all non-acceptance tests for every library.
|
4
|
+
REM * Merges run all non-acceptance tests for every library, and acceptance tests for all altered libraries.
|
5
|
+
REM * Nightlies run all acceptance tests for every library.
|
6
|
+
REM Currently only runs tests on 2.5.1
|
7
|
+
|
8
|
+
"C:\Program Files\Git\bin\bash.exe" github/google-auth-library-ruby/.kokoro/windows.sh
|
data/.kokoro/build.sh
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# This file runs tests for merges, PRs, and nightlies.
|
4
|
+
# There are a few rules for what tests are run:
|
5
|
+
# * PRs run all non-acceptance tests for every library.
|
6
|
+
# * Merges run all non-acceptance tests for every library, and acceptance tests for all altered libraries.
|
7
|
+
# * Nightlies run all acceptance tests for every library.
|
8
|
+
|
9
|
+
set -eo pipefail
|
10
|
+
|
11
|
+
# Debug: show build environment
|
12
|
+
env | grep KOKORO
|
13
|
+
|
14
|
+
cd github/google-auth-library-ruby/
|
15
|
+
|
16
|
+
# Print out Ruby version
|
17
|
+
ruby --version
|
18
|
+
|
19
|
+
# Temporary workaround for a known bundler+docker issue:
|
20
|
+
# https://github.com/bundler/bundler/issues/6154
|
21
|
+
export BUNDLE_GEMFILE=
|
22
|
+
|
23
|
+
RUBY_VERSIONS=("2.3.7" "2.4.4" "2.5.1")
|
24
|
+
|
25
|
+
# Capture failures
|
26
|
+
EXIT_STATUS=0 # everything passed
|
27
|
+
function set_failed_status {
|
28
|
+
EXIT_STATUS=1
|
29
|
+
}
|
30
|
+
|
31
|
+
for version in "${RUBY_VERSIONS[@]}"; do
|
32
|
+
rbenv global "$version"
|
33
|
+
(bundle update && bundle exec rake) || set_failed_status
|
34
|
+
done
|
35
|
+
|
36
|
+
exit $EXIT_STATUS
|
data/.kokoro/common.cfg
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Format: //devtools/kokoro/config/proto/build.proto
|
2
|
+
|
3
|
+
# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR}
|
4
|
+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
|
5
|
+
|
6
|
+
# All builds use the trampoline script to run in docker.
|
7
|
+
build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
|
8
|
+
|
9
|
+
# Download secrets from Cloud Storage.
|
10
|
+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-auth-library-ruby"
|
11
|
+
|
12
|
+
# Tell the trampoline which build file to use.
|
13
|
+
env_vars: {
|
14
|
+
key: "TRAMPOLINE_BUILD_FILE"
|
15
|
+
value: "github/google-auth-library-ruby/.kokoro/build.sh"
|
16
|
+
}
|
17
|
+
|
18
|
+
action {
|
19
|
+
define_artifacts {
|
20
|
+
regex: "**/*sponge_log.xml"
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Format: //devtools/kokoro/config/proto/build.proto
|
2
|
+
|
3
|
+
# Build logs will be here
|
4
|
+
action {
|
5
|
+
define_artifacts {
|
6
|
+
regex: "**/*sponge_log.xml"
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
# Download trampoline resources.
|
11
|
+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
|
12
|
+
|
13
|
+
# Download resources for system tests (service account key, etc.)
|
14
|
+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby"
|
15
|
+
|
16
|
+
env_vars: {
|
17
|
+
key: "JOB_TYPE"
|
18
|
+
value: "continuous"
|
19
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Format: //devtools/kokoro/config/proto/build.proto
|
2
|
+
|
3
|
+
build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
|
4
|
+
|
5
|
+
# Configure the docker image for kokoro-trampoline.
|
6
|
+
# Dockerfile is maintained at https://github.com/googleapis/google-cloud-ruby/tree/master/.kokoro/docker/ruby-multi
|
7
|
+
env_vars: {
|
8
|
+
key: "TRAMPOLINE_IMAGE"
|
9
|
+
value: "gcr.io/cloud-devrel-kokoro-resources/google-cloud-ruby/ruby-multi-ubuntu"
|
10
|
+
}
|
11
|
+
|
12
|
+
env_vars: {
|
13
|
+
key: "TRAMPOLINE_BUILD_FILE"
|
14
|
+
value: "github/google-auth-library-ruby/.kokoro/build.sh"
|
15
|
+
}
|
data/.kokoro/osx.sh
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# This file runs tests for merges, PRs, and nightlies.
|
4
|
+
# There are a few rules for what tests are run:
|
5
|
+
# * PRs run all non-acceptance tests for every library.
|
6
|
+
# * Merges run all non-acceptance tests for every library, and acceptance tests for all altered libraries.
|
7
|
+
# * Nightlies run all acceptance tests for every library.
|
8
|
+
# * Currently only runs tests on 2.5.0
|
9
|
+
|
10
|
+
set -eo pipefail
|
11
|
+
|
12
|
+
# Debug: show build environment
|
13
|
+
env | grep KOKORO
|
14
|
+
|
15
|
+
cd github/google-auth-library-ruby/
|
16
|
+
|
17
|
+
# Print out Ruby version
|
18
|
+
ruby --version
|
19
|
+
|
20
|
+
# Temporary workaround for a known bundler+docker issue:
|
21
|
+
# https://github.com/bundler/bundler/issues/6154
|
22
|
+
export BUNDLE_GEMFILE=
|
23
|
+
|
24
|
+
# Capture failures
|
25
|
+
EXIT_STATUS=0 # everything passed
|
26
|
+
function set_failed_status {
|
27
|
+
EXIT_STATUS=1
|
28
|
+
}
|
29
|
+
|
30
|
+
gem install bundle
|
31
|
+
|
32
|
+
|
33
|
+
(bundle update && bundle exec rake) || set_failed_status
|
34
|
+
|
35
|
+
exit $EXIT_STATUS
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Format: //devtools/kokoro/config/proto/build.proto
|
2
|
+
|
3
|
+
# Build logs will be here
|
4
|
+
action {
|
5
|
+
define_artifacts {
|
6
|
+
regex: "**/*sponge_log.xml"
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
# Download trampoline resources.
|
11
|
+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
|
12
|
+
|
13
|
+
# Download resources for system tests (service account key, etc.)
|
14
|
+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby"
|
15
|
+
|
16
|
+
env_vars: {
|
17
|
+
key: "JOB_TYPE"
|
18
|
+
value: "presubmit"
|
19
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Format: //devtools/kokoro/config/proto/build.proto
|
2
|
+
|
3
|
+
build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
|
4
|
+
|
5
|
+
# Configure the docker image for kokoro-trampoline.
|
6
|
+
env_vars: {
|
7
|
+
key: "TRAMPOLINE_IMAGE"
|
8
|
+
value: "gcr.io/cloud-devrel-kokoro-resources/google-cloud-ruby/ruby-multi-ubuntu"
|
9
|
+
}
|
10
|
+
|
11
|
+
env_vars: {
|
12
|
+
key: "TRAMPOLINE_BUILD_FILE"
|
13
|
+
value: "github/google-auth-library-ruby/.kokoro/build.sh"
|
14
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# Copyright 2017 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
set -eo pipefail
|
16
|
+
# Always run the cleanup script, regardless of the success of bouncing into
|
17
|
+
# the container.
|
18
|
+
function cleanup() {
|
19
|
+
chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
|
20
|
+
${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
|
21
|
+
echo "cleanup";
|
22
|
+
}
|
23
|
+
trap cleanup EXIT
|
24
|
+
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py"
|
data/.kokoro/windows.sh
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# This file runs tests for merges, PRs, and nightlies.
|
4
|
+
# There are a few rules for what tests are run:
|
5
|
+
# * PRs run all non-acceptance tests for every library.
|
6
|
+
# * Merges run all non-acceptance tests for every library, and acceptance tests for all altered libraries.
|
7
|
+
# * Nightlies run all acceptance tests for every library.
|
8
|
+
# * Currently only runs tests on 2.5.1
|
9
|
+
|
10
|
+
set -eo pipefail
|
11
|
+
|
12
|
+
# Debug: show build environment
|
13
|
+
env | grep KOKORO
|
14
|
+
|
15
|
+
cd github/google-auth-library-ruby/
|
16
|
+
|
17
|
+
# Print out Ruby version
|
18
|
+
ruby --version
|
19
|
+
|
20
|
+
# Temporary workaround for a known bundler+docker issue:
|
21
|
+
# https://github.com/bundler/bundler/issues/6154
|
22
|
+
export BUNDLE_GEMFILE=
|
23
|
+
|
24
|
+
# Capture failures
|
25
|
+
EXIT_STATUS=0 # everything passed
|
26
|
+
function set_failed_status {
|
27
|
+
EXIT_STATUS=1
|
28
|
+
}
|
29
|
+
|
30
|
+
(bundle update && bundle exec rake) || set_failed_status
|
31
|
+
|
32
|
+
exit $EXIT_STATUS
|
data/CHANGELOG.md
CHANGED
data/googleauth.gemspec
CHANGED
@@ -12,11 +12,11 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = 'https://github.com/google/google-auth-library-ruby'
|
13
13
|
s.summary = 'Google Auth Library for Ruby'
|
14
14
|
s.license = 'Apache-2.0'
|
15
|
-
s.description = <<-
|
15
|
+
s.description = <<-DESCRIPTION
|
16
16
|
Allows simple authorization for accessing Google APIs.
|
17
17
|
Provide support for Application Default Credentials, as described at
|
18
18
|
https://developers.google.com/accounts/docs/application-default-credentials
|
19
|
-
|
19
|
+
DESCRIPTION
|
20
20
|
|
21
21
|
s.files = `git ls-files`.split("\n")
|
22
22
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
|
29
29
|
s.add_dependency 'faraday', '~> 0.12'
|
30
30
|
s.add_dependency 'jwt', '>= 1.4', '< 3.0'
|
31
|
-
s.add_dependency 'memoist', '~> 0.
|
31
|
+
s.add_dependency 'memoist', '~> 0.16'
|
32
32
|
s.add_dependency 'multi_json', '~> 1.11'
|
33
33
|
s.add_dependency 'os', '>= 0.9', '< 2.0'
|
34
34
|
s.add_dependency 'signet', '~> 0.7'
|
@@ -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 = <<
|
38
|
+
NO_METADATA_SERVER_ERROR = <<ERROR.freeze
|
39
39
|
Error code 404 trying to get security access token
|
40
40
|
from Compute Engine metadata for the default service account. This
|
41
41
|
may be because the virtual machine instance does not have permission
|
42
42
|
scopes specified.
|
43
|
-
|
44
|
-
UNEXPECTED_ERROR_SUFFIX = <<
|
43
|
+
ERROR
|
44
|
+
UNEXPECTED_ERROR_SUFFIX = <<ERROR.freeze
|
45
45
|
trying to get security access token from Compute Engine metadata for
|
46
46
|
the default service account
|
47
|
-
|
47
|
+
ERROR
|
48
48
|
|
49
49
|
# Extends Signet::OAuth2::Client so that the auth token is obtained from
|
50
50
|
# the GCE metadata server.
|
data/lib/googleauth/version.rb
CHANGED
@@ -50,12 +50,16 @@ describe '#get_application_default' do
|
|
50
50
|
@original_env_vals = {}
|
51
51
|
@credential_vars.each { |var| @original_env_vals[var] = ENV[var] }
|
52
52
|
@home = ENV['HOME']
|
53
|
+
@app_data = ENV['APPDATA']
|
54
|
+
@program_data = ENV['ProgramData']
|
53
55
|
@scope = 'https://www.googleapis.com/auth/userinfo.profile'
|
54
56
|
end
|
55
57
|
|
56
58
|
after(:example) do
|
57
59
|
@credential_vars.each { |var| ENV[var] = @original_env_vals[var] }
|
58
60
|
ENV['HOME'] = @home unless @home == ENV['HOME']
|
61
|
+
ENV['APPDATA'] = @app_data unless @app_data == ENV['APPDATA']
|
62
|
+
ENV['ProgramData'] = @program_data unless @program_data == ENV['ProgramData']
|
59
63
|
end
|
60
64
|
|
61
65
|
shared_examples 'it cannot load misconfigured credentials' do
|
@@ -90,7 +94,7 @@ describe '#get_application_default' do
|
|
90
94
|
FileUtils.mkdir_p(File.dirname(key_path))
|
91
95
|
File.write(key_path, cred_json_text)
|
92
96
|
ENV[@var_name] = key_path
|
93
|
-
expect(Google::Auth.get_application_default
|
97
|
+
expect(Google::Auth.get_application_default(@scope, options))
|
94
98
|
.to_not be_nil
|
95
99
|
end
|
96
100
|
end
|
@@ -99,10 +103,12 @@ describe '#get_application_default' do
|
|
99
103
|
ENV.delete(@var_name) unless ENV[@var_name].nil?
|
100
104
|
Dir.mktmpdir do |dir|
|
101
105
|
key_path = File.join(dir, '.config', WELL_KNOWN_PATH)
|
106
|
+
key_path = File.join(dir, WELL_KNOWN_PATH) if OS.windows?
|
102
107
|
FileUtils.mkdir_p(File.dirname(key_path))
|
103
108
|
File.write(key_path, cred_json_text)
|
104
109
|
ENV['HOME'] = dir
|
105
|
-
|
110
|
+
ENV['APPDATA'] = dir
|
111
|
+
expect(Google::Auth.get_application_default(@scope, options))
|
106
112
|
.to_not be_nil
|
107
113
|
end
|
108
114
|
end
|
@@ -111,10 +117,12 @@ describe '#get_application_default' do
|
|
111
117
|
ENV.delete(@var_name) unless ENV[@var_name].nil?
|
112
118
|
Dir.mktmpdir do |dir|
|
113
119
|
key_path = File.join(dir, '.config', WELL_KNOWN_PATH)
|
120
|
+
key_path = File.join(dir, WELL_KNOWN_PATH) if OS.windows?
|
114
121
|
FileUtils.mkdir_p(File.dirname(key_path))
|
115
122
|
File.write(key_path, cred_json_text)
|
116
123
|
ENV['HOME'] = dir
|
117
|
-
|
124
|
+
ENV['APPDATA'] = dir
|
125
|
+
expect(Google::Auth.get_application_default(nil, options)).to_not be_nil
|
118
126
|
end
|
119
127
|
end
|
120
128
|
|
@@ -134,10 +142,12 @@ describe '#get_application_default' do
|
|
134
142
|
it 'succeeds with system default file' do
|
135
143
|
ENV.delete(@var_name) unless ENV[@var_name].nil?
|
136
144
|
FakeFS do
|
137
|
-
|
145
|
+
ENV['ProgramData'] = '/etc'
|
146
|
+
prefix = OS.windows? ? '/etc/Google/Auth/' : '/etc/google/auth/'
|
147
|
+
key_path = File.join(prefix, CREDENTIALS_FILE_NAME)
|
138
148
|
FileUtils.mkdir_p(File.dirname(key_path))
|
139
149
|
File.write(key_path, cred_json_text)
|
140
|
-
expect(Google::Auth.get_application_default
|
150
|
+
expect(Google::Auth.get_application_default(@scope, options))
|
141
151
|
.to_not be_nil
|
142
152
|
File.delete(key_path)
|
143
153
|
end
|
@@ -151,7 +161,7 @@ describe '#get_application_default' do
|
|
151
161
|
ENV[CLIENT_SECRET_VAR] = cred_json[:client_secret]
|
152
162
|
ENV[REFRESH_TOKEN_VAR] = cred_json[:refresh_token]
|
153
163
|
ENV[ACCOUNT_TYPE_VAR] = cred_json[:type]
|
154
|
-
expect(Google::Auth.get_application_default
|
164
|
+
expect(Google::Auth.get_application_default(@scope, options))
|
155
165
|
.to_not be_nil
|
156
166
|
end
|
157
167
|
|
@@ -164,7 +174,7 @@ describe '#get_application_default' do
|
|
164
174
|
ENV[REFRESH_TOKEN_VAR] = cred_json[:refresh_token]
|
165
175
|
ENV[ACCOUNT_TYPE_VAR] = cred_json[:type]
|
166
176
|
expect { Google::Auth.get_application_default @scope, options }.to output(
|
167
|
-
|
177
|
+
Google::Auth::CredentialsLoader::CLOUD_SDK_CREDENTIALS_WARNING + "\n"
|
168
178
|
).to_stderr
|
169
179
|
end
|
170
180
|
end
|
@@ -238,9 +248,11 @@ describe '#get_application_default' do
|
|
238
248
|
ENV.delete(@var_name) unless ENV[@var_name].nil?
|
239
249
|
Dir.mktmpdir do |dir|
|
240
250
|
key_path = File.join(dir, '.config', WELL_KNOWN_PATH)
|
251
|
+
key_path = File.join(dir, WELL_KNOWN_PATH) if OS.windows?
|
241
252
|
FileUtils.mkdir_p(File.dirname(key_path))
|
242
253
|
File.write(key_path, cred_json_text)
|
243
254
|
ENV['HOME'] = dir
|
255
|
+
ENV['APPDATA'] = dir
|
244
256
|
expect do
|
245
257
|
Google::Auth.get_application_default @scope, options
|
246
258
|
end.to raise_error RuntimeError
|
@@ -40,6 +40,7 @@ require 'multi_json'
|
|
40
40
|
require 'openssl'
|
41
41
|
require 'spec_helper'
|
42
42
|
require 'tmpdir'
|
43
|
+
require 'os'
|
43
44
|
|
44
45
|
include Google::Auth::CredentialsLoader
|
45
46
|
|
@@ -223,6 +224,7 @@ describe Google::Auth::ServiceAccountCredentials do
|
|
223
224
|
describe '#from_well_known_path' do
|
224
225
|
before(:example) do
|
225
226
|
@home = ENV['HOME']
|
227
|
+
@app_data = ENV['APPDATA']
|
226
228
|
@scope = 'https://www.googleapis.com/auth/userinfo.profile'
|
227
229
|
@known_path = WELL_KNOWN_PATH
|
228
230
|
@clz = ServiceAccountCredentials
|
@@ -230,6 +232,7 @@ describe Google::Auth::ServiceAccountCredentials do
|
|
230
232
|
|
231
233
|
after(:example) do
|
232
234
|
ENV['HOME'] = @home unless @home == ENV['HOME']
|
235
|
+
ENV['APPDATA'] = @app_data unless @app_data == ENV['APPDATA']
|
233
236
|
end
|
234
237
|
|
235
238
|
it 'is nil if no file exists' do
|
@@ -240,9 +243,11 @@ describe Google::Auth::ServiceAccountCredentials do
|
|
240
243
|
it 'successfully loads the file when it is present' do
|
241
244
|
Dir.mktmpdir do |dir|
|
242
245
|
key_path = File.join(dir, '.config', @known_path)
|
246
|
+
key_path = File.join(dir, WELL_KNOWN_PATH) if OS.windows?
|
243
247
|
FileUtils.mkdir_p(File.dirname(key_path))
|
244
248
|
File.write(key_path, cred_json_text)
|
245
249
|
ENV['HOME'] = dir
|
250
|
+
ENV['APPDATA'] = dir
|
246
251
|
expect(@clz.from_well_known_path(@scope)).to_not be_nil
|
247
252
|
end
|
248
253
|
end
|
@@ -251,10 +256,16 @@ describe Google::Auth::ServiceAccountCredentials do
|
|
251
256
|
describe '#from_system_default_path' do
|
252
257
|
before(:example) do
|
253
258
|
@scope = 'https://www.googleapis.com/auth/userinfo.profile'
|
254
|
-
@
|
259
|
+
@program_data = ENV['ProgramData']
|
260
|
+
@prefix = OS.windows? ? '/etc/Google/Auth/' : '/etc/google/auth/'
|
261
|
+
@path = File.join(@prefix, CREDENTIALS_FILE_NAME)
|
255
262
|
@clz = ServiceAccountCredentials
|
256
263
|
end
|
257
264
|
|
265
|
+
after(:example) do
|
266
|
+
ENV['ProgramData'] = @program_data
|
267
|
+
end
|
268
|
+
|
258
269
|
it 'is nil if no file exists' do
|
259
270
|
FakeFS do
|
260
271
|
expect(ServiceAccountCredentials.from_system_default_path(@scope))
|
@@ -264,6 +275,7 @@ describe Google::Auth::ServiceAccountCredentials do
|
|
264
275
|
|
265
276
|
it 'successfully loads the file when it is present' do
|
266
277
|
FakeFS do
|
278
|
+
ENV['ProgramData'] = '/etc'
|
267
279
|
FileUtils.mkdir_p(File.dirname(@path))
|
268
280
|
File.write(@path, cred_json_text)
|
269
281
|
expect(@clz.from_system_default_path(@scope)).to_not be_nil
|
@@ -351,10 +363,12 @@ describe Google::Auth::ServiceAccountJwtHeaderCredentials do
|
|
351
363
|
describe '#from_well_known_path' do
|
352
364
|
before(:example) do
|
353
365
|
@home = ENV['HOME']
|
366
|
+
@app_data = ENV['APPDATA']
|
354
367
|
end
|
355
368
|
|
356
369
|
after(:example) do
|
357
370
|
ENV['HOME'] = @home unless @home == ENV['HOME']
|
371
|
+
ENV['APPDATA'] = @app_data unless @app_data == ENV['APPDATA']
|
358
372
|
end
|
359
373
|
|
360
374
|
it 'is nil if no file exists' do
|
@@ -365,9 +379,11 @@ describe Google::Auth::ServiceAccountJwtHeaderCredentials do
|
|
365
379
|
it 'successfully loads the file when it is present' do
|
366
380
|
Dir.mktmpdir do |dir|
|
367
381
|
key_path = File.join(dir, '.config', WELL_KNOWN_PATH)
|
382
|
+
key_path = File.join(dir, WELL_KNOWN_PATH) if OS.windows?
|
368
383
|
FileUtils.mkdir_p(File.dirname(key_path))
|
369
384
|
File.write(key_path, cred_json_text)
|
370
385
|
ENV['HOME'] = dir
|
386
|
+
ENV['APPDATA'] = dir
|
371
387
|
expect(clz.from_well_known_path).to_not be_nil
|
372
388
|
end
|
373
389
|
end
|
@@ -40,6 +40,7 @@ require 'multi_json'
|
|
40
40
|
require 'openssl'
|
41
41
|
require 'spec_helper'
|
42
42
|
require 'tmpdir'
|
43
|
+
require 'os'
|
43
44
|
|
44
45
|
include Google::Auth::CredentialsLoader
|
45
46
|
|
@@ -154,6 +155,7 @@ describe Google::Auth::UserRefreshCredentials do
|
|
154
155
|
describe '#from_well_known_path' do
|
155
156
|
before(:example) do
|
156
157
|
@home = ENV['HOME']
|
158
|
+
@app_data = ENV['APPDATA']
|
157
159
|
@scope = 'https://www.googleapis.com/auth/userinfo.profile'
|
158
160
|
@known_path = WELL_KNOWN_PATH
|
159
161
|
@clz = UserRefreshCredentials
|
@@ -161,6 +163,7 @@ describe Google::Auth::UserRefreshCredentials do
|
|
161
163
|
|
162
164
|
after(:example) do
|
163
165
|
ENV['HOME'] = @home unless @home == ENV['HOME']
|
166
|
+
ENV['APPDATA'] = @app_data unless @app_data == ENV['APPDATA']
|
164
167
|
end
|
165
168
|
|
166
169
|
it 'is nil if no file exists' do
|
@@ -173,9 +176,11 @@ describe Google::Auth::UserRefreshCredentials do
|
|
173
176
|
needed.each do |missing|
|
174
177
|
Dir.mktmpdir do |dir|
|
175
178
|
key_path = File.join(dir, '.config', @known_path)
|
179
|
+
key_path = File.join(dir, @known_path) if OS.windows?
|
176
180
|
FileUtils.mkdir_p(File.dirname(key_path))
|
177
181
|
File.write(key_path, cred_json_text(missing))
|
178
182
|
ENV['HOME'] = dir
|
183
|
+
ENV['APPDATA'] = dir
|
179
184
|
expect { @clz.from_well_known_path(@scope) }
|
180
185
|
.to raise_error RuntimeError
|
181
186
|
end
|
@@ -185,9 +190,11 @@ describe Google::Auth::UserRefreshCredentials do
|
|
185
190
|
it 'successfully loads the file when it is present' do
|
186
191
|
Dir.mktmpdir do |dir|
|
187
192
|
key_path = File.join(dir, '.config', @known_path)
|
193
|
+
key_path = File.join(dir, @known_path) if OS.windows?
|
188
194
|
FileUtils.mkdir_p(File.dirname(key_path))
|
189
195
|
File.write(key_path, cred_json_text)
|
190
196
|
ENV['HOME'] = dir
|
197
|
+
ENV['APPDATA'] = dir
|
191
198
|
expect(@clz.from_well_known_path(@scope)).to_not be_nil
|
192
199
|
end
|
193
200
|
end
|
@@ -196,10 +203,16 @@ describe Google::Auth::UserRefreshCredentials do
|
|
196
203
|
describe '#from_system_default_path' do
|
197
204
|
before(:example) do
|
198
205
|
@scope = 'https://www.googleapis.com/auth/userinfo.profile'
|
199
|
-
@
|
206
|
+
@prefix = OS.windows? ? '/etc/Google/Auth/' : '/etc/google/auth/'
|
207
|
+
@path = File.join(@prefix, CREDENTIALS_FILE_NAME)
|
208
|
+
@program_data = ENV['ProgramData']
|
200
209
|
@clz = UserRefreshCredentials
|
201
210
|
end
|
202
211
|
|
212
|
+
after(:example) do
|
213
|
+
ENV['ProgramData'] = @program_data
|
214
|
+
end
|
215
|
+
|
203
216
|
it 'is nil if no file exists' do
|
204
217
|
FakeFS do
|
205
218
|
expect(UserRefreshCredentials.from_system_default_path(@scope))
|
@@ -211,6 +224,7 @@ describe Google::Auth::UserRefreshCredentials do
|
|
211
224
|
needed = %w(client_id client_secret refresh_token)
|
212
225
|
needed.each do |missing|
|
213
226
|
FakeFS do
|
227
|
+
ENV['ProgramData'] = '/etc'
|
214
228
|
FileUtils.mkdir_p(File.dirname(@path))
|
215
229
|
File.write(@path, cred_json_text(missing))
|
216
230
|
expect { @clz.from_system_default_path(@scope) }
|
@@ -222,6 +236,7 @@ describe Google::Auth::UserRefreshCredentials do
|
|
222
236
|
|
223
237
|
it 'successfully loads the file when it is present' do
|
224
238
|
FakeFS do
|
239
|
+
ENV['ProgramData'] = '/etc'
|
225
240
|
FileUtils.mkdir_p(File.dirname(@path))
|
226
241
|
File.write(@path, cred_json_text)
|
227
242
|
expect(@clz.from_system_default_path(@scope)).to_not be_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.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Emiola
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.16'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
60
|
+
version: '0.16'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: multi_json
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +116,20 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- ".gitignore"
|
119
|
+
- ".kokoro/build.bat"
|
120
|
+
- ".kokoro/build.sh"
|
121
|
+
- ".kokoro/common.cfg"
|
122
|
+
- ".kokoro/continuous/common.cfg"
|
123
|
+
- ".kokoro/continuous/linux.cfg"
|
124
|
+
- ".kokoro/continuous/osx.cfg"
|
125
|
+
- ".kokoro/continuous/windows.cfg"
|
126
|
+
- ".kokoro/osx.sh"
|
127
|
+
- ".kokoro/presubmit/common.cfg"
|
128
|
+
- ".kokoro/presubmit/linux.cfg"
|
129
|
+
- ".kokoro/presubmit/osx.cfg"
|
130
|
+
- ".kokoro/presubmit/windows.cfg"
|
131
|
+
- ".kokoro/trampoline.sh"
|
132
|
+
- ".kokoro/windows.sh"
|
119
133
|
- ".rspec"
|
120
134
|
- ".rubocop.yml"
|
121
135
|
- ".travis.yml"
|
@@ -182,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
196
|
version: '0'
|
183
197
|
requirements: []
|
184
198
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
199
|
+
rubygems_version: 2.7.6
|
186
200
|
signing_key:
|
187
201
|
specification_version: 4
|
188
202
|
summary: Google Auth Library for Ruby
|