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

SqlServerLogin: Fix password test fails for nativ sql users #1049

Merged
merged 4 commits into from
Feb 21, 2018

Conversation

claudiospizzi
Copy link
Contributor

@claudiospizzi claudiospizzi commented Feb 19, 2018

Pull Request (PR) description
Bug in the Connect-SQL helper function, the resource is not able to test a nativ SQL user password. It tries to test the native SQL user password like a Windows login, which always fails.

This Pull Request (PR) fixes the following issues:
Fixes #1048

Task list:

  • Change details added to Unreleased section of CHANGELOG.md?
  • Added/updated documentation, comment-based help and descriptions in .schema.mof files where appropriate?
  • Examples appropriately updated?
  • New/changed code adheres to Style Guidelines?
  • Unit and (optional) Integration tests created/updated where possible?

This change is Reviewable

@codecov-io
Copy link

codecov-io commented Feb 19, 2018

Codecov Report

Merging #1049 into dev will increase coverage by <1%.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##            dev   #1049    +/-   ##
=====================================
+ Coverage    97%     97%   +<1%     
=====================================
  Files        32      32            
  Lines      3925    3930     +5     
=====================================
+ Hits       3839    3844     +5     
  Misses       86      86

@johlju johlju added the needs review The pull request needs a code review. label Feb 20, 2018
@johlju
Copy link
Member

johlju commented Feb 20, 2018

@claudiospizzi Thanks for sending in a PR for this! I see Codecov reporting misses in code coverage. Is that false negatives? If you run Invoke-Pester -Path <TestPath> -CodeCoverage <CodePath> locally does it hit those rows?

@johlju
Copy link
Member

johlju commented Feb 20, 2018

Reviewed 3 of 4 files at r1.
Review status: 3 of 4 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


a discussion (no related file):
I see Codecov reporting misses in code coverage. Is that false negatives? If you run Invoke-Pester -Path -CodeCoverage locally does it hit those rows?


SqlServerDscHelper.psm1, line 70 at r1 (raw file):

            $sql.ConnectionContext.SecurePassword = $SetupCredential.Password
        }
        if ($LoginType -eq 'WindowsUser')

Please add a blank row before this one.


SqlServerDscHelper.psm1, line 76 at r1 (raw file):

            $sql.ConnectionContext.ConnectAsUserName = $SetupCredential.GetNetworkCredential().UserName
        }
        $sql.ConnectionContext.ServerInstance = $databaseEngineInstance

Please add a blank row before this one.


DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1, line 425 at r1 (raw file):

                    else
                    {
                        Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName -SetupCredential $userCredential | Out-Null

I don't think this is needed? It can never be hit since line 398 only allows SqlLogin in this code path, and we can't change password for Windows accounts?


Comments from Reviewable

@johlju johlju added waiting for author response The pull request is waiting for the author to respond to comments in the pull request. and removed needs review The pull request needs a code review. labels Feb 20, 2018
@johlju
Copy link
Member

johlju commented Feb 20, 2018

This should be tested in the integration tests, since I'm not currently enforcing changing the integration tests, I added an issue #1050 to track this.

@claudiospizzi If you are up to adding this test you are more than welcome to do so, but I will merge this PR without it if you feel that you don't have time, or if it is to new for you.

@claudiospizzi
Copy link
Contributor Author

@johlju
I've updated the PR based on your feedback. The code coverage was not a false-positive, the test was not written properly. The credentials were not passed to the Connect-SQL function. I would be happy if you can merge the PR without integration test for the moment.

@johlju
Copy link
Member

johlju commented Feb 21, 2018

:lgtm:


Reviewed 3 of 3 files at r2.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@johlju johlju merged commit 024ce32 into dsccommunity:dev Feb 21, 2018
@claudiospizzi claudiospizzi deleted the FixSqlLoginPwdCheckBug branch February 21, 2018 17:10
@johlju johlju removed the waiting for author response The pull request is waiting for the author to respond to comments in the pull request. label Mar 17, 2018
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.

SqlServerLogin: Password test fails for nativ sql users
3 participants