diff options
author | wilkosz <joshua@wilkosz.com.au> | 2020-04-27 15:01:44 +1000 |
---|---|---|
committer | wilkosz <joshua@wilkosz.com.au> | 2020-04-27 15:01:44 +1000 |
commit | 466c94b07bd4535ba869140c0f7d7655334090cf (patch) | |
tree | 3104768bedec48fffa7c7d61c929cd49a962e8ea | |
parent | 857390570e72c718040b4799f48dc6b98b7aa52c (diff) | |
download | ohai-466c94b07bd4535ba869140c0f7d7655334090cf.tar.gz |
pop
-rw-r--r-- | spec/unit/mixin/ec2_metadata_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/ec2_spec.rb | 74 |
2 files changed, 38 insertions, 38 deletions
diff --git a/spec/unit/mixin/ec2_metadata_spec.rb b/spec/unit/mixin/ec2_metadata_spec.rb index 30fc4d13..5d5286b8 100644 --- a/spec/unit/mixin/ec2_metadata_spec.rb +++ b/spec/unit/mixin/ec2_metadata_spec.rb @@ -22,7 +22,7 @@ describe Ohai::Mixin::Ec2Metadata do let(:mixin) do metadata_object = Object.new.extend(described_class) http_client = double("Net::HTTP client") - allow(http_client).to receive(:put) { double("Net::HTTP::PUT Response", body: "xxxxxxxxxxxxxxxxxxxxxxxx==", code: "200") } + allow(http_client).to receive(:put) { double("Net::HTTP::PUT Response", body: "AQAEAE4UUd-3NE5EEeYYXKxicVfDOHsx0YSHFFSuCvo2GfCcxzJsvg==", code: "200") } allow(http_client).to receive(:get).and_return(response) allow(metadata_object).to receive(:http_client).and_return(http_client) metadata_object diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb index bcd3e6c8..a7a7bb50 100644 --- a/spec/unit/plugins/ec2_spec.rb +++ b/spec/unit/plugins/ec2_spec.rb @@ -48,7 +48,7 @@ describe Ohai::System, "plugin ec2" do t = double("connection") allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS) allow(Socket).to receive(:new).and_return(t) - @token = "xxxxxxxxxxxxxxxxxxxxxxxx==" + @token = "AQAEAE4UUd-3NE5EEeYYXKxicVfDOHsx0YSHFFSuCvo2GfCcxzJsvg==" @get_token_header = {:'X-aws-ec2-metadata-token' => @token} allow(@http_client).to receive(:put) { double("Net::HTTP::PUT Response", body: @token, code: "200") } expect(@http_client).to receive(:get) @@ -90,14 +90,14 @@ describe Ohai::System, "plugin ec2" do paths.each do |name, body| expect(@http_client).to receive(:get) .with("/2012-01-12/#{name}", @get_token_header) - .and_return(double("Net::HTTP Response", body: body, code: "200")) + .and_return(double("Net::HTTP::GET Response", body: body, code: "200")) end expect(@http_client).to receive(:get) .with("/2012-01-12/user-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/dynamic/instance-identity/document/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) plugin.run @@ -112,14 +112,14 @@ describe Ohai::System, "plugin ec2" do paths.each do |name, body| expect(@http_client).to receive(:get) .with("/2012-01-12/#{name}", @get_token_header) - .and_return(double("Net::HTTP Response", body: body, code: "200")) + .and_return(double("Net::HTTP::GET Response", body: body, code: "200")) end expect(@http_client).to receive(:get) .with("/2012-01-12/user-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/dynamic/instance-identity/document/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) plugin.run @@ -134,14 +134,14 @@ describe Ohai::System, "plugin ec2" do paths.each do |name, body| expect(@http_client).to receive(:get) .with("/2012-01-12/#{name}", @get_token_header) - .and_return(double("Net::HTTP Response", body: body, code: "200")) + .and_return(double("Net::HTTP::GET Response", body: body, code: "200")) end expect(@http_client).to receive(:get) .with("/2012-01-12/user-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/dynamic/instance-identity/document/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\"region\":\"us-east-1\"}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\"region\":\"us-east-1\"}", code: "200")) plugin.run @@ -156,14 +156,14 @@ describe Ohai::System, "plugin ec2" do paths.each do |name, body| expect(@http_client).to receive(:get) .with("/2012-01-12/#{name}", @get_token_header) - .and_return(double("Net::HTTP Response", body: body, code: "200")) + .and_return(double("Net::HTTP::GET Response", body: body, code: "200")) end expect(@http_client).to receive(:get) .with("/2012-01-12/user-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/dynamic/instance-identity/document/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\"availabilityZone\":\"us-east-1d\"}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\"availabilityZone\":\"us-east-1d\"}", code: "200")) plugin.run @@ -215,22 +215,22 @@ describe Ohai::System, "plugin ec2" do it "parses ec2 iam/ directory and collect iam/security-credentials/" do expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "iam/", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "iam/", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/iam/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "security-credentials/", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "security-credentials/", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/iam/security-credentials/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "MyRole", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "MyRole", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/iam/security-credentials/MyRole", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/user-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "By the pricking of my thumb...", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/dynamic/instance-identity/document/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) plugin.run @@ -248,22 +248,22 @@ describe Ohai::System, "plugin ec2" do it "parses ec2 iam/ directory and NOT collect iam/security-credentials/" do expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "iam/", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "iam/", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/iam/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "security-credentials/", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "security-credentials/", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/iam/security-credentials/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "MyRole", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "MyRole", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/iam/security-credentials/MyRole", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/user-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "By the pricking of my thumb...", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/dynamic/instance-identity/document/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) plugin.run @@ -275,7 +275,7 @@ describe Ohai::System, "plugin ec2" do it "ignores \"./\" and \"../\" on ec2 metadata paths to avoid infinity loops" do expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: ".\n./\n..\n../\npath1/.\npath2/./\npath3/..\npath4/../", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: ".\n./\n..\n../\npath1/.\npath2/./\npath3/..\npath4/../", code: "200")) expect(@http_client).not_to receive(:get) .with("/2012-01-12/meta-data/.", @get_token_header) expect(@http_client).not_to receive(:get) @@ -289,22 +289,22 @@ describe Ohai::System, "plugin ec2" do expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/path1/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/path2/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/path3/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/path4/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/user-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "By the pricking of my thumb...", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/dynamic/instance-identity/document/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) plugin.run @@ -314,19 +314,19 @@ describe Ohai::System, "plugin ec2" do it "completes the run despite unavailable metadata" do expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "metrics/", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "metrics/", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/metrics/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "vhostmd", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "vhostmd", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/meta-data/metrics/vhostmd", @get_token_header) - .and_return(double("Net::HTTP Response", body: "", code: "404")) + .and_return(double("Net::HTTP::GET Response", body: "", code: "404")) expect(@http_client).to receive(:get) .with("/2012-01-12/user-data/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "By the pricking of my thumb...", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200")) expect(@http_client).to receive(:get) .with("/2012-01-12/dynamic/instance-identity/document/", @get_token_header) - .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) + .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200")) plugin.run |