Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@improbable-eng/grpc-web-fake-transport
Advanced tools
Fake Transport for use with @improbable-eng/grpc-web
Readme
Fake Transport for use with @improbable-eng/grpc-web.
FakeTransportBuilder
builds a Transport
that can be configured to send preset headers, messages, and trailers for testing.
By default the Transport
that FakeTranportBuilder.build()
generates will trigger all of the specified response behaviours (.withHeaders(metadata)
, .withMessages([msgOne, msgTwo])
, .withTrailers(metadata)
) when the client has finished sending.
This is usually the desired flow as all of the response behaviour is triggered only after the client has finished sending as would most commonly occur in production usage.
However, in the case of bi-directional or other complex usage it can be helpful to use .withManualTrigger()
to disable automatic sending of messages or headers/trailers and trigger the sending manually using sendHeaders()
, sendMessages()
and sendTrailers()
.
import { FakeTransportBuilder } from '@improbable-eng/grpc-web-fake-transport';
const fakeTransport = new FakeTransportBuilder()
.withMessages([ new PingResponse() ])
.build();
const client = new PingServiceClient("https://example.com", {
transport: fakeTransport
});
client.DoPing(/* ... */);
import { grpc } from '@improbable-eng/grpc-web';
import { FakeTransportBuilder } from '@improbable-eng/grpc-web-fake-transport';
const fakeTransport = new FakeTransportBuilder()
.withMessages([ new PingResponse() ])
.build();
grpc.invoke(PingService.DoPing, {
host: "https://example.com",
transport: fakeTransport,
/* ... */
});
withManualTrigger()
import { grpc } from '@improbable-eng/grpc-web';
import { FakeTransportBuilder } from '@improbable-eng/grpc-web-fake-transport';
const fakeTransport = new FakeTransportBuilder()
.withManualTrigger()
.withHeaders(new grpc.Metadata({ headerKey: "value" }))
.withMessages([ new PingResponse() ])
.withTrailers(new grpc.Metadata({ trailerKey: "value" }))
.build();
grpc.invoke(PingService.DoPing, {
host: "https://example.com",
transport: fakeTransport,
/* ... */
});
// Manually trigger the response behaviours
fakeTransport.sendHeaders();
fakeTransport.sendMessages();
fakeTransport.sendTrailers();
Alternatively replace the Default Transport when initialising your tests:
import { grpc } from "@improbable-eng/grpc-web";
import { NodeHttpTransport } from "@improbable-eng/grpc-web-fake-transport";
// Do this first, before you make any grpc requests!
grpc.setDefaultTransport(fakeTransport);
FAQs
Fake Transport for use with @improbable-eng/grpc-web
The npm package @improbable-eng/grpc-web-fake-transport receives a total of 457 weekly downloads. As such, @improbable-eng/grpc-web-fake-transport popularity was classified as not popular.
We found that @improbable-eng/grpc-web-fake-transport demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.