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

Method TestJWTFileReader_ReadToken_ValidToken

credentials/jwt/file_reader_test.go:125–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123}
124
125func (s) TestJWTFileReader_ReadToken_ValidToken(t *testing.T) {
126 now := time.Now().Truncate(time.Second)
127 tokenExp := now.Add(time.Hour)
128 token := createTestJWT(t, tokenExp)
129 tokenFile := writeTempFile(t, "token", token)
130
131 reader := jwtFileReader{tokenFilePath: tokenFile}
132 readToken, expiry, err := reader.readToken()
133 if err != nil {
134 t.Fatalf("ReadToken() unexpected error: %v", err)
135 }
136
137 if readToken != token {
138 t.Errorf("ReadToken() token = %q, want %q", readToken, token)
139 }
140
141 if !expiry.Equal(tokenExp) {
142 t.Errorf("ReadToken() expiry = %v, want %v", expiry, tokenExp)
143 }
144}
145
146// createInvalidJWT creates a JWT with invalid JSON in the payload.
147func createInvalidJWT(t *testing.T) string {

Callers

nothing calls this directly

Calls 8

readTokenMethod · 0.95
NowMethod · 0.80
createTestJWTFunction · 0.70
writeTempFileFunction · 0.70
AddMethod · 0.65
FatalfMethod · 0.65
ErrorfMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected