diff --git a/pkg/appview/db/hold_store_test.go b/pkg/appview/db/hold_store_test.go index 1e6dedd..2eb7a6f 100644 --- a/pkg/appview/db/hold_store_test.go +++ b/pkg/appview/db/hold_store_test.go @@ -275,11 +275,11 @@ func TestUpsertCaptainRecord_Update(t *testing.T) { updatedRecord := &HoldCaptainRecord{ HoldDID: "did:web:hold04.atcr.io", // Same DID OwnerDID: "did:plc:eve222", // Changed owner - Public: true, // Changed to public - AllowAllCrew: true, // Changed allow all crew + Public: true, // Changed to public + AllowAllCrew: true, // Changed allow all crew DeployedAt: "2025-03-01", // Changed date Region: "ap-south-1", // Changed region - Provider: "azure", // Changed provider + Provider: "azure", // Changed provider UpdatedAt: time.Now(), } diff --git a/pkg/appview/storage/context_test.go b/pkg/appview/storage/context_test.go index 04e70fb..683450c 100644 --- a/pkg/appview/storage/context_test.go +++ b/pkg/appview/storage/context_test.go @@ -37,12 +37,12 @@ func (m *mockHoldAuthorizer) Authorize(holdDID, userDID, permission string) (boo func TestRegistryContext_Fields(t *testing.T) { // Create a sample RegistryContext ctx := &RegistryContext{ - DID: "did:plc:test123", - Handle: "alice.bsky.social", - HoldDID: "did:web:hold01.atcr.io", - PDSEndpoint: "https://bsky.social", - Repository: "debian", - ServiceToken: "test-token", + DID: "did:plc:test123", + Handle: "alice.bsky.social", + HoldDID: "did:web:hold01.atcr.io", + PDSEndpoint: "https://bsky.social", + Repository: "debian", + ServiceToken: "test-token", ATProtoClient: &atproto.Client{ // Mock client - would need proper initialization in real tests }, diff --git a/pkg/appview/storage/manifest_store_test.go b/pkg/appview/storage/manifest_store_test.go index bf5e9b9..77938db 100644 --- a/pkg/appview/storage/manifest_store_test.go +++ b/pkg/appview/storage/manifest_store_test.go @@ -544,9 +544,9 @@ func TestManifestStore_Get_HoldDIDTracking(t *testing.T) { ociManifest := []byte(`{"schemaVersion":2}`) tests := []struct { - name string - manifestResp string - expectedHoldDID string + name string + manifestResp string + expectedHoldDID string }{ { name: "tracks HoldDID from new format", diff --git a/pkg/auth/hold_local_test.go b/pkg/auth/hold_local_test.go index 9ad743c..c1f22fc 100644 --- a/pkg/auth/hold_local_test.go +++ b/pkg/auth/hold_local_test.go @@ -11,11 +11,11 @@ import ( // Shared PDS instances for read-only tests var ( - sharedEmptyPDS *pds.HoldPDS - sharedPublicPDS *pds.HoldPDS - sharedPrivatePDS *pds.HoldPDS - sharedAllowCrewPDS *pds.HoldPDS - sharedTempDir string + sharedEmptyPDS *pds.HoldPDS + sharedPublicPDS *pds.HoldPDS + sharedPrivatePDS *pds.HoldPDS + sharedAllowCrewPDS *pds.HoldPDS + sharedTempDir string ) // TestMain sets up shared test fixtures diff --git a/pkg/auth/hold_remote.go b/pkg/auth/hold_remote.go index 33b5671..2df51ce 100644 --- a/pkg/auth/hold_remote.go +++ b/pkg/auth/hold_remote.go @@ -20,16 +20,16 @@ import ( // Used by AppView to authorize access to remote holds // Implements caching for captain records to reduce XRPC calls type RemoteHoldAuthorizer struct { - db *sql.DB - httpClient *http.Client - cacheTTL time.Duration // TTL for captain record cache - recentDenials sync.Map // In-memory cache for first denials - stopCleanup chan struct{} // Signal to stop cleanup goroutine - testMode bool // If true, use HTTP for local DIDs - firstDenialBackoff time.Duration // Backoff duration for first denial (default: 10s) - cleanupInterval time.Duration // Cleanup goroutine interval (default: 10s) - cleanupGracePeriod time.Duration // Grace period before cleanup (default: 5s) - dbBackoffDurations []time.Duration // Backoff durations for DB denials (default: [1m, 5m, 15m, 1h]) + db *sql.DB + httpClient *http.Client + cacheTTL time.Duration // TTL for captain record cache + recentDenials sync.Map // In-memory cache for first denials + stopCleanup chan struct{} // Signal to stop cleanup goroutine + testMode bool // If true, use HTTP for local DIDs + firstDenialBackoff time.Duration // Backoff duration for first denial (default: 10s) + cleanupInterval time.Duration // Cleanup goroutine interval (default: 10s) + cleanupGracePeriod time.Duration // Grace period before cleanup (default: 5s) + dbBackoffDurations []time.Duration // Backoff durations for DB denials (default: [1m, 5m, 15m, 1h]) } // denialEntry stores timestamp for in-memory first denials @@ -40,9 +40,9 @@ type denialEntry struct { // NewRemoteHoldAuthorizer creates a new remote authorizer for AppView with production defaults func NewRemoteHoldAuthorizer(db *sql.DB, testMode bool) HoldAuthorizer { return NewRemoteHoldAuthorizerWithBackoffs(db, testMode, - 10*time.Second, // firstDenialBackoff - 10*time.Second, // cleanupInterval - 5*time.Second, // cleanupGracePeriod + 10*time.Second, // firstDenialBackoff + 10*time.Second, // cleanupInterval + 5*time.Second, // cleanupGracePeriod []time.Duration{ // dbBackoffDurations 1 * time.Minute, 5 * time.Minute, @@ -60,13 +60,13 @@ func NewRemoteHoldAuthorizerWithBackoffs(db *sql.DB, testMode bool, firstDenialB httpClient: &http.Client{ Timeout: 10 * time.Second, }, - cacheTTL: 1 * time.Hour, // 1 hour cache TTL - stopCleanup: make(chan struct{}), - testMode: testMode, - firstDenialBackoff: firstDenialBackoff, - cleanupInterval: cleanupInterval, - cleanupGracePeriod: cleanupGracePeriod, - dbBackoffDurations: dbBackoffDurations, + cacheTTL: 1 * time.Hour, // 1 hour cache TTL + stopCleanup: make(chan struct{}), + testMode: testMode, + firstDenialBackoff: firstDenialBackoff, + cleanupInterval: cleanupInterval, + cleanupGracePeriod: cleanupGracePeriod, + dbBackoffDurations: dbBackoffDurations, } // Start cleanup goroutine for in-memory denials diff --git a/pkg/auth/hold_remote_test.go b/pkg/auth/hold_remote_test.go index bbd42c3..ee2308f 100644 --- a/pkg/auth/hold_remote_test.go +++ b/pkg/auth/hold_remote_test.go @@ -288,11 +288,11 @@ func TestIsCrewMember_DenialBackoff_FirstDenial(t *testing.T) { // Create authorizer with fast backoffs for testing (10ms instead of 10s) remote := NewRemoteHoldAuthorizerWithBackoffs( testDB, - false, // testMode + false, // testMode 10*time.Millisecond, // firstDenialBackoff (10ms instead of 10s) 50*time.Millisecond, // cleanupInterval (50ms instead of 10s) 50*time.Millisecond, // cleanupGracePeriod (50ms instead of 5s) - []time.Duration{ // dbBackoffDurations (fast test values) + []time.Duration{ // dbBackoffDurations (fast test values) 10 * time.Millisecond, 20 * time.Millisecond, 30 * time.Millisecond, @@ -389,4 +389,3 @@ func TestCheckReadAccess_PublicHold(t *testing.T) { _ = server } - diff --git a/pkg/logging/logger_test.go b/pkg/logging/logger_test.go index 961f181..03b4e3f 100644 --- a/pkg/logging/logger_test.go +++ b/pkg/logging/logger_test.go @@ -49,12 +49,12 @@ func TestInitLogger(t *testing.T) { defer slog.SetDefault(originalLogger) tests := []struct { - name string - level string - shouldLogDebug bool - shouldLogInfo bool - shouldLogWarn bool - shouldLogError bool + name string + level string + shouldLogDebug bool + shouldLogInfo bool + shouldLogWarn bool + shouldLogError bool }{ { name: "debug level logs all",