aboutsummaryrefslogtreecommitdiff
path: root/netty
diff options
context:
space:
mode:
authorEric Anderson <ejona@google.com>2018-05-02 09:02:00 -0700
committerEric Anderson <ejona@google.com>2018-05-24 09:51:45 -0700
commite41e0547769f7ac1b56b9200e9000dc1282f9f08 (patch)
treec1d736f0d23727059e1110e53b8cc982afd7d3fa /netty
parent27439876f28858b3293bc0f790d091b5eba36245 (diff)
downloadgrpc-grpc-java-e41e0547769f7ac1b56b9200e9000dc1282f9f08.tar.gz
Propagate CallCredentials.ATTR_SECURITY_LEVEL from transports
Previously no transport provided the key so CallCredentials would always see the security as NONE.
Diffstat (limited to 'netty')
-rw-r--r--netty/src/main/java/io/grpc/netty/NettyClientTransport.java3
-rw-r--r--netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java5
-rw-r--r--netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java11
3 files changed, 8 insertions, 11 deletions
diff --git a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
index a5aa771a2..7fbc1607d 100644
--- a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
+++ b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
@@ -313,8 +313,7 @@ class NettyClientTransport implements ConnectionClientTransport {
@Override
public Attributes getAttributes() {
- // TODO(zhangkun83): fill channel security attributes
- return Attributes.EMPTY;
+ return handler.getAttributes();
}
@Override
diff --git a/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java b/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
index 93d58e7aa..a9245faf0 100644
--- a/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
+++ b/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
@@ -22,8 +22,10 @@ import static io.grpc.netty.GrpcSslContexts.NEXT_PROTOCOL_VERSIONS;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import io.grpc.Attributes;
+import io.grpc.CallCredentials;
import io.grpc.Grpc;
import io.grpc.Internal;
+import io.grpc.SecurityLevel;
import io.grpc.Status;
import io.grpc.internal.Channelz;
import io.grpc.internal.GrpcUtil;
@@ -645,6 +647,7 @@ public final class ProtocolNegotiators {
Attributes.newBuilder()
.set(Grpc.TRANSPORT_ATTR_SSL_SESSION, session)
.set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
+ .set(CallCredentials.ATTR_SECURITY_LEVEL, SecurityLevel.PRIVACY_AND_INTEGRITY)
.build(),
new Channelz.Security(new Channelz.Tls(session)));
writeBufferedAndRemove(ctx);
@@ -692,6 +695,7 @@ public final class ProtocolNegotiators {
Attributes
.newBuilder()
.set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
+ .set(CallCredentials.ATTR_SECURITY_LEVEL, SecurityLevel.NONE)
.build(),
/*securityInfo=*/ null);
super.channelActive(ctx);
@@ -734,6 +738,7 @@ public final class ProtocolNegotiators {
Attributes
.newBuilder()
.set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
+ .set(CallCredentials.ATTR_SECURITY_LEVEL, SecurityLevel.NONE)
.build(),
/*securityInfo=*/ null);
} else if (evt == HttpClientUpgradeHandler.UpgradeEvent.UPGRADE_REJECTED) {
diff --git a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java
index 83687e33f..56320bbe2 100644
--- a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java
+++ b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java
@@ -503,17 +503,10 @@ public class NettyClientTransportTest {
address = TestUtils.testServerAddress(12345);
authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
- NettyClientTransport transport = newTransport(
- new ProtocolNegotiator() {
- @Override
- public Handler newHandler(GrpcHttp2ConnectionHandler handler) {
- return null;
- }
- });
+ NettyClientTransport transport = newTransport(new NoopProtocolNegotiator());
+ callMeMaybe(transport.start(clientTransportListener));
assertEquals(Attributes.EMPTY, transport.getAttributes());
-
- transports.clear();
}
@Test