Skip to content

Commit 8a59b8a

Browse files
committed
Fix for comments from PR
1 parent f7cb5de commit 8a59b8a

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceDetails/SetAzureStorSimpleVirtualDevice.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public override void ExecuteCmdlet()
117117
private void ValidateParams() {
118118
ValidateLength(AdministratorPassword, 8, 15, Resources.AdminPasswordLengthError);
119119
ValidateLength(SnapshotManagerPassword, 14, 15, Resources.SnapshotPasswordLengthError);
120-
ValidatePasswordComplexity(AdministratorPassword);
121-
ValidatePasswordComplexity(SnapshotManagerPassword);
120+
ValidatePasswordComplexity(AdministratorPassword, "AdministratorPassword");
121+
ValidatePasswordComplexity(SnapshotManagerPassword, "SnapshotManagerPassword");
122122
}
123123
}
124124
}

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@
514514
<value>Invalid value for Registration Key. CIK provided couldnt be used to decrypt the secrets! The exact exception while decrypting is "{0}"!</value>
515515
</data>
516516
<data name="PasswordCharacterCriteriaError" xml:space="preserve">
517-
<value>The password must contain 3 of the following:
517+
<value>{0} is not complex enough. It must contain 3 of the following:
518518
a lowercase character
519519
an uppercase character
520520
a number

src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,17 +547,19 @@ internal void ValidateLength(string data, uint minLength, uint maxLength, string
547547
/// conditions when the validation fails.
548548
/// </summary>
549549
/// <param name="data"></param>
550-
internal void ValidatePasswordComplexity(string data)
550+
internal void ValidatePasswordComplexity(string data, string passwordName)
551551
{
552-
string errorMessage = Resources.PasswordCharacterCriteriaError;
552+
string errorMessage = string.Format(Resources.PasswordCharacterCriteriaError, passwordName);
553553
var criteriaFulfilled = 0;
554554
// Regular expressions for lowercase letter, uppercase letter, digit and special char
555555
// respectively
556556
string[] criteriaRegexs = { ".*[a-z]", ".*[A-Z]", ".*\\d", ".*\\W" };
557557

558558
foreach(var regexStr in criteriaRegexs){
559-
var regex = new Regex(regexStr);
560-
if(regex.IsMatch(data)){
559+
// The static IsMatch method is supposed to use an Application-wide cache of compiled regexes
560+
// and hence should save computation time (though not very significant because we are not doing tens of
561+
// thousands of such tests)
562+
if(Regex.IsMatch(data, regexStr)){
561563
criteriaFulfilled += 1;
562564
}
563565
}

0 commit comments

Comments
 (0)