(t *testing.T)
| 491 | } |
| 492 | |
| 493 | func TestAPIKey_SetDefault(t *testing.T) { |
| 494 | t.Parallel() |
| 495 | |
| 496 | db, pubsub := dbtestutil.NewDB(t) |
| 497 | dc := coderdtest.DeploymentValues(t) |
| 498 | dc.Sessions.DefaultTokenDuration = serpent.Duration(time.Hour * 12) |
| 499 | client := coderdtest.New(t, &coderdtest.Options{ |
| 500 | Database: db, |
| 501 | Pubsub: pubsub, |
| 502 | DeploymentValues: dc, |
| 503 | }) |
| 504 | owner := coderdtest.CreateFirstUser(t, client) |
| 505 | |
| 506 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 507 | defer cancel() |
| 508 | |
| 509 | token, err := client.CreateAPIKey(ctx, owner.UserID.String()) |
| 510 | require.NoError(t, err) |
| 511 | split := strings.Split(token.Key, "-") |
| 512 | apiKey1, err := db.GetAPIKeyByID(ctx, split[0]) |
| 513 | require.NoError(t, err) |
| 514 | require.EqualValues(t, dc.Sessions.DefaultTokenDuration.Value().Seconds(), apiKey1.LifetimeSeconds) |
| 515 | } |
| 516 | |
| 517 | func TestAPIKey_PrebuildsNotAllowed(t *testing.T) { |
| 518 | t.Parallel() |
nothing calls this directly
no test coverage detected