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

improve wmi resource #800

Merged
merged 1 commit into from
Jun 19, 2016
Merged

improve wmi resource #800

merged 1 commit into from
Jun 19, 2016

Conversation

chris-rock
Copy link
Contributor

This improves the wmi resource:

# new syntax
describe wmi({
  class: 'RSOP_SecuritySettingNumeric',
  namespace: 'root\\rsop\\computer',
  filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1'
}) do
   its('Setting') { should eq 1 }
end

# deprecated syntax
describe wmi('RSOP_SecuritySettingNumeric', {
  namespace: 'root\\rsop\\computer',
  filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1'
}) do
   its('Setting') { should eq 1 }
   its('setting') { should eq 1 }
end

In addition this resource supports query now:

describe wmi({
  namespace: 'root\rsop\computer',
  query: "SELECT Setting FROM RSOP_SecuritySettingBoolean WHERE KeyName='LSAAnonymousNameLookup' AND Precedence=1"
}) do
  its('Setting') { should eq false }
end

@wmiclass = wmiclass
@wminamespace = opts[:namespace]
@wmifilter = opts[:filter]
@options = opts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be shortened?
Maybe

@options = opts || {}
if wmiclass.is_a?(Hash)
  @options.merge!(wmiclass)
else
  @options[:class] = wmiclass
end

Should we add a deprecation warning for the old wmiclass mode?

Copy link
Contributor Author

@chris-rock chris-rock Jun 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the shortened version

@arlimus
Copy link
Contributor

arlimus commented Jun 19, 2016

Awesome, kudos @chris-rock 👍

@arlimus arlimus merged commit 6942e92 into master Jun 19, 2016
@arlimus arlimus deleted the chris-rock/wmi branch June 19, 2016 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improves an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants