-
Notifications
You must be signed in to change notification settings - Fork 4k
[Azure.Storage] Fix a null reference issue in New-AzureRMStorageAccount #5220
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
Conversation
@@ -176,7 +176,10 @@ public override void ExecuteCmdlet() | |||
if (this.EnableEncryptionService != null) | |||
{ | |||
createParameters.Encryption = ParseEncryption(EnableEncryptionService); | |||
createParameters.Encryption.KeySource = "Microsoft.Storage"; | |||
if (createParameters.Encryption != null) |
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.
Covering test? Also, rather than checking this way, you can add a ValidateNotNullOrEmpty attribute to this parameter and here check for MyInvocation.BoundParameters.ContainsKey('Encryption')
which is the recommended pattern if you want to see if a parameter was bouynd from either user input or the pipeline
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.
Hi Mark,
As you know, generally we will not cover the data plan cmldets in PowerShell unit test framework since XSCL request can't be record in unit test. I have added cases to test Encryption as none in our team regression test. (let me know if you would like to see the CR for the test).
ValidateNotNullOrEmpty or MyInvocation.BoundParameters.ContainsKey() not work for this issue, since when set "-EnableEncryptionService None" it can pass both check, so will still get the issue.
We will make the "-EnableEncryptionService" as obsolete very soon as feature team requested. I will send a PR for this soon after get the detail requirement from feature team. But before that, would like to fix this issue first.
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.
@blueww The problem there is that people wanting to contribute to these cmdlets sdo not have access to these tests, and so cann't tell if there is a regression. Please add a covering test here for this issue
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.
@markcowl
Unit test is added. please check.
I have verified, without the fix, the unit test can repro the issue. With the fix, the Unit test can pass.
@markcowl |
if (createParameters.Encryption != null) | ||
{ | ||
createParameters.Encryption.KeySource = "Microsoft.Storage"; | ||
} |
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.
Can you please update the changelog for the AzureRM.Storage module here: https://github.com/Azure/azure-powershell/blob/preview/src/ResourceManager/Storage/ChangeLog.md
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.
@markcowl
Change log is updated in the PR.
@blueww - since there is only a changelog change needed, kicked off an on-demand run here: https://azuresdkci.westus2.cloudapp.azure.com/view/PowerShell/job/powershell-demand/355/ Once you have made the changelog change and this passes, we can merge. |
Change log added. |
Description
This PR fix a null reference issue : https://msazure.visualstudio.com/One/XStore-XClient/_workitems?id=1869771
As feature team required, we should remove -EnableEncryptionService and -DisableEncryptionService support in New/set-AzureRMstorageAccount. The detail is in discussion, and I will raise a PR to set the related parameters to obsolete when the discussion with feature team finish.
I have manual test the fix works, and if the parameters are removed, add test case will be no need.
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThru
parameter.Cmdlet Parameter Guidelines