From ca288482c81e6f813ec91527b7a64781bb0a18cd Mon Sep 17 00:00:00 2001 From: Ash Tyndall Date: Mon, 11 May 2020 15:33:21 +0800 Subject: [PATCH] Update tests to support IMDSv2 tokens --- tests/credentials_tests.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/credentials_tests.rb b/tests/credentials_tests.rb index a7d0511a2..a6a387392 100644 --- a/tests/credentials_tests.rb +++ b/tests/credentials_tests.rb @@ -7,6 +7,8 @@ Shindo.tests('AWS | credentials', ['aws']) do Fog.unmock! begin 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/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({}) 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/placement/availability-zone/' }, { status: 400, body: 'not found' }) returns(default_credentials) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }