summaryrefslogtreecommitdiff
path: root/spec/unit/plugins
diff options
context:
space:
mode:
authorsawanoboly <sawanoboriyu@higanworks.com>2020-12-10 15:59:08 +0900
committersawanoboly <sawanoboriyu@higanworks.com>2020-12-10 15:59:26 +0900
commitdc6955ed7b9a04f58991857605513da2d17bbb44 (patch)
treece9aeaf6212a6f533610cf1f70e92e31daa40902 /spec/unit/plugins
parent079decf4bde71c046e59a9784f5b030db51c68dc (diff)
downloadohai-dc6955ed7b9a04f58991857605513da2d17bbb44.tar.gz
include info for returns of meta-data/iam/
Signed-off-by: sawanoboly <sawanoboriyu@higanworks.com>
Diffstat (limited to 'spec/unit/plugins')
-rw-r--r--spec/unit/plugins/ec2_spec.rb99
-rw-r--r--spec/unit/plugins/eucalyptus_spec.rb12
2 files changed, 55 insertions, 56 deletions
diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb
index dbb19715..75a9c529 100644
--- a/spec/unit/plugins/ec2_spec.rb
+++ b/spec/unit/plugins/ec2_spec.rb
@@ -51,7 +51,7 @@ describe Ohai::System, "plugin ec2" do
allow(@http_client).to receive(:put) { double("Net::HTTP::PUT Response", body: token, code: "200") }
expect(@http_client).to receive(:get)
.with("/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "2012-01-12", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "2012-01-12", code: "200"))
end
context "with common metadata paths" do
@@ -67,14 +67,14 @@ describe Ohai::System, "plugin ec2" do
paths.each do |name, body|
expect(@http_client).to receive(:get)
.with("/2012-01-12/#{name}", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: body, code: "200"))
+ .and_return(double("Net::HTTP Response", body: body, code: "200"))
end
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200"))
+ .and_return(double("Net::HTTP 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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
plugin.run
@@ -88,14 +88,14 @@ describe Ohai::System, "plugin ec2" do
paths.each do |name, body|
expect(@http_client).to receive(:get)
.with("/2012-01-12/#{name}", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: body, code: "200"))
+ .and_return(double("Net::HTTP Response", body: body, code: "200"))
end
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .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"))
+ .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"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/dynamic/instance-identity/document/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
plugin.run
@@ -110,14 +110,14 @@ describe Ohai::System, "plugin ec2" do
paths.each do |name, body|
expect(@http_client).to receive(:get)
.with("/2012-01-12/#{name}", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: body, code: "200"))
+ .and_return(double("Net::HTTP Response", body: body, code: "200"))
end
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .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"))
+ .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"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/dynamic/instance-identity/document/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
plugin.run
@@ -132,14 +132,14 @@ describe Ohai::System, "plugin ec2" do
paths.each do |name, body|
expect(@http_client).to receive(:get)
.with("/2012-01-12/#{name}", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: body, code: "200"))
+ .and_return(double("Net::HTTP Response", body: body, code: "200"))
end
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .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"))
+ .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"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/dynamic/instance-identity/document/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"region\":\"us-east-1\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"region\":\"us-east-1\"}", code: "200"))
plugin.run
@@ -154,14 +154,14 @@ describe Ohai::System, "plugin ec2" do
paths.each do |name, body|
expect(@http_client).to receive(:get)
.with("/2012-01-12/#{name}", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: body, code: "200"))
+ .and_return(double("Net::HTTP Response", body: body, code: "200"))
end
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .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"))
+ .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"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/dynamic/instance-identity/document/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"availabilityZone\":\"us-east-1d\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"availabilityZone\":\"us-east-1d\"}", code: "200"))
plugin.run
@@ -176,28 +176,28 @@ describe Ohai::System, "plugin ec2" do
it "parses ec2 network/ directory as a multi-level hash" do
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "network/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "network/", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/network/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "interfaces/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "interfaces/", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/network/interfaces/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "macs/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "macs/", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/network/interfaces/macs/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "12:34:56:78:9a:bc/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "12:34:56:78:9a:bc/", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/network/interfaces/macs/12:34:56:78:9a:bc/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "public_hostname", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "public_hostname", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/network/interfaces/macs/12:34:56:78:9a:bc/public_hostname", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "server17.opscode.com", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "server17.opscode.com", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200"))
+ .and_return(double("Net::HTTP 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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
plugin.run
@@ -213,22 +213,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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "iam/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "iam/", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/iam/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "security-credentials/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "security-credentials/", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/iam/security-credentials/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "MyRole", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "MyRole", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/iam/security-credentials/MyRole", @get_req_token_header)
- .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"))
+ .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"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200"))
+ .and_return(double("Net::HTTP 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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
plugin.run
@@ -246,28 +246,27 @@ describe Ohai::System, "plugin ec2" do
it "parses ec2 iam/ directory and collect info and role_name and NOT collect iam/security-credentials/" do
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "iam/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "iam/", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/iam/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "security-credentials/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "info\nsecurity-credentials/", code: "200"))
expect(@http_client).to receive(:get)
- .with("/2012-01-12/meta-data/iam/info")
+ .with("/2012-01-12/meta-data/iam/info", @get_req_token_header)
.and_return(double("Net::HTTP Response", body: "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2020-10-08T20:47:08Z\",\n \"InstanceProfileArn\" : \"arn:aws:iam::111111111111:instance-profile/my_profile\",\n \"InstanceProfileId\" : \"AAAAAAAAAAAAAAAAAAAAA\"\n}", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/iam/security-credentials/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "MyRole", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "MyRole", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/iam/security-credentials/MyRole", @get_req_token_header)
- .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"))
+ .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"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200"))
+ .and_return(double("Net::HTTP 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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
plugin.run
-
expect(plugin[:ec2]).not_to be_nil
expect(plugin[:ec2]["iam"]["info"]["InstanceProfileId"]).to eql "AAAAAAAAAAAAAAAAAAAAA"
expect(plugin[:ec2]["iam"]["security-credentials"]).to be_nil
@@ -278,7 +277,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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: ".\n./\n..\n../\npath1/.\npath2/./\npath3/..\npath4/../", code: "200"))
+ .and_return(double("Net::HTTP 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_req_token_header)
expect(@http_client).not_to receive(:get)
@@ -292,22 +291,22 @@ describe Ohai::System, "plugin ec2" do
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/path1/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/path2/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/path3/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/path4/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200"))
+ .and_return(double("Net::HTTP 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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
plugin.run
@@ -317,19 +316,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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "metrics/", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "metrics/", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/metrics/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "vhostmd", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "vhostmd", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/metrics/vhostmd", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "", code: "404"))
+ .and_return(double("Net::HTTP Response", body: "", code: "404"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200"))
+ .and_return(double("Net::HTTP 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_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "{\"accountId\":\"4815162342\"}", code: "200"))
plugin.run
diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb
index ad1d22ca..24ac95d8 100644
--- a/spec/unit/plugins/eucalyptus_spec.rb
+++ b/spec/unit/plugins/eucalyptus_spec.rb
@@ -40,22 +40,22 @@ describe Ohai::System, "plugin eucalyptus" do
expect(@http_client).to receive(:get)
.with("/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "2012-01-12", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "2012-01-12", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "instance_type\nami_id\nsecurity-groups", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "instance_type\nami_id\nsecurity-groups", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/instance_type", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "c1.medium", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "c1.medium", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/ami_id", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "ami-5d2dc934", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "ami-5d2dc934", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/meta-data/security-groups", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "group1\ngroup2", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "group1\ngroup2", code: "200"))
expect(@http_client).to receive(:get)
.with("/2012-01-12/user-data/", @get_req_token_header)
- .and_return(double("Net::HTTP::GET Response", body: "By the pricking of my thumb...", code: "200"))
+ .and_return(double("Net::HTTP Response", body: "By the pricking of my thumb...", code: "200"))
end
it "recursively fetches all the eucalyptus metadata" do