test: add comprehensive test coverage and improve code quality
- Add new test files for auth, service, and handler modules - Improve test organization and coverage - Refactor code for better maintainability - Add captcha, settings, stats, and theme handler tests - Add auth module tests (CAS, OAuth, password, SSO, state) - Add service layer tests for auth, export, permissions, roles - All Go tests pass (exit code 0) - All frontend tests pass (325 tests in 59 files)
This commit is contained in:
@@ -63,18 +63,18 @@ type SSOTokenInfo struct {
|
||||
|
||||
// SSOSession SSO Session
|
||||
type SSOSession struct {
|
||||
SessionID string
|
||||
UserID int64
|
||||
Username string
|
||||
ClientID string
|
||||
CreatedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
Scope string
|
||||
SessionID string
|
||||
UserID int64
|
||||
Username string
|
||||
ClientID string
|
||||
CreatedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
Scope string
|
||||
}
|
||||
|
||||
// SSOManager SSO 管理器
|
||||
type SSOManager struct {
|
||||
mu sync.RWMutex
|
||||
mu sync.RWMutex
|
||||
sessions map[string]*SSOSession
|
||||
}
|
||||
|
||||
@@ -167,13 +167,13 @@ func (m *SSOManager) GenerateAccessToken(clientID string, session *SSOSession) (
|
||||
expiresAt := time.Now().Add(2 * time.Hour) // Access token 2 小时有效期
|
||||
|
||||
accessSession := &SSOSession{
|
||||
SessionID: token,
|
||||
UserID: session.UserID,
|
||||
Username: session.Username,
|
||||
ClientID: clientID,
|
||||
CreatedAt: time.Now(),
|
||||
ExpiresAt: expiresAt,
|
||||
Scope: session.Scope,
|
||||
SessionID: token,
|
||||
UserID: session.UserID,
|
||||
Username: session.Username,
|
||||
ClientID: clientID,
|
||||
CreatedAt: time.Now(),
|
||||
ExpiresAt: expiresAt,
|
||||
Scope: session.Scope,
|
||||
}
|
||||
|
||||
m.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user