//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGoodPassword() public virtual void testGoodPassword() { PasswordPolicyResult result = identityService.checkPasswordAgainstPolicy(policy, "LongPas$w0rd"); assertThat(result.ViolatedRules.Count, @is(0)); assertThat(result.FulfilledRules.Count, @is(5)); assertThat(result.Valid, @is(true)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCheckValidPassword_WithoutPassingPolicy() public virtual void shouldCheckValidPassword_WithoutPassingPolicy() { // given // when PasswordPolicyResult result = identityService.checkPasswordAgainstPolicy("LongPas$w0rd"); // then assertThat(result, notNullValue()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testShortPassword() public virtual void testShortPassword() { PasswordPolicyResult result = identityService.checkPasswordAgainstPolicy(policy, "Pas$w0rd"); checkThatPasswordWasInvalid(result); PasswordPolicyRule rule = result.ViolatedRules[0]; assertThat(rule.Placeholder, @is(PasswordPolicyLengthRuleImpl.PLACEHOLDER)); assertThat(rule, instanceOf(typeof(PasswordPolicyLengthRuleImpl))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPasswordWithoutSpecialChar() public virtual void testPasswordWithoutSpecialChar() { PasswordPolicyResult result = identityService.checkPasswordAgainstPolicy(policy, "LongPassw0rd"); checkThatPasswordWasInvalid(result); PasswordPolicyRule rule = result.ViolatedRules[0]; assertThat(rule.Placeholder, @is(PasswordPolicySpecialCharacterRuleImpl.PLACEHOLDER)); assertThat(rule, instanceOf(typeof(PasswordPolicySpecialCharacterRuleImpl))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPasswordWithoutLowerCase() public virtual void testPasswordWithoutLowerCase() { PasswordPolicyResult result = identityService.checkPasswordAgainstPolicy(policy, "LONGPAS$W0RD"); checkThatPasswordWasInvalid(result); PasswordPolicyRule rule = result.ViolatedRules[0]; assertThat(rule.Placeholder, @is(PasswordPolicyLowerCaseRuleImpl.PLACEHOLDER)); assertThat(rule, instanceOf(typeof(PasswordPolicyLowerCaseRuleImpl))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCheckInvalidPassword() public virtual void shouldCheckInvalidPassword() { when(processEngineConfigurationMock.EnablePasswordPolicy).thenReturn(true); PasswordPolicyResult passwordPolicyResultMock = mock(typeof(PasswordPolicyResult)); when(identityServiceMock.checkPasswordAgainstPolicy(anyString())).thenReturn(passwordPolicyResultMock); when(passwordPolicyResultMock.FulfilledRules).thenReturn(Collections.singletonList <PasswordPolicyRule>(new PasswordPolicyDigitRuleImpl(1))); when(passwordPolicyResultMock.ViolatedRules).thenReturn(Collections.singletonList <PasswordPolicyRule>(new PasswordPolicyLengthRuleImpl(1))); given().header("accept", MediaType.APPLICATION_JSON).contentType(POST_JSON_CONTENT_TYPE).body(Collections.singletonMap("password", "password")).then().expect().statusCode(Status.OK.StatusCode).body("rules[0].placeholder", equalTo("PASSWORD_POLICY_DIGIT")).body("rules[0].parameter.minDigit", equalTo("1")).body("rules[0].valid", equalTo(true)).body("rules[1].placeholder", equalTo("PASSWORD_POLICY_LENGTH")).body("rules[1].parameter.minLength", equalTo("1")).body("rules[1].valid", equalTo(false)).body("valid", equalTo(false)).when().post(QUERY_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCheckValidPassword() public virtual void shouldCheckValidPassword() { when(processEngineConfigurationMock.EnablePasswordPolicy).thenReturn(true); PasswordPolicyResult passwordPolicyResultMock = mock(typeof(PasswordPolicyResult)); when(identityServiceMock.checkPasswordAgainstPolicy(anyString())).thenReturn(passwordPolicyResultMock); when(passwordPolicyResultMock.FulfilledRules).thenReturn(Collections.singletonList <PasswordPolicyRule>(new PasswordPolicyDigitRuleImpl(1))); when(passwordPolicyResultMock.ViolatedRules).thenReturn(System.Linq.Enumerable.Empty <PasswordPolicyRule>()); given().header("accept", MediaType.APPLICATION_JSON).contentType(POST_JSON_CONTENT_TYPE).body(Collections.singletonMap("password", "password")).then().expect().statusCode(Status.OK.StatusCode).body("valid", equalTo(true)).when().post(QUERY_URL); }
public static CheckPasswordPolicyResultDto fromPasswordPolicyResult(PasswordPolicyResult result) { CheckPasswordPolicyResultDto dto = new CheckPasswordPolicyResultDto(); foreach (PasswordPolicyRule rule in result.FulfilledRules) { dto.rules.Add(new CheckPasswordPolicyRuleDto(rule, true)); } if (result.ViolatedRules.Count > 0) { dto.valid = false; foreach (PasswordPolicyRule rule in result.ViolatedRules) { dto.rules.Add(new CheckPasswordPolicyRuleDto(rule, false)); } } return(dto); }
private void checkThatPasswordWasInvalid(PasswordPolicyResult result) { assertThat(result.ViolatedRules.Count, @is(1)); assertThat(result.FulfilledRules.Count, @is(4)); assertThat(result.Valid, @is(false)); }