Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void givenExplicitlyDisabledServerLoggingConfigurationShouldNotLogAccesses() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void GivenExplicitlyDisabledServerLoggingConfigurationShouldNotLogAccesses()
        {
            // given
            string directoryPrefix = _testName.MethodName;
            File   logDirectory    = _testDirectory.directory(directoryPrefix + "-logdir");

            NeoServer server = serverOnRandomPorts().withDefaultDatabaseTuning().persistent().withProperty(ServerSettings.http_logging_enabled.name(), Settings.FALSE).withProperty(GraphDatabaseSettings.logs_directory.name(), logDirectory.ToString()).withProperty((new BoltConnector("bolt")).listen_address.name(), ":0").usingDataDir(_testDirectory.directory(directoryPrefix + "-dbdir").AbsolutePath).build();

            try
            {
                server.Start();
                FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server);

                // when
                string        query    = "?implicitlyDisabled" + RandomString();
                JaxRsResponse response = (new RestRequest()).get(functionalTestHelper.ManagementUri() + query);

                assertThat(response.Status, @is(HttpStatus.SC_OK));
                response.Close();

                // then
                File httpLog = new File(logDirectory, "http.log");
                assertThat(httpLog.exists(), @is(false));
            }
            finally
            {
                server.Stop();
            }
        }
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 givenExplicitlyEnabledServerLoggingConfigurationShouldLogAccess() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void GivenExplicitlyEnabledServerLoggingConfigurationShouldLogAccess()
        {
            // given
            string directoryPrefix = _testName.MethodName;
            File   logDirectory    = _testDirectory.directory(directoryPrefix + "-logdir");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String query = "?explicitlyEnabled=" + randomString();
            string query = "?explicitlyEnabled=" + RandomString();

            NeoServer server = serverOnRandomPorts().withDefaultDatabaseTuning().persistent().withProperty(ServerSettings.http_logging_enabled.name(), Settings.TRUE).withProperty(GraphDatabaseSettings.logs_directory.name(), logDirectory.AbsolutePath).withProperty((new BoltConnector("bolt")).listen_address.name(), ":0").usingDataDir(_testDirectory.directory(directoryPrefix + "-dbdir").AbsolutePath).build();

            try
            {
                server.Start();

                FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server);

                // when
                JaxRsResponse response = (new RestRequest()).get(functionalTestHelper.ManagementUri() + query);
                assertThat(response.Status, @is(HttpStatus.SC_OK));
                response.Close();

                // then
                File httpLog = new File(logDirectory, "http.log");
                assertEventually("request appears in log", FileContentSupplier(httpLog), containsString(query), 5, TimeUnit.SECONDS);
            }
            finally
            {
                server.Stop();
            }
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMakeJAXRSClassesAvailableViaHTTP() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldMakeJAXRSClassesAvailableViaHTTP()
        {
            CommunityServerBuilder builder = CommunityServerBuilder.server();

            _server = ServerHelper.createNonPersistentServer(builder);
            FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(_server);

            JaxRsResponse response = (new RestRequest()).get(functionalTestHelper.ManagementUri());

            assertEquals(200, response.Status);
            response.Close();
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRedirectToBrowserUsingXForwardedHeaders() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRedirectToBrowserUsingXForwardedHeaders()
        {
            Client nonRedirectingClient = Client.create();

            nonRedirectingClient.FollowRedirects = false;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.server.rest.JaxRsResponse response = new org.neo4j.server.rest.RestRequest(server.baseUri(), nonRedirectingClient).accept(javax.ws.rs.core.MediaType.TEXT_HTML_TYPE).header("X-Forwarded-Host", "foo.bar:8734").header("X-Forwarded-Proto", "https").get(server.baseUri().toString());
            JaxRsResponse response = (new RestRequest(_server.baseUri(), nonRedirectingClient)).accept(MediaType.TEXT_HTML_TYPE).header("X-Forwarded-Host", "foo.bar:8734").header("X-Forwarded-Proto", "https").get(_server.baseUri().ToString());

            assertEquals(303, response.Status);
            assertEquals(new URI("https://foo.bar:8734/browser/"), response.Location);
            response.Close();
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPickupRelativeUrisForManagementApiAndRestApi() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPickupRelativeUrisForManagementApiAndRestApi()
        {
            string dataUri       = "a/different/data/uri/";
            string managementUri = "a/different/management/uri/";

            _server = serverOnRandomPorts().withRelativeRestApiUriPath("/" + dataUri).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).withRelativeManagementApiUriPath("/" + managementUri).build();
            _server.start();

            JaxRsResponse response = (new RestRequest()).get(_server.baseUri().ToString() + dataUri, MediaType.TEXT_HTML_TYPE);

            assertEquals(200, response.Status);

            response = (new RestRequest()).get(_server.baseUri().ToString() + managementUri);
            assertEquals(200, response.Status);
            response.Close();
        }
Esempio n. 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPickUpAddressFromConfig() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPickUpAddressFromConfig()
        {
            ListenSocketAddress nonDefaultAddress = new ListenSocketAddress("0.0.0.0", 0);

            _server = _server().onAddress(nonDefaultAddress).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build();
            _server.start();

            HostnamePort localHttpAddress = LocalHttpAddress;

            assertNotEquals(HttpConnector.Encryption.NONE.defaultPort, localHttpAddress.Port);
            assertEquals(nonDefaultAddress.Hostname, localHttpAddress.Host);

            JaxRsResponse response = (new RestRequest(_server.baseUri())).get();

            assertThat(response.Status, @is(200));
            response.Close();
        }