Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ public String getChannelExtendAttribute() {

@Override
public String toString() {
String extendAttributeSnapshot = this.extendAttribute;
return MoreObjects.toStringHelper(this)
.add("channelId", id())
.add("type", type)
.add("remoteProxyIp", remoteProxyIp)
.add("extendAttribute", extendAttribute)
.add("extendAttributePresent", extendAttributeSnapshot != null)
.add("extendAttributeLength", extendAttributeSnapshot == null ? 0 : extendAttributeSnapshot.length())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

public class RemoteChannelTest {

Expand All @@ -47,4 +49,22 @@ public void testEncodeAndDecode() {

assertNull(RemoteChannel.decode(""));
}
}

@Test
public void testToStringDoesNotExposeExtendAttribute() {
String extendAttribute = "sensitive-client-settings";
RemoteChannel remoteChannel = new RemoteChannel(
"11.193.0.1",
"10.152.39.53:9768",
"11.193.0.1:1210",
ChannelProtocolType.GRPC_V2,
extendAttribute
);

String output = remoteChannel.toString();

assertFalse(output.contains(extendAttribute));
assertTrue(output.contains("extendAttributePresent=true"));
assertTrue(output.contains("extendAttributeLength=" + extendAttribute.length()));
}
}
Loading