Skip to content

[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

Merged
merged 3 commits into from
Jan 17, 2018

Conversation

blueww
Copy link
Member

@blueww blueww commented Jan 4, 2018

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

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

@@ -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)
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

@blueww blueww Jan 9, 2018

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.

@blueww
Copy link
Member Author

blueww commented Jan 9, 2018

@blueww
Copy link
Member Author

blueww commented Jan 15, 2018

@markcowl
Since the Code complete is near, would you please help to take a look at the PR to reduce the risk?
Let me know if anything still need change.
Hope we can make it in ASAP.

if (createParameters.Encryption != null)
{
createParameters.Encryption.KeySource = "Microsoft.Storage";
}
Copy link
Member

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

Copy link
Member Author

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.

@markcowl
Copy link
Member

@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.

@blueww
Copy link
Member Author

blueww commented Jan 17, 2018

@maddieclayton maddieclayton merged commit 4b28374 into Azure:preview Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants