mirror of
https://github.com/hanzoai/base.git
synced 2026-10-21 03:41:50 +00:00
Remove all _hz_ prefixes from collection IDs, internal markers, and test fixtures. The default users collection is now _users_auth_ instead of _hz_users_auth_. Internal SQL parser tokens renamed from __hz_join__/__hz_discard__ to __join__/__discard__. Backup prefix changed from @auto_hz_backup_ to @auto_backup_. Test database updated with correct collection IDs and indexes. JWT tokens in test files regenerated with new collection IDs. Add LogoURL field to MetaConfig so the admin UI logo is configurable via app settings instead of hardcoded. FullPage.svelte and App.svelte sidebar now read logo and app name from the settings store, falling back to defaults when not configured.
74 lines
2.6 KiB
Go
74 lines
2.6 KiB
Go
// Package tests provides test token helper functions.
|
|
package tests
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hanzoai/base/core"
|
|
)
|
|
|
|
// GetUserAuthToken returns a valid auth token for a test user in the given collection.
|
|
// This should be used in tests instead of hardcoded tokens.
|
|
func GetUserAuthToken(app core.App, collectionNameOrId, recordId string) (string, error) {
|
|
record, err := app.FindRecordById(collectionNameOrId, recordId)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return record.NewAuthToken()
|
|
}
|
|
|
|
// GetUserStaticAuthToken returns a long-lived static auth token for testing.
|
|
func GetUserStaticAuthToken(app core.App, collectionNameOrId, recordId string) (string, error) {
|
|
record, err := app.FindRecordById(collectionNameOrId, recordId)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return record.NewStaticAuthToken(86400 * 365 * 100 * time.Second) // 100 years
|
|
}
|
|
|
|
// GetUserVerificationToken returns a verification token for testing.
|
|
func GetUserVerificationToken(app core.App, collectionNameOrId, recordId string) (string, error) {
|
|
record, err := app.FindRecordById(collectionNameOrId, recordId)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return record.NewVerificationToken()
|
|
}
|
|
|
|
// GetUserPasswordResetToken returns a password reset token for testing.
|
|
func GetUserPasswordResetToken(app core.App, collectionNameOrId, recordId string) (string, error) {
|
|
record, err := app.FindRecordById(collectionNameOrId, recordId)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return record.NewPasswordResetToken()
|
|
}
|
|
|
|
// GetSuperuserAuthToken returns a valid auth token for a test superuser.
|
|
func GetSuperuserAuthToken(app core.App, recordId string) (string, error) {
|
|
return GetUserAuthToken(app, core.CollectionNameSuperusers, recordId)
|
|
}
|
|
|
|
// Common test record IDs (matching tests/data/data.db)
|
|
const (
|
|
// Users collection (_users_auth_)
|
|
TestUserID1 = "4q1xlclmfloku33" // [email protected]
|
|
TestUserID2 = "oap640cot4yru2s" // [email protected]
|
|
TestUserID3 = "bgs820n361vj1qd" // [email protected]
|
|
|
|
// Clients collection (v851q4r790rhknl)
|
|
TestClientID1 = "gk390qegs4y47wn" // [email protected]
|
|
TestClientID2 = "o1y0dd0spd786md" // [email protected]
|
|
|
|
// Nologin collection (kpv709sk2lqbqk8)
|
|
TestNologinID1 = "dc49k6jgejn40h3" // [email protected]
|
|
TestNologinID2 = "phhq3wr65cap535" // [email protected]
|
|
TestNologinID3 = "oos036e9xvqeexy" // [email protected]
|
|
|
|
// Superusers collection (hbc_3142635823)
|
|
TestSuperuserID1 = "sywbhecnh46rhm0" // [email protected]
|
|
TestSuperuserID2 = "sbmbsdb40jyxf7h" // [email protected]
|
|
TestSuperuserID3 = "9q2trqumvlyr3bd" // [email protected]
|
|
TestSuperuserID4 = "q911776rrfy658l" // [email protected]
|
|
)
|