mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add API key ID to interceptions (#20513)
Adds APIKeyID to interceptions. Needed for tracking API key usage with bridge. fixes https://github.com/coder/coder/issues/20001
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package coderd_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
@@ -101,7 +102,9 @@ func TestAIBridgeListInterceptions(t *testing.T) {
|
||||
|
||||
// Insert a bunch of test data.
|
||||
now := dbtime.Now()
|
||||
i1ApiKey := sql.NullString{String: "some-api-key", Valid: true}
|
||||
i1 := dbgen.AIBridgeInterception(t, db, database.InsertAIBridgeInterceptionParams{
|
||||
APIKeyID: i1ApiKey,
|
||||
InitiatorID: user1.ID,
|
||||
StartedAt: now.Add(-time.Hour),
|
||||
}, nil)
|
||||
@@ -146,6 +149,9 @@ func TestAIBridgeListInterceptions(t *testing.T) {
|
||||
require.Equal(t, i2SDK.ID, res.Results[0].ID)
|
||||
require.Equal(t, i1SDK.ID, res.Results[1].ID)
|
||||
|
||||
require.Equal(t, &i1ApiKey.String, i1SDK.APIKeyID)
|
||||
require.Nil(t, i2SDK.APIKeyID)
|
||||
|
||||
// Normalize timestamps in the response so we can compare the whole
|
||||
// thing easily.
|
||||
res.Results[0].StartedAt = i2SDK.StartedAt
|
||||
|
||||
Reference in New Issue
Block a user