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

Method TestGetRequestMetadataBadSecurityLevel

credentials/sts/sts_test.go:285–299  ·  view source on GitHub ↗

TestGetRequestMetadataBadSecurityLevel verifies the case where the securityLevel specified in the context passed to GetRequestMetadata is not sufficient.

(t *testing.T)

Source from the content-addressed store, hash-verified

283// securityLevel specified in the context passed to GetRequestMetadata is not
284// sufficient.
285func (s) TestGetRequestMetadataBadSecurityLevel(t *testing.T) {
286 defer overrideSubjectTokenGood()()
287
288 creds, err := NewCredentials(goodOptions)
289 if err != nil {
290 t.Fatalf("NewCredentials(%v) = %v", goodOptions, err)
291 }
292
293 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
294 defer cancel()
295 gotMetadata, err := creds.GetRequestMetadata(createTestContext(ctx, credentials.IntegrityOnly), "")
296 if err == nil {
297 t.Fatalf("creds.GetRequestMetadata() succeeded with metadata %v, expected to fail", gotMetadata)
298 }
299}
300
301// TestGetRequestMetadataCacheExpiry verifies the case where the cached access
302// token has expired, and the credentials implementation will have to send a

Callers

nothing calls this directly

Calls 5

overrideSubjectTokenGoodFunction · 0.85
createTestContextFunction · 0.85
NewCredentialsFunction · 0.70
FatalfMethod · 0.65
GetRequestMetadataMethod · 0.65

Tested by

no test coverage detected