integration

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package integration provides shared helpers for integration tests.

DD-AUTH-014: This package provides centralized DataStorage authentication helpers that automatically use ServiceAccount tokens from envtest, eliminating the need for each test to manually configure authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticatedDataStorageClients

type AuthenticatedDataStorageClients struct {
	// AuditClient is used by controllers for audit event emission
	// (BufferedStore, batch writes, automatic retries)
	AuditClient audit.DataStorageClient

	// OpenAPIClient is used by tests for direct DataStorage queries
	// (workflow searches, audit queries, etc.)
	OpenAPIClient *ogenclient.Client

	// HTTPClient is the underlying authenticated HTTP client
	// Can be used for custom HTTP requests if needed
	HTTPClient *http.Client
}

AuthenticatedDataStorageClients holds both the audit client and OpenAPI client with automatic ServiceAccount authentication (DD-AUTH-014).

Usage in integration test suite:

var dsClients *integration.AuthenticatedDataStorageClients

var _ = SynchronizedBeforeSuite(func() []byte {
    // Phase 1: Create ServiceAccount + start DataStorage
    authConfig, _ := infrastructure.CreateIntegrationServiceAccountWithDataStorageAccess(...)
    return []byte(authConfig.Token)
}, func(data []byte) {
    // Phase 2: Create authenticated clients
    token := string(data)
    dsClients = integration.NewAuthenticatedDataStorageClients(
        "http://localhost:18140",
        token,
        5*time.Second,
    )
})

func NewAuthenticatedDataStorageClients

func NewAuthenticatedDataStorageClients(baseURL, token string, timeout time.Duration) *AuthenticatedDataStorageClients

NewAuthenticatedDataStorageClients creates DataStorage clients with automatic ServiceAccount authentication via Bearer token (DD-AUTH-014).

This function centralizes authentication setup so that:

  • All DataStorage requests use the same ServiceAccount token
  • Tests don't need to manually configure authentication
  • Audit stores automatically use authenticated requests
  • Easy to reuse across all service integration tests

Parameters:

  • baseURL: DataStorage API URL (e.g., "http://localhost:18140")
  • token: ServiceAccount Bearer token from envtest (from Phase 1)
  • timeout: HTTP client timeout (e.g., 5*time.Second)

Returns:

  • AuthenticatedDataStorageClients with both audit and OpenAPI clients

Example:

dsClients := integration.NewAuthenticatedDataStorageClients(
    dataStorageBaseURL,
    token,  // from Phase 1
    5*time.Second,
)

// Use in controller setup
auditStore, _ := audit.NewBufferedStore(
    dsClients.AuditClient,  // ← Automatically authenticated
    auditConfig,
    "remediation-orchestrator",
    auditLogger,
)

// Use in tests for queries
workflows, _ := dsClients.OpenAPIClient.WorkflowSearch(ctx, ...)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL