(t *testing.T)
| 472 | } |
| 473 | |
| 474 | func TestHandleRegistration(t *testing.T) { |
| 475 | tests := []struct { |
| 476 | name string |
| 477 | serverConfig *oauthtest.RegistrationConfig |
| 478 | handlerConfig *AuthorizationCodeHandlerConfig |
| 479 | asm *oauthex.AuthServerMeta |
| 480 | want *resolvedClientConfig |
| 481 | wantError bool |
| 482 | }{ |
| 483 | { |
| 484 | name: "ClientIDMetadataDocument", |
| 485 | serverConfig: &oauthtest.RegistrationConfig{ |
| 486 | ClientIDMetadataDocumentSupported: true, |
| 487 | }, |
| 488 | handlerConfig: &AuthorizationCodeHandlerConfig{ |
| 489 | ClientIDMetadataDocumentConfig: &ClientIDMetadataDocumentConfig{URL: "https://client.example.com/metadata.json"}, |
| 490 | }, |
| 491 | want: &resolvedClientConfig{ |
| 492 | registrationType: registrationTypeClientIDMetadataDocument, |
| 493 | clientID: "https://client.example.com/metadata.json", |
| 494 | }, |
| 495 | }, |
| 496 | { |
| 497 | name: "Preregistered", |
| 498 | serverConfig: &oauthtest.RegistrationConfig{ |
| 499 | PreregisteredClients: map[string]oauthtest.ClientInfo{ |
| 500 | "pre_client_id": { |
| 501 | Secret: "pre_client_secret", |
| 502 | }, |
| 503 | }, |
| 504 | }, |
| 505 | handlerConfig: &AuthorizationCodeHandlerConfig{ |
| 506 | PreregisteredClient: &oauthex.ClientCredentials{ |
| 507 | ClientID: "pre_client_id", |
| 508 | ClientSecretAuth: &oauthex.ClientSecretAuth{ |
| 509 | ClientSecret: "pre_client_secret", |
| 510 | }, |
| 511 | }, |
| 512 | }, |
| 513 | want: &resolvedClientConfig{ |
| 514 | registrationType: registrationTypePreregistered, |
| 515 | clientID: "pre_client_id", |
| 516 | clientSecret: "pre_client_secret", |
| 517 | authStyle: oauth2.AuthStyleInParams, |
| 518 | }, |
| 519 | }, |
| 520 | { |
| 521 | name: "NoneSupported", |
| 522 | handlerConfig: &AuthorizationCodeHandlerConfig{ |
| 523 | ClientIDMetadataDocumentConfig: &ClientIDMetadataDocumentConfig{URL: "https://client.example.com/metadata.json"}, |
| 524 | }, |
| 525 | wantError: true, |
| 526 | }, |
| 527 | } |
| 528 | |
| 529 | for _, tt := range tests { |
| 530 | t.Run(tt.name, func(t *testing.T) { |
| 531 | s := oauthtest.NewFakeAuthorizationServer(oauthtest.Config{RegistrationConfig: tt.serverConfig}) |
nothing calls this directly
no test coverage detected
searching dependent graphs…