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

Allow service resource to accept Windows service name with spaces #1003

Merged

Conversation

martinheg
Copy link

Currently if you want to check a Windows resource using the service resource you must use the non-friendly short service name, even though using the friendlier service display name will work as long as it doesn't include any spaces.

For example, this currently works:

describe service('AeLookupSvc') do     
  it { should be_installed }
end

while this simple change also allows for this:

describe service('Application Experience') do # Where 'Application Experience' is the display name for the service 'AeLookupSvc'
  it { should be_installed }
end

making it easier to use this resource for Windows services (where the shortname and displayname can often be quite different).

@chris-rock
Copy link
Contributor

@martinheg this is a great addition. Could you change https://github.com/chef/inspec/blob/master/test/helper.rb#L162 to

"New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Service -Value (Get-Service -Name 'dhcp'| Select-Object -Property Name, DisplayName, Status) -PassThru | Add-Member -MemberType NoteProperty -Name WMI -Value (Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq 'dhcp' -or $_.DisplayName -eq 'dhcp'} | Select-Object -Property StartMode) -PassThru | ConvertTo-Json" => cmd.call('get-service-dhcp'),

?
This would allow our tests to pass the unit tests

@martinheg
Copy link
Author

@chris-rock Thanks. Tests passing now - sorry for missing that first time round.

@chris-rock chris-rock merged commit 58a1ca5 into inspec:master Aug 31, 2016
@chris-rock
Copy link
Contributor

Thanks @martinheg !

@chris-rock chris-rock modified the milestone: 0.33.0 Sep 2, 2016
@chris-rock chris-rock added the Type: Enhancement Improves an existing feature label Sep 2, 2016
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