1
0
forked from baron/baron-sso

테넌트 접속 제한 백엔드 로직 수정

This commit is contained in:
2026-04-28 09:55:37 +09:00
parent 3f85f6cfe3
commit 367368805a
6 changed files with 107 additions and 61 deletions

View File

@@ -29,7 +29,7 @@ func NewClientConsentRepository(db *gorm.DB) ClientConsentRepository {
func (r *clientConsentRepo) Find(ctx context.Context, clientID, subject string) (*domain.ClientConsent, error) {
var consent domain.ClientConsent
err := r.db.WithContext(ctx).Unscoped().
err := r.db.WithContext(ctx).
Where("client_id = ? AND subject = ?", clientID, subject).
First(&consent).Error
if err != nil {

View File

@@ -0,0 +1,31 @@
package repository
import (
"baron-sso-backend/internal/domain"
"context"
"testing"
"github.com/lib/pq"
"github.com/stretchr/testify/assert"
)
func TestClientConsentRepository_Find_IgnoresSoftDeletedConsent(t *testing.T) {
repo := NewClientConsentRepository(testDB)
ctx := context.Background()
consent := &domain.ClientConsent{
ClientID: "client-soft-delete",
Subject: "user-soft-delete",
GrantedScopes: pq.StringArray{"openid", "profile"},
}
err := repo.Upsert(ctx, consent)
assert.NoError(t, err)
err = repo.Delete(ctx, consent.Subject, consent.ClientID)
assert.NoError(t, err)
found, err := repo.Find(ctx, consent.ClientID, consent.Subject)
assert.NoError(t, err)
assert.Nil(t, found)
}