Skip to content

Commit 9028ade

Browse files
committed
Update tests
1 parent 172682e commit 9028ade

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

test/aws/fixtures/aws_config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[profile default]
22
region = us-east-1
3-
[profile cdo-expired]
3+
[profile cdo-expired_session]
44
expiration = 0
5-
[profile cdo-saved]
5+
[profile cdo-saved_session]
66
expiration = 3485728777

test/aws/google_test.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
let :config do
3838
{
3939
role_arn: 'aws_role',
40-
google_client_id: 'client_id',
41-
google_client_secret: 'client_secret',
40+
client_id: 'client_id',
41+
client_secret: 'client_secret',
4242
profile: 'cdo',
4343
client: Aws::STS::Client.new(stub_responses: true)
4444
}
@@ -79,7 +79,7 @@
7979
@oauth_default.once
8080
system.times(5)
8181

82-
c = Aws::STS::Client.new.config.credentials
82+
c = Aws::Google.new(config).credentials
8383
_(c.credentials.access_key_id).must_equal credentials[:access_key_id]
8484
_(c.credentials.secret_access_key).must_equal credentials[:secret_access_key]
8585
_(c.credentials.session_token).must_equal credentials[:session_token]
@@ -95,7 +95,7 @@
9595

9696
system.times(5)
9797

98-
c = Aws::STS::Client.new.config.credentials
98+
c = Aws::Google.new(config).credentials
9999
_(c.credentials.access_key_id).must_equal credentials[:access_key_id]
100100
_(c.credentials.secret_access_key).must_equal credentials[:secret_access_key]
101101
_(c.credentials.session_token).must_equal credentials[:session_token]
@@ -109,25 +109,25 @@
109109
{ credentials: credentials.dup.tap { |c| c[:expiration] = 2.hours.from_now } }
110110
]
111111
)
112-
service = Aws::STS::Client.new
113-
expiration = service.config.credentials.expiration
114-
_(expiration).must_equal(service.config.credentials.expiration)
112+
provider = Aws::Google.new(config)
113+
expiration = provider.expiration
114+
_(expiration).must_equal(provider.expiration)
115115
Timecop.travel(1.5.hours.from_now) do
116-
_(expiration).wont_equal(service.config.credentials.expiration)
116+
_(expiration).wont_equal(provider.expiration)
117117
end
118118
end
119119

120120
it 'refreshes saved expired credentials' do
121121
config[:profile] = 'cdo-expired'
122122
@oauth_default.once
123123
system.times(5)
124-
Aws::STS::Client.new.config.credentials
124+
Aws::Google.new(config).credentials
125125
end
126126

127127
it 'reuses saved credentials without refreshing' do
128128
config[:profile] = 'cdo-saved'
129129
Aws::Google.any_instance.expects(:refresh).never
130-
Aws::STS::Client.new.config.credentials
130+
Aws::Google.new(config).credentials
131131
end
132132

133133
describe 'valid Google auth, no AWS permissions' do
@@ -145,14 +145,14 @@
145145
system.times(5)
146146
@oauth_default.once
147147
Aws::Google.any_instance.expects(:google_oauth).returns(oauth)
148-
Aws::STS::Client.new.config.credentials
148+
Aws::Google.new(config).credentials
149149
end
150150

151151
it 'raises error on invalid AWS permissions' do
152152
Google::Auth.expects(:get_application_default).returns(nil)
153153
Aws::Google.any_instance.expects(:google_oauth).times(2).returns(oauth, nil)
154154
err = assert_raises(Aws::STS::Errors::AccessDenied) do
155-
Aws::STS::Client.new.config.credentials
155+
Aws::Google.new(config).credentials
156156
end
157157
_(err.message).must_match 'Your Google ID does not have access to the requested AWS Role.'
158158
end
@@ -176,7 +176,7 @@
176176
}
177177
)
178178
Aws::Google.any_instance.expects(:google_oauth).returns(oauth)
179-
Aws::STS::Client.new.config.credentials
179+
Aws::Google.new(config).credentials
180180
assert_requested(token_post)
181181
end
182182
end
@@ -196,7 +196,7 @@
196196
system.times(5)
197197
@oauth_default.once
198198
Aws::Google.any_instance.expects(:google_oauth).returns(oauth).once
199-
Aws::STS::Client.new.config.credentials
199+
Aws::Google.new(config).credentials
200200
end
201201
end
202202
end

0 commit comments

Comments
 (0)