(t *testing.T)
| 566 | } |
| 567 | |
| 568 | func TestDynamicRegistration(t *testing.T) { |
| 569 | s := oauthtest.NewFakeAuthorizationServer(oauthtest.Config{ |
| 570 | RegistrationConfig: &oauthtest.RegistrationConfig{ |
| 571 | DynamicClientRegistrationEnabled: true, |
| 572 | }, |
| 573 | }) |
| 574 | s.Start(t) |
| 575 | handler, err := NewAuthorizationCodeHandler(&AuthorizationCodeHandlerConfig{ |
| 576 | DynamicClientRegistrationConfig: &DynamicClientRegistrationConfig{ |
| 577 | Metadata: &oauthex.ClientRegistrationMetadata{ |
| 578 | RedirectURIs: []string{"https://example.com/callback"}, |
| 579 | }, |
| 580 | }, |
| 581 | RedirectURL: "https://example.com/callback", |
| 582 | AuthorizationCodeFetcher: func(ctx context.Context, args *AuthorizationArgs) (*AuthorizationResult, error) { |
| 583 | return nil, nil |
| 584 | }, |
| 585 | }) |
| 586 | if err != nil { |
| 587 | t.Fatalf("NewAuthorizationCodeHandler() error = %v", err) |
| 588 | } |
| 589 | asm, err := GetAuthServerMetadata(t.Context(), s.URL(), http.DefaultClient) |
| 590 | if err != nil { |
| 591 | t.Fatalf("GetAuthServerMetadata() unexpected error = %v", err) |
| 592 | } |
| 593 | got, err := handler.handleRegistration(t.Context(), asm) |
| 594 | if err != nil { |
| 595 | t.Fatalf("handleRegistration() error = %v, want nil", err) |
| 596 | } |
| 597 | if got.registrationType != registrationTypeDynamic { |
| 598 | t.Errorf("handleRegistration() registrationType = %v, want %v", got.registrationType, registrationTypeDynamic) |
| 599 | } |
| 600 | if got.clientID == "" { |
| 601 | t.Errorf("handleRegistration() clientID = %q, want non-empty", got.clientID) |
| 602 | } |
| 603 | if got.clientSecret == "" { |
| 604 | t.Errorf("handleRegistration() clientSecret = %q, want non-empty", got.clientSecret) |
| 605 | } |
| 606 | if got.authStyle != oauth2.AuthStyleInHeader { |
| 607 | t.Errorf("handleRegistration() authStyle = %v, want %v", got.authStyle, oauth2.AuthStyleInHeader) |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | func TestInferApplicationType(t *testing.T) { |
| 612 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…