@@ -10,7 +10,8 @@ import {
1010 discoverOAuthProtectedResourceMetadata ,
1111 extractResourceMetadataUrl ,
1212 auth ,
13- type OAuthClientProvider
13+ type OAuthClientProvider ,
14+ selectClientAuthMethod
1415} from './auth.js' ;
1516import { ServerError } from '../server/auth/errors.js' ;
1617import { AuthorizationServerMetadata } from '../shared/auth.js' ;
@@ -881,6 +882,21 @@ describe('OAuth Authorization', () => {
881882 } ) ;
882883 } ) ;
883884
885+ describe ( 'selectClientAuthMethod' , ( ) => {
886+ it ( 'selects the correct client authentication method from client information' , ( ) => {
887+ const clientInfo = { client_id : 'test-client-id' , client_secret : 'test-client-secret' , token_endpoint_auth_method : 'client_secret_basic' } ;
888+ const supportedMethods = [ 'client_secret_post' , 'client_secret_basic' , 'none' ] ;
889+ const authMethod = selectClientAuthMethod ( clientInfo , supportedMethods ) ;
890+ expect ( authMethod ) . toBe ( 'client_secret_basic' ) ;
891+ } ) ;
892+ it ( 'selects the correct client authentication method from supported methods' , ( ) => {
893+ const clientInfo = { client_id : 'test-client-id' } ;
894+ const supportedMethods = [ 'client_secret_post' , 'client_secret_basic' , 'none' ] ;
895+ const authMethod = selectClientAuthMethod ( clientInfo , supportedMethods ) ;
896+ expect ( authMethod ) . toBe ( 'none' ) ;
897+ } ) ;
898+ } ) ;
899+
884900 describe ( 'startAuthorization' , ( ) => {
885901 const validMetadata = {
886902 issuer : 'https://auth.example.com' ,
0 commit comments