Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchConnect::App test for malformed YAML incorrect #3748

Open
Oglopf opened this issue Aug 22, 2024 · 0 comments
Open

BatchConnect::App test for malformed YAML incorrect #3748

Oglopf opened this issue Aug 22, 2024 · 0 comments
Milestone

Comments

@Oglopf
Copy link
Contributor

Oglopf commented Aug 22, 2024

While working on #221 I noticed a test written that purports to check for malformed YAML already:

test "app with malformed form.yml" do
Dir.mktmpdir { |dir|
r = PathRouter.new(dir)
r.path.join("form.yml").write("--x-\nnot a valid form yaml")
app = BatchConnect::App.new(router: r)
assert ! app.valid?
}
end

However, this is really only checking if the app is valid?. As implemented now, the BatchConnect::App#valid? method does not check for malformed YAML, it only ensures that the form key is an Array and attributes is a Hash:

# Whether this is a valid app the user can use
# @return [Boolean] whether valid app
def valid?
if form_config.empty?
false
elsif !form_config.fetch(:form, []).is_a?(Array)
@validation_reason = I18n.t('dashboard.batch_connect_invalid_form_array')
false
elsif !form_config.fetch(:attributes, {}).is_a?(Hash)
@validation_reason = I18n.t('dashboard.batch_connect_invalid_form_attributes')
false
elsif configured_clusters.any?
clusters.any?
else
true
end
end

Fix

Rename this test to check if an batch connect app is valid?.

Make test in #221 ensure the YAML and ERB errors are raised correctly instead of silent fails.

@osc-bot osc-bot added this to the Backlog milestone Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants