//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldForwardHttpAndHost() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldForwardHttpAndHost() { URI rootUri = _functionalTestHelper.baseUri(); HttpClient httpclient = new DefaultHttpClient(); try { HttpGet httpget = new HttpGet(rootUri); httpget.setHeader("Accept", "application/json"); httpget.setHeader("X-Forwarded-Host", "foobar.com"); httpget.setHeader("X-Forwarded-Proto", "http"); HttpResponse response = httpclient.execute(httpget); string length = response.getHeaders("CONTENT-LENGTH")[0].Value; sbyte[] data = new sbyte[Convert.ToInt32(length)]; response.Entity.Content.read(data); string responseEntityBody = StringHelper.NewString(data); assertTrue(responseEntityBody.Contains("http://foobar.com")); assertFalse(responseEntityBody.Contains("http://localhost")); } finally { httpclient.ConnectionManager.shutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void should403WhenAuthenticatedButForbidden() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Should403WhenAuthenticatedButForbidden() { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withSecurityRules(typeof(PermanentlyForbiddenSecurityRule).FullName, typeof(PermanentlyPassingSecurityRule).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); JaxRsResponse clientResponse = Gen.get().expectedStatus(403).expectedType(MediaType.APPLICATION_JSON_TYPE).get(TrimTrailingSlash(_functionalTestHelper.baseUri())).response(); assertEquals(403, clientResponse.Status); }
public virtual void AComplexWildcardUriPathShould401OnAccessToProtectedSubPath() { string mountPoint = "/protected/wildcard_replacement/x/y/z/something/else/more_wildcard_replacement/a/b/c" + "/final/bit"; //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withThirdPartyJaxRsPackage("org.dummy.web.service", mountPoint).withSecurityRules(typeof(PermanentlyFailingSecurityRuleWithComplexWildcardPath).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); JaxRsResponse clientResponse = Gen.get().expectedStatus(401).expectedType(MediaType.APPLICATION_JSON_TYPE).expectedHeader("WWW-Authenticate").get(TrimTrailingSlash(_functionalTestHelper.baseUri()) + mountPoint + "/more/stuff").response(); assertEquals(401, clientResponse.Status); }