| 486 | } |
| 487 | |
| 488 | func ObfuscatedSubjectManagerTest(t *testing.T, deps Deps, m consent.ObfuscatedSubjectManager, clientManager client.Manager) { |
| 489 | t.Run("get with random keys", func(t *testing.T) { |
| 490 | _, err := m.GetForcedObfuscatedLoginSession(t.Context(), uuidx.NewV4().String(), uuidx.NewV4().String()) |
| 491 | assert.ErrorIs(t, err, x.ErrNotFound) |
| 492 | }) |
| 493 | |
| 494 | t.Run("create and retrieve", func(t *testing.T) { |
| 495 | cl := &client.Client{ID: uuidx.NewV4().String()} |
| 496 | require.NoError(t, clientManager.CreateClient(t.Context(), cl)) |
| 497 | obfuscatedSession := &consent.ForcedObfuscatedLoginSession{ |
| 498 | ClientID: cl.ID, |
| 499 | Subject: uuidx.NewV4().String(), |
| 500 | SubjectObfuscated: uuidx.NewV4().String(), |
| 501 | NID: deps.Networker().NetworkID(t.Context()), |
| 502 | } |
| 503 | require.NoError(t, m.CreateForcedObfuscatedLoginSession(t.Context(), obfuscatedSession)) |
| 504 | |
| 505 | actual, err := m.GetForcedObfuscatedLoginSession(t.Context(), cl.ID, obfuscatedSession.SubjectObfuscated) |
| 506 | require.NoError(t, err) |
| 507 | assert.EqualValues(t, obfuscatedSession, actual) |
| 508 | |
| 509 | t.Run("with random client fails", func(t *testing.T) { |
| 510 | _, err = m.GetForcedObfuscatedLoginSession(t.Context(), uuidx.NewV4().String(), obfuscatedSession.SubjectObfuscated) |
| 511 | assert.ErrorIs(t, err, x.ErrNotFound) |
| 512 | }) |
| 513 | |
| 514 | t.Run("with random obfuscated subject fails", func(t *testing.T) { |
| 515 | _, err = m.GetForcedObfuscatedLoginSession(t.Context(), cl.ID, uuidx.NewV4().String()) |
| 516 | assert.ErrorIs(t, err, x.ErrNotFound) |
| 517 | }) |
| 518 | }) |
| 519 | } |
| 520 | |
| 521 | func LogoutManagerTest(t *testing.T, m consent.LogoutManager, clientManager client.Manager) { |
| 522 | for _, withClient := range []bool{true, false} { |