Skip to content

Commit

Permalink
Add OrchestrationParameterMultiline constraints to options that requi…
Browse files Browse the repository at this point in the history
…re a textarea
  • Loading branch information
bzwei committed Oct 3, 2017
1 parent 8a92d66 commit 5a8bd30
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ def notifications_opt
OrchestrationTemplate::OrchestrationParameter.new(
:name => "stack_notifications",
:label => "Notification ARNs",
:data_type => "text",
:description => "Notification SNS topic ARNs, one ARN per line"
:data_type => "string",
:description => "Notification SNS topic ARNs, one ARN per line",
:constraints => [OrchestrationTemplate::OrchestrationParameterMultiline.new]
)
end

Expand All @@ -139,8 +140,9 @@ def resource_types_opt
OrchestrationTemplate::OrchestrationParameter.new(
:name => "stack_resource_types",
:label => "Permitted resource types",
:data_type => "text",
:description => "Grand permissions to selected types, one type per line"
:data_type => "string",
:description => "Grand permissions to selected types, one type per line",
:constraints => [OrchestrationTemplate::OrchestrationParameterMultiline.new]
)
end

Expand All @@ -157,17 +159,19 @@ def tags_opt
OrchestrationTemplate::OrchestrationParameter.new(
:name => "stack_tags",
:label => "AWS Tags",
:data_type => "text",
:description => "Key-value pairs with format key1=>val1, one pair per line"
:data_type => "string",
:description => "Key-value pairs with format key1=>val1, one pair per line",
:constraints => [OrchestrationTemplate::OrchestrationParameterMultiline.new]
)
end

def policy_opt
OrchestrationTemplate::OrchestrationParameter.new(
:name => "stack_policy",
:label => "Policy",
:data_type => "text",
:description => "URL of an policy file or the actual content of the policy"
:data_type => "string",
:description => "URL of an policy file or the actual content of the policy",
:constraints => [OrchestrationTemplate::OrchestrationParameterMultiline.new]
)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
describe "OrchestrationTemplateServiceDialog for Amazon" do
let(:dialog_service) { Dialog::OrchestrationTemplateServiceDialog.new }
let(:template_amazon) { FactoryGirl.create(:orchestration_template_amazon_in_json) }

describe "#create_dialog" do
it "creates a dialog from CloudFormation template with stack basic info and parameters" do
dialog = dialog_service.create_dialog("test", template_amazon)

tabs = dialog.dialog_tabs
assert_stack_group(tabs[0].dialog_groups[0])
end
end

def assert_stack_group(group)
expect(group).to have_attributes(
:label => "Options",
:display => "edit",
)

fields = group.dialog_fields
expect(fields.size).to eq(10)

expect(fields[0].resource_action.fqname).to eq('/Cloud/Orchestration/Operations/Methods/Available_Tenants')
assert_field(fields[0], DialogFieldDropDownList, :name => 'tenant_name', :dynamic => true)
assert_field(fields[1], DialogFieldTextBox, :name => 'stack_name', :validator_rule => '^[A-Za-z][A-Za-z0-9\-]*$')
assert_field(fields[2], DialogFieldDropDownList, :name => 'stack_onfailure', :values => [%w(DELETE Delete\ stack), %w(DO_NOTHING Do\ nothing), %w(ROLLBACK Rollback)])
assert_field(fields[3], DialogFieldTextBox, :name => 'stack_timeout', :data_type => 'integer')
assert_field(fields[4], DialogFieldTextAreaBox, :name => 'stack_notifications', :data_type => 'string')
assert_field(fields[5], DialogFieldDropDownList, :name => 'stack_capabilities', :values => [[nil, '<None>'], ['CAPABILITY_IAM'] * 2, ['CAPABILITY_NAMED_IAM'] * 2])
assert_field(fields[6], DialogFieldTextBox, :name => 'stack_resource_types', :data_type => 'string')
assert_field(fields[7], DialogFieldTextBox, :name => 'stack_role', :data_type => 'string')
assert_field(fields[8], DialogFieldTextBox, :name => 'stack_tags', :data_type => 'string')
assert_field(fields[9], DialogFieldTextBox, :name => 'stack_policy', :data_type => 'string')
end

def assert_field(field, clss, attributes)
expect(field).to be_kind_of clss
expect(field).to have_attributes(attributes)
end
end

0 comments on commit 5a8bd30

Please sign in to comment.