Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- main

env:
GO_VERSION: 1.25.x
GO_VERSION: 1.26.x

jobs:
lint:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Remove updated_at column from auth_session table
ALTER TABLE auth_session DROP COLUMN updated_at;
3 changes: 3 additions & 0 deletions deploy/migrations/initial/011_auth_session_updated_at.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Add updated_at column to auth_session table
-- This column was missing despite having the updated_at_column() trigger
ALTER TABLE auth_session ADD COLUMN updated_at TIMESTAMP NOT NULL DEFAULT NOW();
13 changes: 8 additions & 5 deletions pkg/auth/oauth2/serverprovider/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ func (s *storageSuite) TestCreatePKCERequestSessionUpdatesExistingSession() {
s.Mock.ExpectQuery(`SELECT \* FROM "auth_session"`).
WithArgs(codeSig).
WillReturnRows(
sqlmock.NewRows([]string{"id", "request_id", "access_token", "form", "client_id", "username", "subject", "active", "access_token_expires_at", "refresh_token_expires_at", "created_at"}).
AddRow(rowID, requestID, codeSig, "existing=value", "mcp-client", "user", "subject", true, time.Now(), time.Now(), time.Now()),
sqlmock.NewRows([]string{"id", "request_id", "access_token", "form", "client_id", "username", "subject", "active", "access_token_expires_at", "refresh_token_expires_at", "created_at", "updated_at"}).
AddRow(rowID, requestID, codeSig, "existing=value", "mcp-client", "user", "subject", true, time.Now(), time.Now(), time.Now(), time.Now()),
)
// GORM automatically adds updated_at to the UPDATE statement
s.Mock.ExpectExec(`UPDATE "auth_session" SET`).
WithArgs(sqlmock.AnyArg(), rowID).
WithArgs(sqlmock.AnyArg(), sqlmock.AnyArg(), rowID).
WillReturnResult(sqlmock.NewResult(0, 1))

s.NoError(s.storage.CreatePKCERequestSession(ctx, codeSig, req))
s.NoError(s.Mock.ExpectationsWereMet())
}

func (s *storageSuite) TestCreateRefreshTokenSessionUpdatesByPrimaryKey() {
Expand All @@ -84,8 +86,9 @@ func (s *storageSuite) TestCreateRefreshTokenSessionUpdatesByPrimaryKey() {
sqlmock.NewRows([]string{"id", "request_id", "access_token"}).
AddRow(rowID, requestID, "access-sig"),
)
// GORM automatically adds updated_at to the UPDATE statement
s.Mock.ExpectExec(`UPDATE "auth_session" SET .*WHERE id=\$`).
WithArgs(requestID, "access-sig", "refresh-sig", sqlmock.AnyArg(), rowID, rowID).
WithArgs(requestID, "access-sig", "refresh-sig", sqlmock.AnyArg(), sqlmock.AnyArg(), rowID, rowID).
WillReturnResult(sqlmock.NewResult(0, 1))

err := s.storage.CreateRefreshTokenSession(NewContext(s.Ctx), "refresh-sig", "access-sig", req)
Expand All @@ -95,7 +98,7 @@ func (s *storageSuite) TestCreateRefreshTokenSessionUpdatesByPrimaryKey() {
func (s *storageSuite) expectAuthSessionInsert(accessToken, requestID string) {
var got []driver.Value
cap := captureArg{dst: &got}
args := make([]driver.Value, 16)
args := make([]driver.Value, 17) // 17 columns including updated_at
for i := range args {
args[i] = cap
}
Expand Down
1 change: 1 addition & 0 deletions repository/authclient/models/auth_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type AuthSession struct {
GrantedAudience gosql.NullableStringArray `db:"granted_audience" gorm:"type:text[]"`

CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DeletedAt gorm.DeletedAt `db:"deleted_at"`
}

Expand Down
Loading