- Added a new blueprint for password recovery (`05-ulti-recovery.yaml`) to facilitate user password reset via email. - Introduced a new API handler for managing Authentik flow sessions, including starting and responding to flows. - Implemented flow session management with in-memory storage for tracking user sessions during the recovery process. - Enhanced error handling for flow session operations and added unit tests for the new functionalities. - Updated README to include the new recovery flow in the Authentik blueprints documentation.
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package authentik
|
|
|
|
import (
|
|
"context"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestFlowExecutorGetChallenge(t *testing.T) {
|
|
t.Parallel()
|
|
// Smoke test structure only — integration tests hit real Authentik.
|
|
fe, err := NewFlowExecutor("http://localhost:9000", "test-flow")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if fe.slug != "test-flow" {
|
|
t.Fatalf("slug = %q", fe.slug)
|
|
}
|
|
}
|
|
|
|
func TestFlowDone(t *testing.T) {
|
|
t.Parallel()
|
|
done, denied := FlowDone(FlowChallenge{"component": "xak-flow-redirect"})
|
|
if !done || denied {
|
|
t.Fatalf("redirect: done=%v denied=%v", done, denied)
|
|
}
|
|
done, denied = FlowDone(FlowChallenge{"component": "ak-stage-access-denied"})
|
|
if !done || !denied {
|
|
t.Fatalf("denied: done=%v denied=%v", done, denied)
|
|
}
|
|
done, denied = FlowDone(FlowChallenge{"component": "ak-stage-prompt"})
|
|
if done || denied {
|
|
t.Fatalf("prompt: done=%v denied=%v", done, denied)
|
|
}
|
|
}
|
|
|
|
func TestFlowSessionStoreLifecycle(t *testing.T) {
|
|
t.Parallel()
|
|
store := NewFlowSessionStore("http://127.0.0.1:1")
|
|
_, err := store.Respond(context.Background(), "missing", "ulti-enrollment", "", map[string]any{"component": "x"})
|
|
if err != ErrFlowSessionNotFound {
|
|
t.Fatalf("expected ErrFlowSessionNotFound, got %v", err)
|
|
}
|
|
_ = httptest.NewRecorder()
|
|
}
|