Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
com.github.httpmock:mock-http-server-exec
Advanced tools
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 - Executable
We found that com.github.httpmock:mock-http-server-exec 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.