@@ -10,7 +10,7 @@ describe('Client Registration Handler', () => {
1010 async getClient ( _clientId : string ) : Promise < OAuthClientInformationFull | undefined > {
1111 return undefined ;
1212 } ,
13-
13+
1414 async registerClient ( client : OAuthClientInformationFull ) : Promise < OAuthClientInformationFull > {
1515 // Return the client info as-is in the mock
1616 return client ;
@@ -30,15 +30,15 @@ describe('Client Registration Handler', () => {
3030 const options : ClientRegistrationHandlerOptions = {
3131 clientsStore : mockClientStoreWithoutRegistration
3232 } ;
33-
33+
3434 expect ( ( ) => clientRegistrationHandler ( options ) ) . toThrow ( 'does not support registering clients' ) ;
3535 } ) ;
3636
3737 it ( 'creates handler if client store supports registration' , ( ) => {
3838 const options : ClientRegistrationHandlerOptions = {
3939 clientsStore : mockClientStoreWithRegistration
4040 } ;
41-
41+
4242 expect ( ( ) => clientRegistrationHandler ( options ) ) . not . toThrow ( ) ;
4343 } ) ;
4444 } ) ;
@@ -54,7 +54,7 @@ describe('Client Registration Handler', () => {
5454 clientsStore : mockClientStoreWithRegistration ,
5555 clientSecretExpirySeconds : 86400 // 1 day for testing
5656 } ;
57-
57+
5858 app . use ( '/register' , clientRegistrationHandler ( options ) ) ;
5959
6060 // Spy on the registerClient method
@@ -72,7 +72,12 @@ describe('Client Registration Handler', () => {
7272 redirect_uris : [ 'https://example.com/callback' ]
7373 } ) ;
7474
75- expect ( response . status ) . toBe ( 404 ) ; // 404 since router only handles POST
75+ expect ( response . status ) . toBe ( 405 ) ;
76+ expect ( response . headers . allow ) . toBe ( 'POST' ) ;
77+ expect ( response . body ) . toEqual ( {
78+ error : "method_not_allowed" ,
79+ error_description : "The method GET is not allowed for this endpoint"
80+ } ) ;
7681 expect ( spyRegisterClient ) . not . toHaveBeenCalled ( ) ;
7782 } ) ;
7883
@@ -112,14 +117,14 @@ describe('Client Registration Handler', () => {
112117 . send ( clientMetadata ) ;
113118
114119 expect ( response . status ) . toBe ( 201 ) ;
115-
120+
116121 // Verify the generated client information
117122 expect ( response . body . client_id ) . toBeDefined ( ) ;
118123 expect ( response . body . client_secret ) . toBeDefined ( ) ;
119124 expect ( response . body . client_id_issued_at ) . toBeDefined ( ) ;
120125 expect ( response . body . client_secret_expires_at ) . toBeDefined ( ) ;
121126 expect ( response . body . redirect_uris ) . toEqual ( [ 'https://example.com/callback' ] ) ;
122-
127+
123128 // Verify client was registered
124129 expect ( spyRegisterClient ) . toHaveBeenCalledTimes ( 1 ) ;
125130 } ) ;
@@ -145,7 +150,7 @@ describe('Client Registration Handler', () => {
145150 clientsStore : mockClientStoreWithRegistration ,
146151 clientSecretExpirySeconds : 3600 // 1 hour
147152 } ;
148-
153+
149154 customApp . use ( '/register' , clientRegistrationHandler ( options ) ) ;
150155
151156 const response = await supertest ( customApp )
@@ -155,7 +160,7 @@ describe('Client Registration Handler', () => {
155160 } ) ;
156161
157162 expect ( response . status ) . toBe ( 201 ) ;
158-
163+
159164 // Verify the expiration time (~1 hour from now)
160165 const issuedAt = response . body . client_id_issued_at ;
161166 const expiresAt = response . body . client_secret_expires_at ;
@@ -169,7 +174,7 @@ describe('Client Registration Handler', () => {
169174 clientsStore : mockClientStoreWithRegistration ,
170175 clientSecretExpirySeconds : 0 // No expiry
171176 } ;
172-
177+
173178 customApp . use ( '/register' , clientRegistrationHandler ( options ) ) ;
174179
175180 const response = await supertest ( customApp )
@@ -205,7 +210,7 @@ describe('Client Registration Handler', () => {
205210 . send ( fullClientMetadata ) ;
206211
207212 expect ( response . status ) . toBe ( 201 ) ;
208-
213+
209214 // Verify all metadata was preserved
210215 Object . entries ( fullClientMetadata ) . forEach ( ( [ key , value ] ) => {
211216 expect ( response . body [ key ] ) . toEqual ( value ) ;
0 commit comments