-
Notifications
You must be signed in to change notification settings - Fork 103
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
Update Global Settings #87
Conversation
9b8fcca
to
8dcc26a
Compare
# Before updating the Nexpose gem
When(/^I (disable|enable) the global setting for Controls Scanning$/) do |action|
state_for_action =
case action
when 'disable' then '0'
when 'enable' then '1'
end
global_settings_response = Nexpose::AJAX.get(@nexpose_client, '/data/admin/global-settings')
global_settings = REXML::Document.new(global_settings_response)
controls_scan = REXML::XPath.first(global_settings, 'GlobalSettings/ControlsScan')
enable_controls_scan = REXML::XPath.first(controls_scan, 'enableControlsScan')
enable_controls_scan.add_attribute('enabled', state_for_action)
# This would fail for some reason.
Nexpose::AJAX.post(@nexpose_client, '/data/admin/global-settings', global_settings)
end # After (without #87)
When(/^I (disable|enable) the global setting for Controls Scanning$/) do |action|
global_settings = Nexpose::GlobalSettings.load(@nexpose_client)
case action
when 'disable'
global_settings._set_controls_scanning(global_settings.xml, false)
when 'enable'
global_settings._set_controls_scanning(global_settings.xml, true)
end
global_settings.save(@nexpose_client)
end # After (with #87)
When(/^I (disable|enable) the global setting for Controls Scanning$/) do |action|
global_settings = @nexpose_client.global_settings
case action
when 'disable'
global_settings.controls_scanning = false
when 'enable'
global_settings.controls_scanning = true
end
global_settings.save(@nexpose_client)
end cc: @nbibinagar-r7 |
# Internal method for updating exclusions before saving. | ||
def _replace_exclusions(xml, exclusions) | ||
def replace_exclusions(xml, exclusions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change all the names? There a fairly strong convention across the gem to use the underscore to indicate the private methods that are meant for internal utility.
Also, I've had some problems using private
methods in the gem. I cannot remember what the problems were, but it's one of the reasons for adding the naming conventions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen similar naming conventions in JS. I knew what was being done but since Ruby provides privacy levels I opt'd to remove the unneeded convention in this particular case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw this comment come through, so I'll pile on. :) In Ruby, you rarely see folks using the prepended underscore to indicate private methods, since you can enforce method hiding with the private
keyword. You are forbidden from calling private methods outside of the class in which they are declared, which could be the cause of the issues you're seeing.
bd87264
to
9b17cd5
Compare
9b17cd5
to
144c5ca
Compare
@mdaines-r7 I've removed |
@mdaines-r7 (@defndaines) Can you check this PR out? I'd like to get it merged for some automated tests I'm working on right now.