Skip to content

Commit c56a761

Browse files
fix failing specflow
1 parent e4c5f2e commit c56a761

5 files changed

Lines changed: 24 additions & 19 deletions

File tree

SecurityService.BusinessLogic/RequestHandlers/UserRequestHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public async Task<Result> Handle(SecurityServiceCommands.CreateUserCommand comma
9090
};
9191

9292
String passwordValue = String.IsNullOrEmpty(command.Password) ? UserRequestHandler.GenerateRandomPassword(this.UserManager.Options.Password) : command.Password;
93-
93+
9494
// Hash the default password
9595
newIdentityUser.PasswordHash = this.PasswordHasher.HashPassword(newIdentityUser, passwordValue);
9696

@@ -281,6 +281,7 @@ public async Task<Result<ChangeUserPasswordResult>> Handle(SecurityServiceComman
281281
return Result.Invalid($"Client not found for clientId {command.ClientId}");
282282
}
283283

284+
Logger.LogWarning($"Client uri: {client.ClientUri}");
284285
return Result.Success(new ChangeUserPasswordResult { IsSuccessful = true, RedirectUri = client.ClientUri});
285286
}
286287

@@ -343,7 +344,6 @@ public async Task<Result<String>> Handle(SecurityServiceCommands.ProcessPassword
343344
return Result.Invalid($"Client not found for clientId {command.ClientId}");
344345
}
345346

346-
Logger.LogWarning($"Client uri {client.ClientUri}");
347347
return Result.Success<String>(client.ClientUri);
348348
}
349349

SecurityService.OpenIdConnect.IntegrationTests/ChangePassword/ChangePassword.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Background:
2525
@PRTest
2626
Scenario: Change Passwword
2727
Given I create the following users
28-
| Email Address | Phone Number | Given Name | Middle Name | Family Name | Claims | Roles |
29-
| estateuser@testestate1.co.uk | 123456789 | Test | | User 1 | EstateId:1 | Estate |
28+
| Email Address | Phone Number | Given Name | Middle Name | Family Name | Claims | Roles | Password |
29+
| estateuser@testestate1.co.uk | 123456789 | Test | | User 1 | EstateId:1 | Estate | 123456 |
3030
Then I get an email with a confirm email address link
3131
When I navigate to the confirm email address
3232
Then I am presented with the confirm email address successful screen
@@ -38,7 +38,7 @@ Scenario: Change Passwword
3838
Then I am presented with the privacy screen
3939
When I click the 'ChangePassword' link
4040
Then I am presented with a change password screen
41-
When I enter my old password '123456'
41+
When I enter my old password
4242
When I enter my new password 'Pa55word!'
4343
And I confirm my new password 'Pa55word!'
4444
And I click the change password button

SecurityService.OpenIdConnect.IntegrationTests/ChangePassword/ChangePassword.feature.cs

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SecurityService.OpenIdConnect.IntegrationTests/ChangePassword/ChangePasswordSteps.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ public async Task ThenIAmPresentedWithAChangePasswordScreen()
4444
changePasswordButton.ShouldNotBeNull();
4545
}
4646

47-
[When(@"I enter my old password '([^']*)'")]
48-
public async Task WhenIEnterMyOldPassword(string oldPassword)
47+
//[When(@"I enter my old password '([^']*)'")]
48+
//public async Task WhenIEnterMyOldPassword(string oldPassword)
49+
//{
50+
// this.WebDriver.FillIn("Input.CurrentPassword", oldPassword);
51+
//}
52+
53+
[When("I enter my old password")]
54+
public void WhenIEnterMyOldPassword()
4955
{
50-
this.WebDriver.FillIn("Input.CurrentPassword", oldPassword);
56+
this.WebDriver.FillIn("Input.CurrentPassword", this.TestingContext.Password);
5157
}
5258

5359
[When(@"I enter my new password '([^']*)'")]

SecurityService.UserInterface/Pages/Account/ChangePassword/Index.cshtml.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.AspNetCore.Mvc;
1010
using Microsoft.AspNetCore.Mvc.RazorPages;
1111
using SecurityService.Models;
12+
using SimpleResults;
1213

1314
namespace IdentityServerHost.Pages.ChangePassword;
1415

@@ -64,17 +65,13 @@ public async Task<IActionResult> OnPost(CancellationToken cancellationToken)
6465
return this.Page();
6566
}
6667
SecurityServiceCommands.ChangeUserPasswordCommand command = new(Input.Username, Input.CurrentPassword, Input.NewPassword, Input.ClientId);
67-
ChangeUserPasswordResult? result = await this.Mediator.Send(command, cancellationToken);
68-
69-
Logger.LogDebug(Input.ClientId);
70-
Logger.LogDebug(result.IsSuccessful.ToString());
71-
Logger.LogDebug(result.RedirectUri);
72-
if (result.IsSuccessful== false) {
68+
Result<ChangeUserPasswordResult>? result= await this.Mediator.Send(command, cancellationToken);
69+
70+
if (result.IsFailed) {
7371
ModelState.AddModelError(String.Empty, ErrorChangingPassword);
7472
return this.Page();
7573
}
76-
77-
return this.Redirect(result.RedirectUri);
74+
return this.Redirect(result.Data.RedirectUri);
7875
}
7976

8077
private async Task BuildModelAsync(String returnUrl)

0 commit comments

Comments
 (0)