Esempio n. 1
0
            protected internal override bool matchesSafely(ResponseMessage t)
            {
                assertThat(t, instanceOf(typeof(FailureMessage)));
                FailureMessage msg = ( FailureMessage )t;

                assertThat(msg.Status(), equalTo(_status));
                assertThat(msg.Message(), containsString(_message));
                return(true);
            }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailDifferentlyIfTooManyFailedAuthAttempts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailDifferentlyIfTooManyFailedAuthAttempts()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long timeout = System.currentTimeMillis() + 60_000;
            long           timeout        = DateTimeHelper.CurrentUnixTimeMillis() + 60_000;
            FailureMessage failureMessage = null;

            // When
            while (failureMessage == null)
            {
                if (DateTimeHelper.CurrentUnixTimeMillis() > timeout)
                {
                    fail("Timed out waiting for the authentication failure to occur.");
                }

                ExecutorService executor = Executors.newFixedThreadPool(10);

                // Fire up some parallel connections that all send wrong authentication tokens
                IList <CompletableFuture <FailureMessage> > futures = new List <CompletableFuture <FailureMessage> >();
                for (int i = 0; i < 10; i++)
                {
                    futures.Add(CompletableFuture.supplyAsync(this.collectAuthFailureOnFailedAuth, executor));
                }

                try
                {
                    // Wait for all tasks to complete
                    CompletableFuture.allOf(futures.ToArray()).get(30, SECONDS);

                    // We want at least one of the futures to fail with our expected code
                    for (int i = 0; i < futures.Count; i++)
                    {
                        FailureMessage recordedMessage = futures[i].get();

                        if (recordedMessage != null)
                        {
                            failureMessage = recordedMessage;

                            break;
                        }
                    }
                }
                catch (TimeoutException)
                {
                    // if jobs did not complete, let's try again
                    // do nothing
                }
                finally
                {
                    executor.shutdown();
                }
            }

            assertThat(failureMessage.Status(), equalTo(Org.Neo4j.Kernel.Api.Exceptions.Status_Security.AuthenticationRateLimit));
            assertThat(failureMessage.Message(), containsString("The client has provided incorrect authentication details too many times in a row."));
        }
Esempio n. 3
0
            protected internal override bool MatchesSafely(ResponseMessage t)
            {
                assertThat(t, instanceOf(typeof(FailureMessage)));
                FailureMessage msg = ( FailureMessage )t;

                if (!msg.Status().Equals(Org.Neo4j.Kernel.Api.Exceptions.Status_Security.Unauthorized) || !msg.Message().Contains("The client is unauthorized due to authentication failure."))
                {
                    SpecialMessage = msg;
                }
                return(true);
            }