@@ -109,6 +109,7 @@ describe("OAuth Proxy Utilities", () => {
109109 it ( "should handle non-ok responses" , async ( ) => {
110110 ( global . fetch as jest . Mock ) . mockResolvedValueOnce ( {
111111 ok : false ,
112+ status : 404 ,
112113 statusText : "Not Found" ,
113114 json : async ( ) => ( { error : "Metadata not found" } ) ,
114115 } ) ;
@@ -119,13 +120,14 @@ describe("OAuth Proxy Utilities", () => {
119120 mockConfig ,
120121 ) ,
121122 ) . rejects . toThrow (
122- "Failed to discover OAuth metadata: Metadata not found" ,
123+ "Failed to discover OAuth metadata: Not found: Metadata not found" ,
123124 ) ;
124125 } ) ;
125126
126127 it ( "should handle responses without error details" , async ( ) => {
127128 ( global . fetch as jest . Mock ) . mockResolvedValueOnce ( {
128129 ok : false ,
130+ status : 500 ,
129131 statusText : "Internal Server Error" ,
130132 json : async ( ) => {
131133 throw new Error ( "Invalid JSON" ) ;
@@ -138,7 +140,7 @@ describe("OAuth Proxy Utilities", () => {
138140 mockConfig ,
139141 ) ,
140142 ) . rejects . toThrow (
141- "Failed to discover OAuth metadata: Internal Server Error" ,
143+ "Failed to discover OAuth metadata: Server error (500): Internal Server Error" ,
142144 ) ;
143145 } ) ;
144146 } ) ;
@@ -177,6 +179,7 @@ describe("OAuth Proxy Utilities", () => {
177179 it ( "should handle errors" , async ( ) => {
178180 ( global . fetch as jest . Mock ) . mockResolvedValueOnce ( {
179181 ok : false ,
182+ status : 404 ,
180183 statusText : "Not Found" ,
181184 json : async ( ) => ( { error : "Resource metadata not found" } ) ,
182185 } ) ;
@@ -187,7 +190,7 @@ describe("OAuth Proxy Utilities", () => {
187190 mockConfig ,
188191 ) ,
189192 ) . rejects . toThrow (
190- "Failed to discover resource metadata: Resource metadata not found" ,
193+ "Failed to discover resource metadata: Not found: Resource metadata not found" ,
191194 ) ;
192195 } ) ;
193196 } ) ;
@@ -237,6 +240,7 @@ describe("OAuth Proxy Utilities", () => {
237240 it ( "should handle registration errors" , async ( ) => {
238241 ( global . fetch as jest . Mock ) . mockResolvedValueOnce ( {
239242 ok : false ,
243+ status : 400 ,
240244 statusText : "Bad Request" ,
241245 json : async ( ) => ( { error : "Invalid client metadata" } ) ,
242246 } ) ;
@@ -250,7 +254,9 @@ describe("OAuth Proxy Utilities", () => {
250254 } ,
251255 mockConfig ,
252256 ) ,
253- ) . rejects . toThrow ( "Failed to register client: Invalid client metadata" ) ;
257+ ) . rejects . toThrow (
258+ "Failed to register client: Bad Request: Invalid client metadata" ,
259+ ) ;
254260 } ) ;
255261 } ) ;
256262
@@ -301,6 +307,7 @@ describe("OAuth Proxy Utilities", () => {
301307 it ( "should handle token exchange errors" , async ( ) => {
302308 ( global . fetch as jest . Mock ) . mockResolvedValueOnce ( {
303309 ok : false ,
310+ status : 401 ,
304311 statusText : "Unauthorized" ,
305312 json : async ( ) => ( { error : "invalid_grant" } ) ,
306313 } ) ;
@@ -311,7 +318,9 @@ describe("OAuth Proxy Utilities", () => {
311318 { grant_type : "authorization_code" , code : "invalid" } ,
312319 mockConfig ,
313320 ) ,
314- ) . rejects . toThrow ( "Failed to exchange authorization code: invalid_grant" ) ;
321+ ) . rejects . toThrow (
322+ "Failed to exchange authorization code: Authentication failed: invalid_grant" ,
323+ ) ;
315324 } ) ;
316325
317326 it ( "should handle network failures" , async ( ) => {
0 commit comments