MCPcopy
hub / github.com/ory/hydra / TestCanUseLegacyChallenges

Function TestCanUseLegacyChallenges

flow/flow_encoding_test.go:585–620  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

583)
584
585func 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
622func 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)")

Callers

nothing calls this directly

Calls 10

NewRegistryMemoryFunction · 0.92
WithConfigOptionsFunction · 0.92
DecodeFromLoginChallengeFunction · 0.92
IsDirMethod · 0.80
FatalfMethod · 0.80
UnwrapMethod · 0.80
NameMethod · 0.45

Tested by

no test coverage detected