-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from ITfoxtec/test
Test
- Loading branch information
Showing
28 changed files
with
162 additions
and
708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/FoxIDs.Control/Controllers/Master/MRiskPasswordTestController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using FoxIDs.Infrastructure; | ||
using FoxIDs.Models; | ||
using FoxIDs.Repository; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
|
||
namespace FoxIDs.Controllers | ||
{ | ||
public class MRiskPasswordTestController : MasterApiController | ||
{ | ||
private readonly IMasterRepository masterRepository; | ||
|
||
public MRiskPasswordTestController(TelemetryScopedLogger logger, IMasterRepository masterRepository) : base(logger) | ||
{ | ||
this.masterRepository = masterRepository; | ||
} | ||
|
||
/// <summary> | ||
/// Test if a password has appeared in breaches and is in risk. | ||
/// </summary> | ||
/// <param name="password">Password.</param> | ||
/// <returns>True if in risk.</returns> | ||
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
public async Task<ActionResult<bool>> GetRiskPasswordTest(string password) | ||
{ | ||
try | ||
{ | ||
if (!ModelState.TryValidateRequiredParameter(password, nameof(password))) return BadRequest(ModelState); | ||
|
||
var passwordSha1Hash = password.Sha1Hash(); | ||
var mRiskPassword = await masterRepository.GetAsync<RiskPassword>(await RiskPassword.IdFormat(passwordSha1Hash)); | ||
return Ok(true); | ||
} | ||
catch (CosmosDataException ex) | ||
{ | ||
if (ex.StatusCode == HttpStatusCode.NotFound) | ||
{ | ||
return Ok(false); | ||
} | ||
throw; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/FoxIDs.ControlClient/Models/ViewModels/Tenants/GeneralUploadRiskPasswordViewModel.cs
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
src/FoxIDs.ControlClient/Models/ViewModels/Tenants/UploadRiskPasswordViewModel.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.