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

Function TestDefaultCredentialsWithOptions

credentials/google/google_test.go:183–268  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func TestDefaultCredentialsWithOptions(t *testing.T) {
184 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
185 defer cancel()
186 md1 := map[string]string{"foo": "tls"}
187 md2 := map[string]string{"foo": "alts"}
188 tests := []struct {
189 desc string
190 defaultCredsOpts DefaultCredentialsOptions
191 authInfo credentials.AuthInfo
192 wantedMetadata map[string]string
193 }{
194 {
195 desc: "no ALTSPerRPCCreds with tls channel",
196 defaultCredsOpts: DefaultCredentialsOptions{
197 PerRPCCreds: &testPerRPCCreds{
198 md: md1,
199 },
200 },
201 authInfo: &testAuthInfo{typ: "tls"},
202 wantedMetadata: md1,
203 },
204 {
205 desc: "no ALTSPerRPCCreds with alts channel",
206 defaultCredsOpts: DefaultCredentialsOptions{
207 PerRPCCreds: &testPerRPCCreds{
208 md: md1,
209 },
210 },
211 authInfo: &testAuthInfo{typ: "alts"},
212 wantedMetadata: md1,
213 },
214 {
215 desc: "ALTSPerRPCCreds specified with tls channel",
216 defaultCredsOpts: DefaultCredentialsOptions{
217 PerRPCCreds: &testPerRPCCreds{
218 md: md1,
219 },
220 ALTSPerRPCCreds: &testPerRPCCreds{
221 md: md2,
222 },
223 },
224 authInfo: &testAuthInfo{typ: "tls"},
225 wantedMetadata: md1,
226 },
227 {
228 desc: "ALTSPerRPCCreds specified with alts channel",
229 defaultCredsOpts: DefaultCredentialsOptions{
230 PerRPCCreds: &testPerRPCCreds{
231 md: md1,
232 },
233 ALTSPerRPCCreds: &testPerRPCCreds{
234 md: md2,
235 },
236 },
237 authInfo: &testAuthInfo{typ: "alts"},
238 wantedMetadata: md2,
239 },
240 {

Callers

nothing calls this directly

Calls 5

GetRequestMetadataMethod · 0.65
PerRPCCredentialsMethod · 0.65
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected