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

Function TestValidateDynamicRegistration

client/validator_test.go:340–406  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

338}
339
340func TestValidateDynamicRegistration(t *testing.T) {
341 reg := testhelpers.NewRegistryMemory(t, driver.WithConfigOptions(configx.WithValues(map[string]any{
342 config.KeySubjectTypesSupported: []string{"pairwise", "public"},
343 config.KeyDefaultClientScope: []string{"openid"},
344 })))
345
346 v := NewValidator(reg)
347 for k, tc := range []struct {
348 in *Client
349 check func(t *testing.T, c *Client)
350 expectErr bool
351 v func(t *testing.T) *Validator
352 }{
353 {
354 in: &Client{
355 ID: "foo",
356 PostLogoutRedirectURIs: []string{"https://foo/"},
357 RedirectURIs: []string{"https://foo/"},
358 Metadata: []byte(`{"access_token_ttl":10}`),
359 },
360 expectErr: true,
361 },
362 {
363 in: &Client{
364 ID: "foo",
365 PostLogoutRedirectURIs: []string{"https://foo/"},
366 RedirectURIs: []string{"https://foo/"},
367 Metadata: []byte(`{"id_token_ttl":10}`),
368 },
369 expectErr: true,
370 },
371 {
372 in: &Client{
373 ID: "foo",
374 PostLogoutRedirectURIs: []string{"https://foo/"},
375 RedirectURIs: []string{"https://foo/"},
376 Metadata: []byte(`{"anything":10}`),
377 },
378 expectErr: true,
379 },
380 {
381 in: &Client{
382 ID: "foo",
383 PostLogoutRedirectURIs: []string{"https://foo/"},
384 RedirectURIs: []string{"https://foo/"},
385 },
386 check: func(t *testing.T, c *Client) {
387 assert.EqualValues(t, "foo", c.ID)
388 },
389 },
390 } {
391 t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
392 if tc.v == nil {
393 tc.v = func(t *testing.T) *Validator {
394 return v
395 }
396 }
397 err := tc.v(t).ValidateDynamicRegistration(t.Context(), tc.in)

Callers

nothing calls this directly

Calls 6

NewRegistryMemoryFunction · 0.92
WithConfigOptionsFunction · 0.92
NewValidatorFunction · 0.85
checkMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected