MCPcopy
hub / github.com/grpc/grpc-go / TestCustomAuthority

Method TestCustomAuthority

internal/resolver/dns/dns_resolver_test.go:1125–1228  ·  view source on GitHub ↗

Tests different cases for a user's dial target that specifies a non-empty authority (or Host field of the URL).

(t *testing.T)

Source from the content-addressed store, hash-verified

1123// Tests different cases for a user's dial target that specifies a non-empty
1124// authority (or Host field of the URL).
1125func (s) TestCustomAuthority(t *testing.T) {
1126 tests := []struct {
1127 name string
1128 authority string
1129 wantAuthority string
1130 wantBuildErr bool
1131 }{
1132 {
1133 name: "authority with default DNS port",
1134 authority: "4.3.2.1:53",
1135 wantAuthority: "4.3.2.1:53",
1136 },
1137 {
1138 name: "authority with non-default DNS port",
1139 authority: "4.3.2.1:123",
1140 wantAuthority: "4.3.2.1:123",
1141 },
1142 {
1143 name: "authority with no port",
1144 authority: "4.3.2.1",
1145 wantAuthority: "4.3.2.1:53",
1146 },
1147 {
1148 name: "ipv6 authority with brackets and no port",
1149 authority: "[::1]",
1150 wantAuthority: "[::1]:53",
1151 },
1152 {
1153 name: "ipv6 authority with brackets and non-default DNS port",
1154 authority: "[::1]:123",
1155 wantAuthority: "[::1]:123",
1156 },
1157 {
1158 name: "host name with no port",
1159 authority: "dnsserver.com",
1160 wantAuthority: "dnsserver.com:53",
1161 },
1162 {
1163 name: "no host port and non-default port",
1164 authority: ":123",
1165 wantAuthority: "localhost:123",
1166 },
1167 {
1168 name: "only colon",
1169 authority: ":",
1170 wantAuthority: "",
1171 wantBuildErr: true,
1172 },
1173 {
1174 name: "ipv6 name ending in colon",
1175 authority: "[::1]:",
1176 wantAuthority: "",
1177 wantBuildErr: true,
1178 },
1179 {
1180 name: "host name ending in colon",
1181 authority: "dnsserver.com:",
1182 wantAuthority: "",

Callers

nothing calls this directly

Calls 8

GetFunction · 0.92
MustParseURLFunction · 0.92
overrideTimeAfterFuncFunction · 0.85
ErrorfMethod · 0.65
FatalfMethod · 0.65
BuildMethod · 0.65
CloseMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected