public void TestPassword_FailingPassword_HasRulesFailed() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.IsTrue(result.RulesFailed?.Any() ?? false); }
public void TestPassword_PassingPassword_MaxScore() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.AreEqual(defaultRuleSet.Score, result.Score); }
public void TestPassword_PassingPassword_HasRecommendations() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.IsTrue(result.RulesRecommendations?.Any() ?? false); }
public void TestPassword_FailingPassword_IsSuccessFalse() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.IsFalse(result.IsSuccess); }
public void TestPassword_PassingPassword_IsSuccessTrue() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.IsTrue(result.IsSuccess); }
public void TestPassword_FailingPassword_HasZeroScore() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.AreEqual(0, result.Score); }
public void TestPassword_EmptyPassword_ScoreZero() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = ""; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.AreEqual(0, result.Score); }
public void TestPassword_PassingPassword_HasNoRulesFailed() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.IsNull(result.RulesFailed); }
public void TestPassword_FailingPartiallyPassword_HasRulesPassed() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.IsNotNull(result.RulesPassed); }
public void TestPassword_PassingPassword_HasScoreHigherThanZero() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.IsTrue(result.IsSuccess); Assert.IsTrue(result.Score > 0); }
public void TestPassword_FailingPartiallyPassword_HasZeroScore() { // Arrange RuleSet defaultRuleSet = RuleSetProvider.Default; string password = "******"; // Act RuleSetTestResult result = defaultRuleSet.Test(password); // Assert Assert.IsFalse(result.IsSuccess); Assert.AreEqual(0, result.Score); }
public async Task <CheckPasswordResult> Check( string password, string ruleSetName = null, string rankingSetName = null, bool isCheckHaveIBeenPwned = false) { RuleSet ruleSet = await this.ruleSetService.GetRuleSet(ruleSetName); RankingSet rankingSet = await this.rankingSetService.GetRankingSet(rankingSetName); // Test Password RuleSetTestResult ruleSetTestResults = ruleSet.Test(password); // Normalize Score int normalizedScore = this.scoreNormalizer.Normalize( ruleSetTestResults.IsSuccess ? ruleSetTestResults : null, ruleSet, rankingSet); // Interpret KeyValuePair <int, string>?interpretedRanking = rankingSet.GetClosestRanking(normalizedScore); PNDPassword pndPassword = null; if (isCheckHaveIBeenPwned) { // Check if pass has been pwned on the external website pndPassword = await this.pndService.HaveIBeenPND(password); } return(new CheckPasswordResult( score: interpretedRanking?.Key, ranking: interpretedRanking?.Value, rankingSet: rankingSet, ruleSet: ruleSet, isSuccess: ruleSetTestResults.IsSuccess, pndPassword: pndPassword, rulesPassed: ruleSetTestResults.RulesPassed, rulesFailed: ruleSetTestResults.RulesFailed, rulesRecommendations: ruleSetTestResults.RulesRecommendations)); }