diff options
author | John McCrae <john.mccrae@progress.com> | 2022-06-02 09:17:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-02 09:17:01 -0700 |
commit | 568f67c248d6b05900e9daefb94440d7f2976c1a (patch) | |
tree | 328da097a6a0b8a9f45264d605dbf317ab9220f0 | |
parent | 621d432f0ed0f8e0eed1911f3901c937e1111447 (diff) | |
parent | d27e6f2d7fcd0b835f5c89040c08744b364c7a2e (diff) | |
download | ohai-568f67c248d6b05900e9daefb94440d7f2976c1a.tar.gz |
Merge pull request #1747 from chef/jfm/ohai_ruby3.1
-rw-r--r-- | lib/ohai/mixin/azure_metadata.rb | 7 | ||||
-rw-r--r-- | spec/unit/mixin/azure_metadata_spec.rb | 10 |
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/ohai/mixin/azure_metadata.rb b/lib/ohai/mixin/azure_metadata.rb index 7bf17ec9..7212bda2 100644 --- a/lib/ohai/mixin/azure_metadata.rb +++ b/lib/ohai/mixin/azure_metadata.rb @@ -35,9 +35,10 @@ module Ohai AZURE_METADATA_ADDR ||= "169.254.169.254" # it's important that the newer versions are at the end of this array so we can skip sorting it - AZURE_SUPPORTED_VERSIONS ||= %w{ 2017-04-02 2017-08-01 2017-12-01 2018-02-01 2018-04-02 - 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01 - 2019-06-04 2019-08-01 2019-08-15 2019-11-01 }.freeze + AZURE_SUPPORTED_VERSIONS ||= %w{ 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01 + 2019-06-04 2019-08-01 2019-08-15 2019-11-01 2020-06-01 + 2020-07-15 2020-09-01 2020-10-01 2020-12-01 2021-01-01 + 2021-02-01 2021-03-01 2021-05-01 2021-10-01 }.freeze def best_api_version @api_version ||= begin diff --git a/spec/unit/mixin/azure_metadata_spec.rb b/spec/unit/mixin/azure_metadata_spec.rb index 21e6febe..0a3c0455 100644 --- a/spec/unit/mixin/azure_metadata_spec.rb +++ b/spec/unit/mixin/azure_metadata_spec.rb @@ -55,10 +55,10 @@ describe Ohai::Mixin::AzureMetadata do end context "when azure doesn't return any versions we know about" do - let(:response) { double("Net::HTTP Response", body: "{\"error\":\"Bad request. api-version was not specified in the request. For more information refer to aka.ms/azureimds\",\"newest-versions\":[\"2021-01-02\",\"2020-08-01\",\"2020-07-15\"]}", code: "400") } + let(:response) { double("Net::HTTP Response", body: "{\"error\":\"Bad request. api-version was not specified in the request. For more information refer to aka.ms/azureimds\",\"newest-versions\":[\"2020-12-01\",\"2020-10-01\",\"2020-09-01\"]}", code: "400") } it "returns the most recent version we know of" do - expect(mixin.best_api_version).to eq("2019-11-01") + expect(mixin.best_api_version).to eq("2020-12-01") end end @@ -66,12 +66,12 @@ describe Ohai::Mixin::AzureMetadata do let(:response) { double("Net::HTTP Response", code: "404") } it "returns the most recent version we know of" do - expect(mixin.best_api_version).to eq("2019-11-01") + expect(mixin.best_api_version).to eq("2021-10-01") end end context "when the response code is unexpected" do - let(:response) { double("Net::HTTP Response", body: "{\"error\":\"Bad request. api-version was not specified in the request. For more information refer to aka.ms/azureimds\",\"newest-versions\":[\"2021-01-02\",\"2020-08-01\",\"2020-07-15\"]}", code: "418") } + let(:response) { double("Net::HTTP Response", body: "{\"error\":\"Bad request. api-version was not specified in the request. For more information refer to aka.ms/azureimds\",\"newest-versions\":[\"2021-10-01\",\"2021-05-01\",\"2021-03-01\"]}", code: "418") } it "raises an error" do expect { mixin.best_api_version }.to raise_error(RuntimeError) @@ -81,7 +81,7 @@ describe Ohai::Mixin::AzureMetadata do describe "#fetch_metadata" do before do - allow(mixin).to receive(:best_api_version).and_return("2019-11-01") + allow(mixin).to receive(:best_api_version).and_return("2021-10-01") end it "returns an empty hash given a non-200 response" do |