-
Notifications
You must be signed in to change notification settings - Fork 228
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
Set-SqlDscServerPermission
: Added support for assigning permissions to a server role
#2061
base: main
Are you sure you want to change the base?
Conversation
…ts for new logic bug haven't added explicit tests for roles
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2061 +/- ##
======================================
- Coverage 94% 93% -1%
======================================
Files 94 36 -58
Lines 7930 6341 -1589
======================================
- Hits 7500 5953 -1547
+ Misses 430 388 -42
|
Set-SqlServerPermission
: Added support for assigning permissions to a server role
There was a problem hiding this 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, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @IAMJDA)
source/Classes/020.SqlPermission.ps1
line 373 at r1 (raw file):
New-InvalidOperationException -Message $missingPrincipalMessage }
We should not need this check at all since it is already evaluated in the Set-SqlDscServerPermission
command. I rather see this change for the resource SqlPermission
in a separate PR as we also need integration tests. Please revert the changes for this file and move it to a separate PR. 🙂
Code quote:
$testSqlDscIsPrincipalParameters = @{
ServerObject = $serverObject
Name = $this.Name
}
# This will test wether the principal exist.
$isLogin = Test-SqlDscIsLogin @testSqlDscIsPrincipalParameters
$isRole = Test-SqlDscIsRole @testSqlDscIsPrincipalParameters
if (-not $isLogin -and -not $isRole)
{
$missingPrincipalMessage = $this.localizedData.NameIsMissing -f @(
$this.Name,
$this.InstanceName
)
New-InvalidOperationException -Message $missingPrincipalMessage
}
source/Public/Set-SqlDscServerPermission.ps1
line 107 at r1 (raw file):
if (-not $isLogin -and -not $isRole) { $missingPrincipalMessage = $script:localizedData.ServerPermission_MissingPrincipal -f $Name, $ServerObject.InstanceName
We need to update the localized string
ServerPermission_MissingPrincipal = The principal '{0}' is not a login on the instance '{1}'. |
Code quote:
ServerPermission_MissingPrincipal
source/Public/Set-SqlDscServerPermission.ps1
line 117 at r1 (raw file):
) ) return
We should not need return
here as we throw a terminating error?
Code quote:
return
tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1
line 430 at r1 (raw file):
Mock -CommandName Test-SqlDscIsRole -MockWith { return $false }
We should add a test that actually test the it is a role and not a login.
Code quote:
Mock -CommandName Test-SqlDscIsRole -MockWith {
return $false
}
Set-SqlServerPermission
: Added support for assigning permissions to a server roleSet-SqlDscServerPermission
: Added support for assigning permissions to a server role
Pull Request (PR) description
Updated Set-SqlDscServerPermission to be able to set permission on server roles. Adapted unit tests so they should continue to work but missing support for the new logic.
This Pull Request (PR) fixes the following issues
Set-SqlDscServerPermission
: Not possible to set server permissions for a server role #2059Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is