Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

added tests for get-item, get-childitem, set-item, new-item remove-item, clear-item, dynamic parameters
merged CoreClr and FullClr code
did not add tests for clientcert handling

Part of #4158

Should get line coverage from 50.39% to 72.2%

Lots of error handling code not hit

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we wait that the service stop?

Copy link
Member Author

Choose a reason for hiding this comment

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

Stop-Service should be waiting by default, it has a -nowait switch

Copy link
Collaborator

Choose a reason for hiding this comment

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

Closed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want have all tab complete tests in one file TabCompletion.Tests.ps1?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll move them

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the Should in finally block? Maybe add a comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

The tests are for new-item and corresponding remove-item. Should validates that the remove-item worked. The test title indicates this and I thought was obvious enough. In case some other Should validation fails before the remove-item I still want to cleanup. Do you think a comment is needed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for clarify.

Closed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we move the test to a file with all Help tests? Tum more what we want to move Help subsystem in separate module.

Copy link
Member Author

Choose a reason for hiding this comment

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

This test is a bit different from the HelpSystem.Tests.ps1 as it's testing the implementation of ICmdletProviderSupportsHelp in this provider (not testing the HelpSystem). But more than that, it's specific to Windows and requires elevation.

Copy link
Collaborator

@iSazonov iSazonov Sep 14, 2017

Choose a reason for hiding this comment

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

Thanks for clarify. I think we should mention ICmdletProviderSupportsHelp in a comment or Context description.

Copy link
Member

Choose a reason for hiding this comment

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

Microsoft.powershell is the Windows PowerShell endpoint. Ideally, PowerShell Core should work with the PowerShell Core endpoint as its template. It would require a call to Enable-PSRemoting within PowerShell Core to set up.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make the change

Copy link
Member Author

Choose a reason for hiding this comment

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

Had to change it back as using Install-PowerShellRemoting or Enable-PSRemoting was making things complicated even though my tests had no dependency on remoting actually working. Since I'm just relying on a well known existing plugin configuration, I think using microsoft.powershell seems reasonable.

Copy link
Member

Choose a reason for hiding this comment

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

Should this user be added to the Administrators group?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed, I don't do any actual remoting. I just need a valid local account to set configuration (runas)

Copy link
Member

Choose a reason for hiding this comment

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

Please use more descriptive variable names

Copy link
Member Author

Choose a reason for hiding this comment

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

will change

Copy link
Member

Choose a reason for hiding this comment

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

Would it be useful to also test that it resolves ambiguous parameters in a consistent manner? "-pr" and "-pl" collide at "-p".

Copy link
Member Author

Choose a reason for hiding this comment

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

There should already be tabcomplete tests to cover that. This is specifically testing WSMan Config Provider's returning dynamic parameters

Copy link
Member

Choose a reason for hiding this comment

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

Extra space

Copy link
Member Author

Choose a reason for hiding this comment

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

will fix

Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, where did these SDDL values come from?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add a comment, but the second one is the default SDDL, the first is a truncated version

Copy link
Member

Choose a reason for hiding this comment

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

I'm starting to see patterns here among the tests. I like the descriptive names of the It's, but I'm wondering if they can be combined as TestCases to include the path to the property as well as the property and value. A change isn't necessarily required, but I'm curious if you considered it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about it while writing the tests, but there's enough differences in the properties and validation I think it would be overly complicated to combine them

Copy link
Member

Choose a reason for hiding this comment

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

This is the Windows PowerShell plugin path. It matches the config you have been using throughout, but it will need to be updated

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll update it to the one for PSCore6

Copy link
Member

Choose a reason for hiding this comment

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

We should not use "foo" and "bar" since they violate PolyCheck. Please use other string values.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe policheck allows it for code, but not in strings given to users. In any case, if we need to fix this, we should have a separate PR for all the code.

Copy link
Member

Choose a reason for hiding this comment

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

Does Remove-Item on a non-existant path throw an error?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm testing Remove-Item and also trying to cleanup. I think it may be better since @iSazonov gave similar feedback and have some redundancy where I do the remove-item test within the try and still do cleanup.

@SteveL-MSFT
Copy link
Member Author

CI failure waiting on #4802 to be merged

Copy link
Member

Choose a reason for hiding this comment

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

Please set $Global:PSDefaultParameterValues to the originalDefaultParameterValues.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why would we want to mess with global scope?

Copy link
Collaborator

Choose a reason for hiding this comment

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

:-) I asked @JamesWTruher previously the same and he said that is good to exclude scoped isssues.

Copy link
Member

Choose a reason for hiding this comment

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

@JamesWTruher could you point to the PR where we had problems with scoping and PSDefaultParameterValues

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, had an issue with scoping where it affected the CIM cmdlet tests on non-Windows. Changed it to global and it fixed the issue. Would like to understand what is happening here as it's not intuitive.

Copy link
Member

Choose a reason for hiding this comment

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

Please use a more descriptive variable name.

Copy link
Member Author

Choose a reason for hiding this comment

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

will fix

Copy link
Member

Choose a reason for hiding this comment

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

Set $Global:PSDefaultParameterValues instead

Copy link
Member

Choose a reason for hiding this comment

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

This check seems unnecessary as $plugin.PSPath is already checked.

Copy link
Member Author

Choose a reason for hiding this comment

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

true, will remove

Copy link
Member

Choose a reason for hiding this comment

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

Please move the value calculated for Should Be to a variable. It will make it more readable.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

Copy link
Member

Choose a reason for hiding this comment

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

Should this be BeExactly

Copy link
Member Author

Choose a reason for hiding this comment

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

will change

Copy link
Member

Choose a reason for hiding this comment

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

This can be Remove-Item "WSMan:\localhost\Plugin\TestPlugin2\" -Force -ErrorAction SilentlyContinue and remove the Test-Path.

Copy link
Member Author

Choose a reason for hiding this comment

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

true, will change

Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

will change

Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

will change

Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

will change

Copy link
Member

Choose a reason for hiding this comment

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

Can you use Enable-PSRemoting instead? I'd like to steer everyone in that direction now that the cmdlet is supported. An alternative is to modify the script to use the cmdlet internally. That way everyone will use it without noticing.

Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't need remoting to actual work for the purpose of these tests, I think I'll simplify it by just getting the first endpoint and validating against that

@mirichmo
Copy link
Member

@SteveL-MSFT Looks like a few tests are failing

@SteveL-MSFT
Copy link
Member Author

@mirichmo I'm going to revert back to using microsoft.powershell plugin as my base plugin since that seems to be well defined and trying to make it work with enable-psremoting turned out to be more complicated than it's worth particularly since I'm not actually using remoting for these tests.

@SteveL-MSFT SteveL-MSFT force-pushed the wsman-config-tests branch 3 times, most recently from b1b9b93 to 25d9d99 Compare September 18, 2017 03:42
@SteveL-MSFT
Copy link
Member Author

@adityapatwardhan your feedback has been addressed

Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

LGTM with monor comments.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use as in line 50 > $null?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll change it to $null = for consistency

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please place a comment on new line.

Copy link
Member

Choose a reason for hiding this comment

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

I think the request here was to move the comment on line 115 to a new line, not insert a newline character after it.

This isn't a blocking issue for the PR. I'm just clarifying intent.

@TravisEz13
Copy link
Member

@adityapatwardhan Can you update your review

Copy link
Member

@adityapatwardhan adityapatwardhan left a comment

Choose a reason for hiding this comment

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

LGTM

@mirichmo
Copy link
Member

Thanks for all the updates @SteveL-MSFT. I'll merge the PR once the tests pass

fixed issues in WSMan Config Provider
added tests for get-item, get-childitem, set-item, new-item remove-item, clear-item, dynamic parameters
merged CoreClr and FullClr code
address PR feedback
revert to using microsoft.powershell plugin as base for test
keeps it simple rather than relying on additional scripts or cmdlets since these tests don't require remoting
address Aditya's feedback
address some cosmetic feedback
based on discussion with Jim, we should skip resx checks on non-Windows
@SteveL-MSFT
Copy link
Member Author

Travis-CI failures due to resx tests not finding resources that don't exist there (like cimcmdlets). After discussion with @JamesWTruher we decided that it is ok to skip those tests on non-Windows. Easier to just make that change in this PR than making another PR and pulling it in.

@mirichmo mirichmo merged commit 2342064 into PowerShell:master Sep 18, 2017
@SteveL-MSFT SteveL-MSFT deleted the wsman-config-tests branch September 18, 2017 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants