Documentation
¶
Index ¶
- func CreateOrgProjectAndAssetAssetVersion(db shared.DB) (models.Org, models.Project, models.Asset, models.AssetVersion)
- func InitDatabaseContainer(initDBSQLPath string) (shared.DB, func())
- func InitSQLDatabaseContainer(initDBSQLPath string) (string, string, string, string, string, func())
- func NewContext(r *http.Request, w http.ResponseWriter) shared.Context
- func ReaderFromAny(v any) io.Reader
- func WithTestApp(t *testing.T, sqlInitFile string, testFn func(*TestFixture))
- func WithTestAppOptions(t *testing.T, sqlInitFile string, options TestAppOptions, ...)
- type SessionMock
- type TestApp
- type TestAppOptions
- type TestFixture
- func (f *TestFixture) CreateAsset(projectID uuid.UUID, name string) models.Asset
- func (f *TestFixture) CreateAssetVersion(assetID uuid.UUID, name string, isDefault bool) models.AssetVersion
- func (f *TestFixture) CreateDaemonRunner() daemons.DaemonRunner
- func (f *TestFixture) CreateOrg(name string) models.Org
- func (f *TestFixture) CreateOrgProjectAssetAndVersion() (models.Org, models.Project, models.Asset, models.AssetVersion)
- func (f *TestFixture) CreateProject(orgID uuid.UUID, name string) models.Project
- type TestGitlabClientFactory
- func (f TestGitlabClientFactory) FromAccessToken(accessToken string, baseURL string) (shared.GitlabClientFacade, error)
- func (f TestGitlabClientFactory) FromIntegration(integration models.GitLabIntegration) (shared.GitlabClientFacade, error)
- func (f TestGitlabClientFactory) FromIntegrationUUID(id uuid.UUID) (shared.GitlabClientFacade, error)
- func (f TestGitlabClientFactory) FromOauth2Token(token models.GitLabOauth2Token, enableClientCache bool) (shared.GitlabClientFacade, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitDatabaseContainer ¶
func InitSQLDatabaseContainer ¶
func InitSQLDatabaseContainer(initDBSQLPath string) (string, string, string, string, string, func())
InitSQLDatabaseContainer initializes a test database container and returns the underlying SQL DB and connection string instead of GORM DB. Useful for components that need direct SQL access.
func NewContext ¶
func ReaderFromAny ¶
func WithTestApp ¶
func WithTestApp(t *testing.T, sqlInitFile string, testFn func(*TestFixture))
WithTestApp provides a callback-based pattern for tests
func WithTestAppOptions ¶
func WithTestAppOptions(t *testing.T, sqlInitFile string, options TestAppOptions, testFn func(*TestFixture))
Types ¶
type SessionMock ¶
func NewSessionMock ¶
func NewSessionMock(userID string) SessionMock
func (SessionMock) GetScopes ¶
func (s SessionMock) GetScopes() []string
func (SessionMock) GetUserID ¶
func (s SessionMock) GetUserID() string
type TestApp ¶
type TestApp struct {
fx.In
// Core infrastructure
DB shared.DB
Broker database.Broker
// Services
ConfigService shared.ConfigService
LicenseRiskService shared.LicenseRiskService
StatisticsService shared.StatisticsService
ComponentService shared.ComponentService
FirstPartyVulnService shared.FirstPartyVulnService
DependencyVulnService shared.DependencyVulnService
ArtifactService shared.ArtifactService
AssetVersionService shared.AssetVersionService
AssetService shared.AssetService
ProjectService shared.ProjectService
OrgService shared.OrgService
ScanService shared.ScanService
CSAFService shared.CSAFService
ReleaseService shared.ReleaseService
OpenSourceInsightService shared.OpenSourceInsightService
// Controllers
AssetController *controllers.AssetController
AssetVersionController *controllers.AssetVersionController
ScanController *controllers.ScanController
ProjectController *controllers.ProjectController
OrgController *controllers.OrgController
DependencyVulnController *controllers.DependencyVulnController
FirstPartyVulnController *controllers.FirstPartyVulnController
ComponentController *controllers.ComponentController
ArtifactController *controllers.ArtifactController
CSAFController *controllers.CSAFController
// Repositories
AssetRepository shared.AssetRepository
AssetVersionRepository shared.AssetVersionRepository
ComponentRepository shared.ComponentRepository
DependencyVulnRepository shared.DependencyVulnRepository
FirstPartyVulnRepository shared.FirstPartyVulnRepository
CveRepository shared.CveRepository
CweRepository shared.CweRepository
ExploitRepository shared.ExploitRepository
AffectedComponentRepository shared.AffectedComponentRepository
ProjectRepository shared.ProjectRepository
OrgRepository shared.OrganizationRepository
ArtifactRepository shared.ArtifactRepository
VulnEventRepository shared.VulnEventRepository
ComponentProjectRepository shared.ComponentProjectRepository
StatisticsRepository shared.StatisticsRepository
LicenseRiskRepository shared.LicenseRiskRepository
GitLabOauth2TokenRepository shared.GitLabOauth2TokenRepository
GitlabIntegrationRepository shared.GitlabIntegrationRepository
ExternalUserRepository shared.ExternalUserRepository
AggregatedVulnRepository shared.VulnRepository
// Access Control
RBACProvider shared.RBACProvider
// Integrations
GitlabIntegration *gitlabint.GitlabIntegration
IntegrationAggregate shared.IntegrationAggregate
}
TestApp provides access to all services and controllers via FX
func NewTestApp ¶
NewTestApp creates a test application with all dependencies wired via FX It uses the same FX modules as production for consistency
func NewTestAppWithT ¶
NewTestAppWithT creates a test application tied to a testing.T It automatically stops the app when the test completes
type TestAppOptions ¶
type TestAppOptions struct {
// Additional FX options to include
ExtraOptions []fx.Option
// Whether to suppress FX logging
SuppressLogs bool
// Custom broker (if nil, a default in-memory broker will be provided)
Broker database.Broker
}
TestAppOptions configures the test application
type TestFixture ¶
TestFixture provides a complete test environment with database and FX app
func NewTestFixture ¶
func NewTestFixture(t *testing.T, sqlInitFile string, options *TestAppOptions) *TestFixture
NewTestFixture creates a complete test environment with database container and FX app
func (*TestFixture) CreateAsset ¶
CreateAsset creates a test asset
func (*TestFixture) CreateAssetVersion ¶
func (f *TestFixture) CreateAssetVersion(assetID uuid.UUID, name string, isDefault bool) models.AssetVersion
CreateAssetVersion creates a test asset version
func (*TestFixture) CreateDaemonRunner ¶
func (f *TestFixture) CreateDaemonRunner() daemons.DaemonRunner
CreateDaemonRunner creates a DaemonRunner instance with all dependencies from the test app
func (*TestFixture) CreateOrg ¶
func (f *TestFixture) CreateOrg(name string) models.Org
CreateOrg creates a test organization
func (*TestFixture) CreateOrgProjectAssetAndVersion ¶
func (f *TestFixture) CreateOrgProjectAssetAndVersion() (models.Org, models.Project, models.Asset, models.AssetVersion)
CreateOrgProjectAssetAndVersion creates a full test hierarchy using FX services
func (*TestFixture) CreateProject ¶
CreateProject creates a test project
type TestGitlabClientFactory ¶
type TestGitlabClientFactory struct {
*mocks.GitlabClientFacade
}
func NewTestClientFactory ¶
func NewTestClientFactory(t *testing.T) (TestGitlabClientFactory, *mocks.GitlabClientFacade)
func (TestGitlabClientFactory) FromAccessToken ¶
func (f TestGitlabClientFactory) FromAccessToken(accessToken string, baseURL string) (shared.GitlabClientFacade, error)
func (TestGitlabClientFactory) FromIntegration ¶
func (f TestGitlabClientFactory) FromIntegration(integration models.GitLabIntegration) (shared.GitlabClientFacade, error)
func (TestGitlabClientFactory) FromIntegrationUUID ¶
func (f TestGitlabClientFactory) FromIntegrationUUID(id uuid.UUID) (shared.GitlabClientFacade, error)
func (TestGitlabClientFactory) FromOauth2Token ¶
func (f TestGitlabClientFactory) FromOauth2Token(token models.GitLabOauth2Token, enableClientCache bool) (shared.GitlabClientFacade, error)