MCPcopy Index your code
hub / github.com/coder/coder / TestUserSetTokenDuration

Function TestUserSetTokenDuration

coderd/apikey_test.go:183–199  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func TestUserSetTokenDuration(t *testing.T) {
184 t.Parallel()
185
186 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
187 defer cancel()
188 client := coderdtest.New(t, nil)
189 _ = coderdtest.CreateFirstUser(t, client)
190
191 _, err := client.CreateToken(ctx, codersdk.Me, codersdk.CreateTokenRequest{
192 Lifetime: time.Hour * 24 * 7,
193 })
194 require.NoError(t, err)
195 keys, err := client.Tokens(ctx, codersdk.Me, codersdk.TokensFilter{})
196 require.NoError(t, err)
197 require.Greater(t, keys[0].ExpiresAt, dbtime.Now().Add(time.Hour*6*24))
198 require.Less(t, keys[0].ExpiresAt, dbtime.Now().Add(time.Hour*8*24))
199}
200
201func TestDefaultTokenDuration(t *testing.T) {
202 t.Parallel()

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
CreateFirstUserFunction · 0.92
NowFunction · 0.92
CreateTokenMethod · 0.80
TokensMethod · 0.80
LessMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected