aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2015-07-23 20:28:42 -0700
committerGravatar Jan Tattermusch <jtattermusch@google.com>2015-07-24 14:51:59 -0700
commit062c329cf8afaa8479031c6d91124e1dc936feba (patch)
treee7bf5d5bc0951551cd185db4babe4293def4a010 /src/csharp/Grpc.Core.Tests/ClientServerTest.cs
parent6e685ff965c4069492e5deabdf6eeeb660b5a5cb (diff)
expose peer info in serverside call handlers
Diffstat (limited to 'src/csharp/Grpc.Core.Tests/ClientServerTest.cs')
-rw-r--r--src/csharp/Grpc.Core.Tests/ClientServerTest.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
index 8ba2c8a9a2..2536c00345 100644
--- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
@@ -45,7 +45,7 @@ namespace Grpc.Core.Tests
{
public class ClientServerTest
{
- const string Host = "localhost";
+ const string Host = "127.0.0.1";
const string ServiceName = "/tests.Test";
static readonly Method<string, string> EchoMethod = new Method<string, string>(
@@ -277,6 +277,14 @@ namespace Grpc.Core.Tests
Assert.IsTrue(userAgent.StartsWith("grpc-csharp/"));
}
+ [Test]
+ public void PeerInfoPresent()
+ {
+ var internalCall = new Call<string, string>(ServiceName, EchoMethod, channel, Metadata.Empty);
+ string peer = Calls.BlockingUnaryCall(internalCall, "RETURN-PEER", CancellationToken.None);
+ Assert.IsTrue(peer.Contains(Host));
+ }
+
private static async Task<string> EchoHandler(string request, ServerCallContext context)
{
foreach (Metadata.Entry metadataEntry in context.RequestHeaders)
@@ -292,6 +300,11 @@ namespace Grpc.Core.Tests
return context.RequestHeaders.Where(entry => entry.Key == "user-agent").Single().Value;
}
+ if (request == "RETURN-PEER")
+ {
+ return context.Peer;
+ }
+
if (request == "THROW")
{
throw new Exception("This was thrown on purpose by a test");