Ejemplo n.º 1
0
//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));
        }
Ejemplo n.º 2
0
//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());
        }
Ejemplo n.º 3
0
//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)));
        }
Ejemplo n.º 4
0
//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)));
        }
Ejemplo n.º 5
0
//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)));
        }
Ejemplo n.º 6
0
//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);
        }
Ejemplo n.º 7
0
//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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
 private void checkThatPasswordWasInvalid(PasswordPolicyResult result)
 {
     assertThat(result.ViolatedRules.Count, @is(1));
     assertThat(result.FulfilledRules.Count, @is(4));
     assertThat(result.Valid, @is(false));
 }