From d4b1982dfef0dd8a273ac896e3af9dc8af5cbfb4 Mon Sep 17 00:00:00 2001 From: Soumyodeep Karmakar Date: Mon, 30 Jan 2023 14:15:55 +0530 Subject: [PATCH 1/4] adding the azure_graph_generic_resources plural integration test Signed-off-by: Soumyodeep Karmakar --- .../verify/controls/azure_graph_generic_resources.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/integration/verify/controls/azure_graph_generic_resources.rb diff --git a/test/integration/verify/controls/azure_graph_generic_resources.rb b/test/integration/verify/controls/azure_graph_generic_resources.rb new file mode 100644 index 00000000..8475cc9f --- /dev/null +++ b/test/integration/verify/controls/azure_graph_generic_resources.rb @@ -0,0 +1,8 @@ +control "azure_graph_generic_resources" do + title "Testing the plural resource of azure_graph_generic_resources." + desc "Testing the plural resource of azure_graph_generic_resources." + + describe azure_graph_generic_resources(resource: "users", filter: { given_name: "John" }) do + it { should exist } + end +end From 78b04b4259993496361dcccb8f74f25babf6fdfe Mon Sep 17 00:00:00 2001 From: Soumyodeep Karmakar Date: Mon, 30 Jan 2023 14:16:27 +0530 Subject: [PATCH 2/4] adding the azure_lock plural integration test Signed-off-by: Soumyodeep Karmakar --- test/integration/verify/controls/azure_lock.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/integration/verify/controls/azure_lock.rb diff --git a/test/integration/verify/controls/azure_lock.rb b/test/integration/verify/controls/azure_lock.rb new file mode 100644 index 00000000..039b97fc --- /dev/null +++ b/test/integration/verify/controls/azure_lock.rb @@ -0,0 +1,15 @@ +resource_group = input("resource_group", value: nil) +resource_name = input("windows_vm_name", value: nil) + +control "azure_lock_test" do + title "Testing the singular resource of azure_lock." + desc "Testing the singular resource of azure_lock." + + vm_id = azure_virtual_machine(resource_group: resource_group, name: resource_name).id + + describe azure_locks(resource_id: vm_id).ids.each do |lock_id| + describe azure_lock(resource_id: lock_id) do + it("properties.notes") { should_not be_empty } + end + end +end From 7d1f136196daea1926b9b008c1cce6974ae4cafe Mon Sep 17 00:00:00 2001 From: Soumyodeep Karmakar Date: Mon, 30 Jan 2023 14:17:22 +0530 Subject: [PATCH 3/4] adding the azure_key_vault_rotation_key singular integration test Signed-off-by: Soumyodeep Karmakar --- .../verify/controls/azure_key_vault_rotation_key.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/integration/verify/controls/azure_key_vault_rotation_key.rb diff --git a/test/integration/verify/controls/azure_key_vault_rotation_key.rb b/test/integration/verify/controls/azure_key_vault_rotation_key.rb new file mode 100644 index 00000000..b8110784 --- /dev/null +++ b/test/integration/verify/controls/azure_key_vault_rotation_key.rb @@ -0,0 +1,11 @@ +vault_name = input("key_vault_name", value: nil) +key_name = input("key_vault_key_name", value: nil) + +control "azure_key_vault_rotation_key" do + title "Testing the singular resource of azure_key_vault_rotation_key." + desc "Testing the singular resource of azure_key_vault_rotation_key." + + describe azure_key_vault_key(vault_name, key_name) do + it { should have_rotation_policy_enabled } + end +end From 5a78f72c00368065861bf68b782a9cecb0aa3852 Mon Sep 17 00:00:00 2001 From: Soumyodeep Karmakar Date: Thu, 2 Feb 2023 17:42:50 +0530 Subject: [PATCH 4/4] removing the unwanted files Signed-off-by: Soumyodeep Karmakar --- libraries/azure_key_vault_rotation_key.rb | 37 ------------------- .../controls/azure_key_vault_rotation_key.rb | 11 ------ 2 files changed, 48 deletions(-) delete mode 100644 libraries/azure_key_vault_rotation_key.rb delete mode 100644 test/integration/verify/controls/azure_key_vault_rotation_key.rb diff --git a/libraries/azure_key_vault_rotation_key.rb b/libraries/azure_key_vault_rotation_key.rb deleted file mode 100644 index 58dc3cfe..00000000 --- a/libraries/azure_key_vault_rotation_key.rb +++ /dev/null @@ -1,37 +0,0 @@ -require "azure_generic_resource" - -class AzureKeyVaultRotationKey < AzureGenericResource - name "azure_key_vault_rotation_key" - desc "Verifies configuration for an Azure Rotation Key within a Vault." - example <<-EXAMPLE - describe azure_key_vault_rotation_key(vault_name: 'KEY_VAULT_NAME', key_name: 'KEY_NAME') do - it { should exist } - end - EXAMPLE - - def initialize(opts = {}) - # Options should be Hash type. Otherwise Ruby will raise an error when we try to access the keys. - raise ArgumentError, "Parameters must be provided in an Hash object." unless opts.is_a?(Hash) - - # This part is normally done in the backend; however, we need to get the `key_vault_dns_suffix` at the initiation. - opts[:endpoint] ||= ENV_HASH["endpoint"] || "azure_cloud" - unless AzureEnvironments::ENDPOINTS.key?(opts[:endpoint]) - raise ArgumentError, "Invalid endpoint: `#{opts[:endpoint]}`."\ - " Expected one of the following options: #{AzureEnvironments::ENDPOINTS.keys}." - end - endpoint = AzureEnvironments.get_endpoint(opts[:endpoint]) - key_vault_dns_suffix = endpoint.key_vault_dns_suffix - opts[:resource_provider] = specific_resource_constraint(key_vault_dns_suffix, opts) - - opts[:required_parameters] = %i(vault_name) - opts[:resource_identifiers] = %i(key_name) - opts[:resource_uri] = "https://#{opts[:vault_name]}#{key_vault_dns_suffix}/keys/#{opts[:key_name]}/rotationpolicy" - opts[:is_uri_a_url] = true - opts[:audience] = "https://#{key_vault_dns_suffix.delete_prefix(".")}" - super(opts, true) - end - - def to_s - super(AzureKeyVaultRotationKey) - end -end diff --git a/test/integration/verify/controls/azure_key_vault_rotation_key.rb b/test/integration/verify/controls/azure_key_vault_rotation_key.rb deleted file mode 100644 index b8110784..00000000 --- a/test/integration/verify/controls/azure_key_vault_rotation_key.rb +++ /dev/null @@ -1,11 +0,0 @@ -vault_name = input("key_vault_name", value: nil) -key_name = input("key_vault_key_name", value: nil) - -control "azure_key_vault_rotation_key" do - title "Testing the singular resource of azure_key_vault_rotation_key." - desc "Testing the singular resource of azure_key_vault_rotation_key." - - describe azure_key_vault_key(vault_name, key_name) do - it { should have_rotation_policy_enabled } - end -end