(t *testing.T)
| 583 | ) |
| 584 | |
| 585 | func TestCanUseLegacyChallenges(t *testing.T) { |
| 586 | reg := testhelpers.NewRegistryMemory(t, |
| 587 | driver.WithConfigOptions( |
| 588 | configx.WithValue(config.KeyGetSystemSecret, []string{"well-known-fixture-secret"}), |
| 589 | configx.WithValue(config.KeyConsentRequestMaxAge, 100*365*24*time.Hour), // 100 years, effectively disabling expiration |
| 590 | ), |
| 591 | driver.WithServiceLocatorOptions(servicelocatorx.WithContextualizer(&contextx.Static{NID: legacyChallengesNID})), |
| 592 | ) |
| 593 | |
| 594 | require.NoError(t, fs.WalkDir(LegacyChallenges, "fixtures/legacy_challenges", func(path string, d fs.DirEntry, err error) error { |
| 595 | require.NoError(t, err) |
| 596 | if d.IsDir() { |
| 597 | return nil |
| 598 | } |
| 599 | t.Run(strings.TrimSuffix(d.Name(), ".txt"), func(t *testing.T) { |
| 600 | content, err := fs.ReadFile(LegacyChallenges, path) |
| 601 | require.NoError(t, err) |
| 602 | |
| 603 | var f *flow.Flow |
| 604 | switch { |
| 605 | case strings.Contains(d.Name(), "login"): |
| 606 | f, err = flow.DecodeFromLoginChallenge(t.Context(), reg, string(content)) |
| 607 | case strings.Contains(d.Name(), "consent"): |
| 608 | f, err = flow.DecodeFromConsentChallenge(t.Context(), reg, string(content)) |
| 609 | case strings.Contains(d.Name(), "device"): |
| 610 | f, err = flow.DecodeFromDeviceChallenge(t.Context(), reg, string(content)) |
| 611 | default: |
| 612 | t.Fatalf("unknown challenge type in file name: %s", d.Name()) |
| 613 | } |
| 614 | require.NoErrorf(t, err, "failed to decode challenge from file: %s\n%+v", d.Name(), errors.Unwrap(errors.Unwrap(err))) |
| 615 | |
| 616 | snapshotx.SnapshotT(t, f) |
| 617 | }) |
| 618 | return nil |
| 619 | })) |
| 620 | } |
| 621 | |
| 622 | func TestUpdateLegacyChallenges(t *testing.T) { |
| 623 | t.Skip("this test is used to update the fixtures only, they should not be updated unless we have a breaking change (so probably never)") |
nothing calls this directly
no test coverage detected