mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
Test cases fixed and new test cases added
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
parent
39081c51ba
commit
9e1ef742f8
5 changed files with 56 additions and 11 deletions
|
@ -43,7 +43,7 @@ module Inspec::DSL
|
|||
include DeprecatedCloudResourcesList
|
||||
cloud_resource = id.start_with?("aws_") ? "aws" : "azure"
|
||||
|
||||
# this check raises deprecation warning for aws and azure resources that were part of InSpec before version 5.
|
||||
# Deprecated AWS and Azure resources in InSpec 5.
|
||||
if CLOUD_RESOURCES_DEPRECATED.include? id
|
||||
Inspec.deprecate(:"#{cloud_resource}_resources_in_resource_pack", "Resource '#{id}'")
|
||||
else
|
||||
|
|
24
test/fixtures/profiles/azure-profile/controls/azure.rb
vendored
Normal file
24
test/fixtures/profiles/azure-profile/controls/azure.rb
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
control 'azure_resource_group_example' do
|
||||
title 'Check if the Example Resource Group matches expectations'
|
||||
impact 1.0
|
||||
|
||||
describe azure_resource_group(name: 'Inspec-Azure') do
|
||||
# Check if the Resource Group is located in the correct region
|
||||
its('location') { should cmp 'westeurope' }
|
||||
|
||||
# Check if the Resource Group has tags
|
||||
it { should have_tags }
|
||||
|
||||
# Check if the number of VMs in the Resource Group is correct
|
||||
its('vm_count') { should eq 3 }
|
||||
|
||||
# Check if the number of public IPs is correct
|
||||
its('public_ip_count') { should eq 1 }
|
||||
|
||||
# Check if the number of Network Security Groups is correct
|
||||
its('nsg_count') { should eq 1 }
|
||||
|
||||
# Check if the number of Storage Accounts is correct
|
||||
its('sa_count') { should eq 1 }
|
||||
end
|
||||
end
|
9
test/fixtures/profiles/azure-profile/inspec.yml
vendored
Normal file
9
test/fixtures/profiles/azure-profile/inspec.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
name: azure
|
||||
title: azure example profile
|
||||
maintainer: Chef Software, Inc.
|
||||
copyright: Chef Software, Inc.
|
||||
copyright_email: support@chef.io
|
||||
license: Apache-2.0
|
||||
summary: Testing stub
|
||||
version: 1.0.0
|
||||
license: Apache-2.0
|
|
@ -42,8 +42,7 @@ describe "inspec check" do
|
|||
describe "inspec check with a aws profile" do
|
||||
it "ignore train connection error" do
|
||||
out = inspec("check " + File.join(examples_path, "profile-aws"))
|
||||
|
||||
assert_exit_code 0, out
|
||||
assert_exit_code 3, out
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -51,7 +50,7 @@ describe "inspec check" do
|
|||
it "ignore train connection error" do
|
||||
out = inspec("check " + File.join(examples_path, "profile-azure"))
|
||||
|
||||
assert_exit_code 0, out
|
||||
assert_exit_code 3, out
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -479,15 +479,28 @@ Test Summary: 0 successful, 0 failures, 0 skipped
|
|||
end
|
||||
|
||||
describe "with a profile that contains skipped resources" do
|
||||
let(:out) { inspec("exec " + File.join(profile_path, "aws-profile")) }
|
||||
let(:out) { inspec("exec " + File.join(examples_path, "profile-aws")) }
|
||||
it "exits with an error" do
|
||||
skip if ENV["NO_AWS"]
|
||||
_(stdout).must_include "Unsupported resource/backend combination: aws_iam_users"
|
||||
_(stdout).must_include "Unsupported resource/backend combination: aws_iam_access_keys"
|
||||
_(stdout).must_include "Unsupported resource/backend combination: aws_s3_bucket"
|
||||
_(stdout).must_include "3 failures"
|
||||
_(stdout).must_include "Skipping profile: 'profile-aws' on unsupported platform"
|
||||
assert_exit_code 101, out
|
||||
end
|
||||
end
|
||||
|
||||
assert_exit_code 100, out
|
||||
# Deprecation tests are called without aws:// and azure:// due to lack of creds
|
||||
# aws-profile and azure-profiles does not have platforms as aws and azure for testing this scenario
|
||||
describe "with a profile that contains deprecated aws resources" do
|
||||
let(:out) { inspec("exec " + File.join(profile_path, "aws-profile")) }
|
||||
it "exits with deprecation error" do
|
||||
_(stdout).must_include "DEPRECATION: AWS resources shipped with core InSpec are deprecated"
|
||||
assert_exit_code 3, out
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a profile that contains deprecated azure resources" do
|
||||
let(:out) { inspec("exec " + File.join(profile_path, "azure-profile")) }
|
||||
it "exits with deprecation error" do
|
||||
_(stdout).must_include "DEPRECATION: Azure resources shipped with core InSpec are deprecated"
|
||||
assert_exit_code 3, out
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue