
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
com.github.httpmock:mock-http-server
With this mock http server you can write integration tests for your application and mock its http based backends. This example shows an integration test which configures the mock to answer for a specific request with a specific response. It also shows how to use this mock server with junit.
import static com.github.httpmock.builder.RequestBuilder.request;
import static com.github.httpmock.builder.ResponseBuilder.response;
import static com.github.httpmock.times.ExcatlyOnce.once;
import static com.jayway.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import com.github.httpmock.dto.RequestDto;
import com.github.httpmock.dto.ResponseDto;
import com.jayway.restassured.response.Response;
public class ExampleIT {
@ClassRule
public static HttpMockServer mockServer = new HttpMockServer();
@Rule
public HttpMock mock = new HttpMock(mockServer);
@Test
public void someTest() throws Exception {
RequestDto request = request().method("POST").url("/some/url").build();
ResponseDto response = response().payload("data")
.contentType("text/plain").build();
mock.when(request).thenRespond(response);
Response mockResponse = given().baseUri(getBaseUri())
.basePath(mock.getRequestUrl()).post("/some/url");
assertThat(mockResponse.getBody().asString(), is("data"));
assertThat(mockResponse.getContentType(), is("text/plain"));
mock.verify(request, once());
}
private String getBaseUri() {
return String.format("http://localhost:%d", mockServer.getPort());
}
}
FAQs
Mock HTTP Server
We found that com.github.httpmock:mock-http-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket investigates hidden protestware in npm packages that blocks user interaction and plays the Ukrainian anthem for Russian-language visitors.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.