First release of open core

This commit is contained in:
t
2026-04-02 10:57:36 -04:00
parent 1c94f12d1c
commit 084c1321fc
101 changed files with 8812 additions and 17 deletions

30
pkg/admin/helpers_test.go Normal file
View File

@@ -0,0 +1,30 @@
package admin
import (
"context"
"database/sql"
"net/http"
"testing"
"time"
"epigas.gitea.cloud/RiskRancher/core/pkg/datastore"
"epigas.gitea.cloud/RiskRancher/core/pkg/domain"
)
// setupTestAdmin returns the clean Admin Handler and the raw DB
func setupTestAdmin(t *testing.T) (*Handler, *sql.DB) {
db := datastore.InitDB(":memory:")
store := datastore.NewSQLiteStore(db)
return NewHandler(store), db
}
// GetVIPCookie creates a dummy Sheriff user to bypass the Bouncer in tests
func GetVIPCookie(store domain.Store) *http.Cookie {
user, err := store.GetUserByEmail(context.Background(), "vip_test@RiskRancher.com")
if err != nil {
user, _ = store.CreateUser(context.Background(), "vip_test@RiskRancher.com", "Test VIP", "hash", "Sheriff")
}
token := "vip_test_token_999"
store.CreateSession(context.Background(), token, user.ID, time.Now().Add(1*time.Hour))
return &http.Cookie{Name: "session_token", Value: token}
}