feat: authsession service

This commit is contained in:
Ilia Denisov
2026-04-08 16:23:07 +02:00
committed by GitHub
parent 28f04916af
commit 86a68ed9d0
174 changed files with 31732 additions and 112 deletions
@@ -0,0 +1,48 @@
package testkit
import (
"context"
"errors"
"testing"
"galaxy/authsession/internal/domain/common"
"galaxy/authsession/internal/domain/gatewayprojection"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRecordingProjectionPublisherConsumesScriptedErrorsAndRecordsAttempts(t *testing.T) {
t.Parallel()
publisher := &RecordingProjectionPublisher{
Errors: []error{errors.New("first publish failed"), nil},
}
snapshot := projectionSnapshotFixture()
err := publisher.PublishSession(context.Background(), snapshot)
require.Error(t, err)
err = publisher.PublishSession(context.Background(), snapshot)
require.NoError(t, err)
published := publisher.PublishedSnapshots()
require.Len(t, published, 2)
assert.Equal(t, snapshot.DeviceSessionID, published[0].DeviceSessionID)
assert.Equal(t, snapshot.DeviceSessionID, published[1].DeviceSessionID)
published[0].ClientPublicKey = "mutated"
stable := publisher.PublishedSnapshots()
require.Len(t, stable, 2)
assert.Equal(t, snapshot.ClientPublicKey, stable[0].ClientPublicKey)
}
func projectionSnapshotFixture() gatewayprojection.Snapshot {
return gatewayprojection.Snapshot{
DeviceSessionID: common.DeviceSessionID("device-session-1"),
UserID: common.UserID("user-1"),
ClientPublicKey: "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
Status: gatewayprojection.StatusActive,
}
}