-
Notifications
You must be signed in to change notification settings - Fork 84
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
Fixed transparentDataEncryption property status to state #1505
Conversation
@Dylan-Prins Thanks for the PR. Looks like there is a difference between various API versions or the provider documentation is wrong. The newer use If the later, to get the tests to pass we need to add an entry for PSRule.Rules.Azure/tests/PSRule.Rules.Azure.Tests/Resources.SQL.json Lines 436 to 491 in ca694e0
@ms-sambell Did you notice something similar? |
I see! I will add an if statement.
How can I check on API-Version in the if statement?
|
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.
@Dylan-Prins Nice work on the test resource. I think your suggestion is better to conditionally detect based on API version, but there is some specific cases around it.
Based on your suggestion, I am fine with removing database-C
and just updating database-B
with state
as an export from Azure will be using a newer API version the specific case we are testing should always be state
.
@@ -94,7 +94,7 @@ Rule 'Azure.SQL.TDE' -Ref 'AZR-000191' -Type 'Microsoft.Sql/servers/databases' - | |||
return $Assert.Fail($LocalizedData.SubResourceNotFound, 'Microsoft.Sql/servers/databases/transparentDataEncryption'); | |||
} | |||
foreach ($config in $configs) { | |||
$Assert.HasFieldValue($config, 'Properties.status', 'Enabled'); | |||
$Assert.HasFieldValue($config, 'Properties.state', 'Enabled'); |
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.
The property apiVersion
will not exist if exported with in-flight scenarios, but latest API version should be used. We only need to catch the case when older IaC is used.
$Assert.HasFieldValue($config, 'Properties.state', 'Enabled'); | |
if ($Assert.HasFieldValue($config, 'apiVersion', '2014-04-01').Result) { | |
$Assert.HasFieldValue($config, 'Properties.status', 'Enabled'); | |
} | |
else { | |
$Assert.HasFieldValue($config, 'Properties.state', 'Enabled'); | |
} |
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.
Ok, I have added the if statement, removed database-c and changed database-b to 'state'
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.
@Dylan-Prins Great, all good to go. I'll update the branch for main and merge. Thanks!
PR Summary
PR Checklist