Bulk edit of test files to use input() in DSL

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2019-06-10 17:41:23 -04:00
parent 44a8480a49
commit 46624396c7
47 changed files with 79 additions and 79 deletions

View file

@ -1,5 +1,5 @@
val_user = attribute('user', value: 'alice', description: 'An identification for the user')
val_password = attribute('password', description: 'A value for the password')
val_user = input('user', value: 'alice', description: 'An identification for the user')
val_password = input('password', description: 'A value for the password')
describe val_user do
it { should eq 'bob' }

View file

@ -10,7 +10,7 @@ fixtures = {}
'cloudtrail_trail_2_arn',
'cloudtrail_trail_2_s3_bucket_name'
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/cloudtrail.tf',

View file

@ -4,7 +4,7 @@ fixtures = {}
'cloudwatch_alarm_1_metric_name',
'cloudwatch_alarm_1_namespace',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/cloudwatch.tf',
@ -26,4 +26,4 @@ control 'aws_cloudwatch_alarm recall' do
) do
it { should_not exist }
end
end
end

View file

@ -7,7 +7,7 @@ fixtures = {}
'log_metric_filter_2_log_group_name',
'log_metric_filter_2_pattern',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/cloudwatch.tf',
@ -71,4 +71,4 @@ control "aws_cloudwatch_log_metric_filter filter_name property" do
) do
its('filter_name') { should cmp fixtures['log_metric_filter_2_name'] }
end
end
end

View file

@ -6,7 +6,7 @@ fixtures = {}
'delivery_channel_01_bucket_prefix',
'sns_topic_for_delivery_channel_arn'
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',

View file

@ -3,7 +3,7 @@ fixtures = {}
'role_for_config_recorder_arn',
'config_recorder_name',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/config.tf',
@ -59,4 +59,4 @@ control "aws_config_recorder matchers" do
it { should be_recording_all_resource_types }
it { should_not be_recording_all_global_types }
end
end
end

View file

@ -12,7 +12,7 @@ fixtures = {}
'ec2_instance_debian_id',
'ec2_ami_id_debian',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',
@ -74,4 +74,4 @@ control "aws_ec2_instance - image_id property" do
describe aws_ec2_instance(fixtures['ec2_instance_debian_id']) do
its('image_id') { should eq fixtures['ec2_ami_id_debian'] }
end
end
end

View file

@ -4,7 +4,7 @@ fixtures = {}
'ec2_instance_centos_id',
'ec2_instance_debian_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -5,7 +5,7 @@ fixtures = {}
'eks_cluster_security_group_id',
'eks_vpc_subnets',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/eks.tf',

View file

@ -13,7 +13,7 @@ fixtures = {}
'elb_security_group_to_lb_id',
'elb_vpc_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -13,7 +13,7 @@ fixtures = {}
'elb_security_group_to_lb_id',
'elb_vpc_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -1,7 +1,7 @@
fixtures = {}
%w[flow_log_alpha_vpc_log_id flow_log_alpha_subnet_log_id
flow_log_alpha_subnet_id flow_log_vpc_id].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/flow_log.tf',

View file

@ -6,7 +6,7 @@ fixtures = {}
'iam_access_key_recall_hit',
'iam_access_key_recall_miss',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',

View file

@ -4,7 +4,7 @@ fixtures = {}
'iam_user_without_access_key',
'iam_access_key_recall_hit',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',
@ -55,4 +55,4 @@ control 'IAM Access Keys - fetch-time filtering' do
describe aws_iam_access_keys(username: fixtures['iam_user_without_access_key']) do
it { should_not exist }
end
end
end

View file

@ -3,7 +3,7 @@ fixtures = {}
'iam_group_administrators',
'iam_user_recall_hit'
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',
@ -24,4 +24,4 @@ control "aws_iam_group properties test" do
describe aws_iam_group(fixtures['iam_group_administrators']) do
its('users') { should include fixtures['iam_user_recall_hit'] }
end
end
end

View file

@ -2,7 +2,7 @@ fixtures = {}
[
'iam_group_administrators',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',
@ -28,4 +28,4 @@ control "aws_iam_groups properties test" do
describe aws_iam_groups do
its('group_names') { should include fixtures['iam_group_administrators'] }
end
end
end

View file

@ -3,7 +3,7 @@ fixtures = {}
'aws_iam_policy_alpha_name',
'aws_iam_policy_beta_name',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',
@ -107,4 +107,4 @@ control "aws_iam_policy matchers" do
describe aws_iam_policy('PowerUserAccess') do
it { should_not have_statement 'Action' => 'iam:*' }
end
end
end

View file

@ -2,7 +2,7 @@ fixtures = {}
[
'aws_account_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',

View file

@ -20,7 +20,7 @@ fixtures = {}
'iam_policy_user_attached_0i_2a_2_arn',
'iam_policy_user_attached_0i_2a_2_name',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',
@ -108,4 +108,4 @@ control "aws_iam_user properties" do
end
end
end
end
end

View file

@ -14,7 +14,7 @@ fixtures = {}
'iam_policy_user_attached_0i_2a_2_arn',
'iam_policy_user_attached_0i_2a_2_name',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',
@ -52,4 +52,4 @@ control "aws_iam_users filtering" do
its('attached_policy_arns.count') { should eq 3 }
its('attached_policy_arns') { should include fixtures['iam_policy_user_attached_1i_1a_1_arn'] }
end
end
end

View file

@ -5,7 +5,7 @@ fixtures = {}
'kms_key_disabled_key_id',
'kms_key_enabled_key_description'
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/kms.tf',
@ -48,4 +48,4 @@ control "aws_kms_key matchers" do
describe aws_kms_key(fixtures['kms_key_disabled_key_id']) do
it { should_not have_rotation_enabled }
end
end
end

View file

@ -2,7 +2,7 @@ fixtures = {}
[
'rds_db_instance_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/rds.tf',

View file

@ -3,7 +3,7 @@ fixtures = {}
'route_table_1_id',
'route_table_1_vpc_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/route_table.tf',

View file

@ -4,7 +4,7 @@ fixtures = {}
'route_table_2_id',
'route_table_1_vpc_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',
@ -25,4 +25,4 @@ control "aws_route_tables properties" do
its('vpc_ids') { should include fixtures['route_table_1_vpc_id'] }
its('route_table_ids') { should include fixtures['route_table_1_id'], fixtures['route_table_2_id'] }
end
end
end

View file

@ -10,7 +10,7 @@ fixtures = {}
's3_bucket_access_logging_enabled_name',
's3_bucket_access_logging_not_enabled_name',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/s3.tf',

View file

@ -3,7 +3,7 @@ fixtures = {}
's3_bucket_public_name',
's3_bucket_private_name',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/s3.tf',

View file

@ -7,7 +7,7 @@ fixtures = {}
'ec2_security_group_gamma_group_id',
'ec2_security_group_alpha_group_name',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -3,7 +3,7 @@ fixtures = {}
'ec2_security_group_default_vpc_id',
'ec2_security_group_default_group_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -5,7 +5,7 @@ fixtures = {}
'sqs_for_sub_03_arn',
'aws_account_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/sns.tf',

View file

@ -4,7 +4,7 @@ fixtures = {}
'sns_topic_with_subscription_arn',
'sns_topic_no_subscription_arn',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/sns.tf',
@ -36,4 +36,4 @@ control "aws_sns_topic confirmed_subscription_count property" do
describe aws_sns_topic(fixtures['sns_topic_no_subscription_arn']) do
its('confirmed_subscription_count') { should be_zero }
end
end
end

View file

@ -2,7 +2,7 @@ fixtures = {}
[
'sns_topic_recall_hit_arn',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/sns.tf',

View file

@ -3,7 +3,7 @@ fixtures = {}
'sqs_queue_1_url',
'sqs_queue_2_url',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/sqs.tf',
@ -44,4 +44,4 @@ control "aws_sqs_queue fifo properties" do
its('is_fifo_queue') { should be true }
its('content_based_deduplication') { should be true }
end
end
end

View file

@ -4,7 +4,7 @@ fixtures = {}
'subnet_01_id',
'subnet_01_az',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -3,7 +3,7 @@ fixtures = {}
'subnet_01_id',
'subnet_vpc_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -8,7 +8,7 @@ fixtures = {}
'vpc_non_default_instance_tenancy',
'vpc_non_default_dhcp_options_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -8,7 +8,7 @@ fixtures = {}
'vpc_non_default_instance_tenancy',
'vpc_non_default_dhcp_options_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/ec2.tf',

View file

@ -2,7 +2,7 @@ fixtures = {}
[
'aws_account_id',
].each do |fixture_name|
fixtures[fixture_name] = attribute(
fixtures[fixture_name] = input(
fixture_name,
default: "default.#{fixture_name}",
description: 'See ../build/iam.tf',
@ -39,4 +39,4 @@ control "aws_iam_root_user has_access_key property" do
describe aws_iam_root_user do
it { should have_access_key }
end
end
end

View file

@ -10,7 +10,7 @@ tests = expecteds.keys.map do |test_name|
{
name: test_name,
expected: expecteds[test_name],
input_via_string: attribute(test_name.to_s, value: "#{test_name}_default"),
input_via_string: input(test_name.to_s, value: "#{test_name}_default"),
}
end
@ -21,4 +21,4 @@ control 'flat' do
it { should eq details[:expected] }
end
end
end
end

View file

@ -9,9 +9,9 @@ input_names = [
inputs = {}
input_names.each do |input_name|
# Store as a symbol-fetched input
inputs[input_name] = attribute(input_name, value: "#{input_name}_sym_default")
inputs[input_name] = input(input_name, value: "#{input_name}_sym_default")
# .. and store under a string name, as a string-fetched input!
inputs[input_name.to_s] = attribute(input_name.to_s, value: "#{input_name}_str_default")
inputs[input_name.to_s] = input(input_name.to_s, value: "#{input_name}_str_default")
end
# For now, these all use string keys, as that is normal InSpec behavior
@ -74,4 +74,4 @@ control 'nested' do
# its([1, 'key22']) { should eq 'value22' }
its('count') { should eq 2 }
end
end
end

View file

@ -1,13 +1,13 @@
control 'child-01-control-01' do
describe attribute('test-01') do
describe input('test-01') do
# This is an independent value, inheritance-child-01/test-01
it { should cmp 'value-from-child-01-metadata' }
end
end
control 'child-01-control-02' do
describe attribute('test-02') do
describe input('test-02') do
# This value was set by the wrapper, inheritance-child-01/test-02
it { should cmp 'value-from-wrapper-metadata' }
end
end
end

View file

@ -1,6 +1,6 @@
control 'child-02-control-01' do
describe attribute('test-03') do
describe input('test-03') do
# This value was set by the wrapper via an alias, inheritance-child-02/test-02
it { should cmp 'value-from-wrapper-metadata' }
end
end
end

View file

@ -5,9 +5,9 @@ include_controls('inheritance-child-01')
include_controls('inheritance-child-02-aliased')
control 'wrapper-control-01' do
describe attribute('test-01') do
describe input('test-01') do
# This is an independent value, inheritance-wrapper/test-01
it { should cmp 'value-from-wrapper-metadata' }
end
input_object('test-01')
end
end

View file

@ -1 +1 @@
attribute('a_required_input')
input('a_required_input')

View file

@ -1,17 +1,17 @@
control 'only_in_plugin' do
describe attribute('test_only_in_plugin') do
describe input('test_only_in_plugin') do
it { should cmp 'only_in_plugin' }
end
end
control 'collide_plugin_higher' do
describe attribute('test_collide_plugin_higher', value: 'wrong', priority: 10) do
describe input('test_collide_plugin_higher', value: 'wrong', priority: 10) do
it { should cmp 'collide_plugin_higher' }
end
end
control 'collide_inline_higher' do
describe attribute('test_collide_inline_higher', value: 'collide_inline_higher', priority: 70) do
describe input('test_collide_inline_higher', value: 'collide_inline_higher', priority: 70) do
it { should cmp 'collide_inline_higher' }
end
end
@ -19,7 +19,7 @@ end
control 'event_log' do
# This attribute is set here here in the DSL and in the plugin
# An attribute with this history should have 3 events - a create, a DSL set, and a plugin fetch.
attribute('test_event_log', value: 'setting_in_dsl')
input('test_event_log', value: 'setting_in_dsl')
# Fetch the attribute object from the registry
input_obj = Inspec::InputRegistry.find_or_register_input('test_event_log', 'input-test-fixture')
@ -61,4 +61,4 @@ control 'list_inputs' do
it { should_not include 'nonesuch' }
end
end
end

View file

@ -5,24 +5,24 @@ control 'start_marker' do
end
control 'undeclared_in_control_body' do
attribute('undeclared_01')
assignment_outcome = attribute('undeclared_02')
input('undeclared_01')
assignment_outcome = input('undeclared_02')
describe('dummy_test_02') do
it { should cmp 'dummy_test_02'}
end
end
control 'undeclared_in_only_if' do
only_if { attribute('undeclared_03') }
only_if { input('undeclared_03') }
describe('dummy_test_03') do
it { should cmp 'dummy_test_03'}
end
end
attribute('undeclared_04')
input('undeclared_04')
control 'end_marker' do
describe('dummy_test_04') do
it { should cmp 'dummy_test_04'}
end
end
end

View file

@ -1,5 +1,5 @@
val_user = attribute('user', value: 'alice', description: 'An identification for the user')
val_password = attribute('password', description: 'A value for the password')
val_user = input('user', value: 'alice', description: 'An identification for the user')
val_password = input('password', description: 'A value for the password')
describe val_user do
it { should eq 'bob' }

View file

@ -1,4 +1,4 @@
cis_level = attribute('cis_level')
cis_level = input('cis_level')
control 'control1' do
title 'title'