1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Update tests to support IMDSv2 tokens

This commit is contained in:
Ash Tyndall 2020-05-11 15:33:21 +08:00
parent 1cd77b81e7
commit ca288482c8

View file

@ -7,6 +7,8 @@ Shindo.tests('AWS | credentials', ['aws']) do
Fog.unmock! Fog.unmock!
begin begin
Excon.defaults[:mock] = true Excon.defaults[:mock] = true
Excon.stub({ method: :put, path: '/latest/api/token' }, { status: 200, body: 'token1234' })
Excon.stub({ method: :get, path: '/latest/meta-data/iam/security-credentials/' }, { status: 200, body: 'arole' }) Excon.stub({ method: :get, path: '/latest/meta-data/iam/security-credentials/' }, { status: 200, body: 'arole' })
Excon.stub({ method: :get, path: '/latest/meta-data/placement/availability-zone/' }, { status: 200, body: 'us-west-1a' }) Excon.stub({ method: :get, path: '/latest/meta-data/placement/availability-zone/' }, { status: 200, body: 'us-west-1a' })
@ -62,6 +64,7 @@ Shindo.tests('AWS | credentials', ['aws']) do
default_credentials = Fog::AWS::Compute.fetch_credentials({}) default_credentials = Fog::AWS::Compute.fetch_credentials({})
tests('#fetch_credentials when the url 404s') do tests('#fetch_credentials when the url 404s') do
Excon.stub({ method: :put, path: '/latest/api/token' }, { status: 404, body: 'not found' })
Excon.stub({ method: :get, path: '/latest/meta-data/iam/security-credentials/' }, { status: 404, body: 'not bound' }) Excon.stub({ method: :get, path: '/latest/meta-data/iam/security-credentials/' }, { status: 404, body: 'not bound' })
Excon.stub({ method: :get, path: '/latest/meta-data/placement/availability-zone/' }, { status: 400, body: 'not found' }) Excon.stub({ method: :get, path: '/latest/meta-data/placement/availability-zone/' }, { status: 400, body: 'not found' })
returns(default_credentials) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) } returns(default_credentials) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }