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

SqlServerRole: Add support for nested roles and remove case-sensitive checks #1453

Merged
merged 19 commits into from
Jan 12, 2020
Merged

SqlServerRole: Add support for nested roles and remove case-sensitive checks #1453

merged 19 commits into from
Jan 12, 2020

Conversation

nabrond
Copy link
Contributor

@nabrond nabrond commented Dec 30, 2019

Pull Request (PR) description

Adds support to the resource for nesting server role membership. Fixes an issue where role membership tests were performed in a case-sensitive manner. Updated the unit test template to v1.2.4 and refactored mocks and test structure to decrease the runtime and resolve some false test results.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry under the Unreleased section of the change log in the CHANGELOG.md.
    Entry should say what was changed, and how that affects users (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof
    and comment-based help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Resource Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Resource Testing Guidelines.
  • New/changed code adheres to DSC Resource Style Guidelines and Best Practices.

This change is Reviewable

@johlju johlju added the needs review The pull request needs a code review. label Dec 31, 2019
@johlju
Copy link
Member

johlju commented Dec 31, 2019

Working on getting the new CI pipeline working, so the tests won't pass yet. I will review this and test manually. But would like to merge this once I got the new CI pipeline in.

Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nabrond)


DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1, line 501 at r1 (raw file):

.Contains

Maybe we should not use case sensitive here either?


DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1, line 562 at r1 (raw file):

.Contains

Maybe we should not use case sensitive here either?

@johlju johlju added waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. and removed needs review The pull request needs a code review. labels Dec 31, 2019
@johlju johlju changed the base branch from dev to master January 1, 2020 20:59
@johlju
Copy link
Member

johlju commented Jan 1, 2020

The new CI pipeline has merged. This changed the folder structure, and also removed the dev branch. Please rebase against the master branch, and make sure to get your changes into the the file in the new location (under source folder). 😃

Read more here about the new coding workflow:
https://dsccommunity.org/guidelines/contributing/#understand-the-coding-workflow
https://dsccommunity.org/guidelines/testing-guidelines/#running-tests
You can also use Invoke-Pester once you run build.ps1 -Task build (not documented yet)
https://dsccommunity.org/guidelines/contributing/#attach-your-fork-to-a-free-azure-devops-organization

Copy link
Contributor Author

@nabrond nabrond left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 7 files reviewed, 2 unresolved discussions (waiting on @johlju)


DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1, line 501 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
.Contains

Maybe we should not use case sensitive here either?

My testing showed that these were not case sensitive, but I updated the code to avoid future confusion.


DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1, line 562 at r1 (raw file):

My testing showed that these were not case sensitive, but I updated the code to avoid future confusion.

Copy link
Contributor Author

@nabrond nabrond left a comment

Choose a reason for hiding this comment

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

Ran into some issues with the CI conversion and my local git repo. Refactored a bit to get away from the Contains() calls in the add/drop functions.

Reviewable status: 0 of 7 files reviewed, 2 unresolved discussions (waiting on @johlju)

@johlju
Copy link
Member

johlju commented Jan 3, 2020

@nabrond What issues did you run into? Something I should document in the contribution guidelines?

@johlju
Copy link
Member

johlju commented Jan 3, 2020

@nabrond could you please rebase against branch master so we get rid of already merged commits (those that already been merged in other PR's)

Copy link
Contributor Author

@nabrond nabrond left a comment

Choose a reason for hiding this comment

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

Rebased and pushed my branch again. Most of my issues were git-related. I never maintained master in my fork as everything was previously based off dev. Trying to get that back in-sync is still proving challenging, I continually encounter disconnected HEAD scenarios. I think once this PR is complete, I will recreate my copy of the repository for future work.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @johlju)

@johlju
Copy link
Member

johlju commented Jan 3, 2020

I thought git rebase would fix that for you. 🤔 I haven't seen the problem yet. But will look out for it.

@johlju
Copy link
Member

johlju commented Jan 3, 2020

There are still issues with the rebase. The PR wants to remove things from the change log.
I would do this to resolve this, will this fail with the error you mentioned?

git checkout master
git fetch origin master
git rebase origin/master
git push my --force
git checkout nabrond-fix-sqlserverrole
git rebase my/master
# fix any conflicts
git push my --force

@johlju
Copy link
Member

johlju commented Jan 3, 2020

You could also just delete the local master branch git branch -D master then checkout the master from upstream again, and force push that to your fork. Then rebase your working branch against your forks master branch.

nabrond and others added 2 commits January 3, 2020 12:03
This reverts commit 61b01b6. and should
resolve inconsistencies from rebase.
@nabrond
Copy link
Contributor Author

nabrond commented Jan 3, 2020

@johlju, I took at look at my git history for this branch and reverted the change that I think introduced the problems with CHANGELOG.MD. It looks like that change came in through one off my rebase operations. Hopefully this makes this PR good to go.

@johlju johlju added needs review The pull request needs a code review. and removed waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. labels Jan 3, 2020
Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 7 files at r2, 3 of 4 files at r5, 1 of 1 files at r6.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nabrond)

a discussion (no related file):
Could you please add a integration tests that tests the nested roles? That adds a role into a role, and then removes the role from the role?



tests/Unit/MSFT_SqlServerRole.Tests.ps1, line 1146 at r6 (raw file):

speciifying

Typo

@johlju
Copy link
Member

johlju commented Jan 6, 2020

@nabrond Awesome work on this! 😃 Thank you! Would just love to have an integration tests, and I found a little typo.

@johlju johlju added waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. and removed needs review The pull request needs a code review. labels Jan 6, 2020
Copy link
Contributor Author

@nabrond nabrond left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 6 files reviewed, 2 unresolved discussions (waiting on @johlju)

a discussion (no related file):

Previously, johlju (Johan Ljunggren) wrote…

Could you please add a integration tests that tests the nested roles? That adds a role into a role, and then removes the role from the role?

@johlju Integration tests added.



tests/Unit/MSFT_SqlServerRole.Tests.ps1, line 1146 at r6 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
speciifying

Typo

Done.

@johlju johlju added needs review The pull request needs a code review. and removed waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. labels Jan 11, 2020
@johlju
Copy link
Member

johlju commented Jan 11, 2020

@nabrond I will continue the review tomorrow but a quick question in regards to the case-sensitivity. If are SQL instance is using a case-sensitive collation would that make it possible to have logins and users with different casing? 🤔 When looking at this now I thought that this might break existing use-cases by removing .Contains(). What are your thoughts? 🤔

Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r7, 1 of 1 files at r8.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @nabrond)


CHANGELOG.md, line 39 at r8 (raw file):

Removed use of case-sensitive Contains() function when evalutating role membership.
``

In regards to the question in the main PR thread. This will not be an issue wit case-sensitive collations? It is never possible to have the same name of a login or group but with different casings?

@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 Jan 12, 2020
Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


CHANGELOG.md, line 39 at r8 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
Removed use of case-sensitive Contains() function when evalutating role membership.
``

In regards to the question in the main PR thread. This will not be an issue wit case-sensitive collations? It is never possible to have the same name of a login or group but with different casings?

It is supported in SQL Server to have the same login with different casing (in sensitive collations). But it will fail when compiling the mof-file as mentioned here #1191.

@johlju johlju added ready for merge The pull request was approved by the community and is ready to be merged by a maintainer. and removed waiting for author response The pull request is waiting for the author to respond to comments in the pull request. ready for merge The pull request was approved by the community and is ready to be merged by a maintainer. labels Jan 12, 2020
@johlju johlju changed the title SqlServerRole: Add support for nested roles and remove case-sensitive checks. SqlServerRole: Add support for nested roles and remove case-sensitive checks Jan 12, 2020
@johlju johlju merged commit 620e9b4 into dsccommunity:master Jan 12, 2020
@johlju
Copy link
Member

johlju commented Jan 12, 2020

@nabrond Thank you for the work on this! 😄

@nabrond nabrond deleted the nabrond-fix-sqlserverrole branch January 12, 2020 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants