Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnTooManyAttemptsWhenThatIsAppropriate() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnTooManyAttemptsWhenThatIsAppropriate()
        {
            // Given
            Users.create(NewUser("jake", "abc123", true));
            _manager.start();
            SetMockAuthenticationStrategyResult("jake", "wrong password", AuthenticationResult.TOO_MANY_ATTEMPTS);

            // When
            AuthSubject          authSubject = _manager.login(authToken("jake", "wrong password")).subject();
            AuthenticationResult result      = authSubject.AuthenticationResult;

            // Then
            assertThat(result, equalTo(AuthenticationResult.TOO_MANY_ATTEMPTS));
            _logProvider.assertExactly(Error("[%s]: failed to log in: too many failed attempts", "jake"));
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            AuthSubject subject = mock(typeof(AuthSubject));

            when(subject.Username()).thenReturn("pearl");

            EnterpriseSecurityContext ctx = mock(typeof(EnterpriseSecurityContext));

            when(ctx.Subject()).thenReturn(subject);
            when(ctx.Roles()).thenReturn(Collections.singleton("jammer"));

            _procedures = new SecurityProcedures();
            _procedures.securityContext = ctx;
            _procedures.userManager     = mock(typeof(EnterpriseUserManager));
        }