File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,8 @@ public async Task TestAuth()
106106 {
107107 var client = ThirdwebClient . Create ( clientId : "hi" , fetchTimeoutOptions : new TimeoutOptions ( rpc : 60000 ) ) ;
108108 var rpc = ThirdwebRPC . GetRpcInstance ( client , 1 ) ;
109- _ = await Assert . ThrowsAsync < HttpRequestException > ( async ( ) => await rpc . SendRequestAsync < string > ( "eth_blockNumber" ) ) ;
109+ var ex = await Assert . ThrowsAsync < HttpRequestException > ( async ( ) => await rpc . SendRequestAsync < string > ( "eth_blockNumber" ) ) ;
110+ Assert . Contains ( "Unauthorized" , ex . Message ) ;
110111 }
111112
112113 [ Fact ( Timeout = 120000 ) ]
Original file line number Diff line number Diff line change @@ -71,12 +71,12 @@ public async Task DownloadTest_Base64Uri()
7171 }
7272
7373 [ Fact ( Timeout = 120000 ) ]
74- public async Task DownloadTest_400 ( )
74+ public async Task DownloadTest_404 ( )
7575 {
7676 var client = ThirdwebClient . Create ( secretKey : this . SecretKey ) ;
77- var exception = await Assert . ThrowsAsync < Exception > ( ( ) => ThirdwebStorage . Download < string > ( client , "https://0.rpc.thirdweb. com/" ) ) ;
77+ var exception = await Assert . ThrowsAsync < Exception > ( ( ) => ThirdwebStorage . Download < string > ( client , "https://example. com/invalid-file " ) ) ;
7878 Assert . Contains ( "Failed to download" , exception . Message ) ;
79- Assert . Contains ( "400 " , exception . Message ) ;
79+ Assert . Contains ( "404 " , exception . Message ) ;
8080 }
8181
8282 [ Fact ( Timeout = 120000 ) ]
Original file line number Diff line number Diff line change @@ -181,8 +181,12 @@ private async Task SendBatchAsync(List<RpcRequest> batch)
181181 throw new HttpRequestException ( errorDetail ) ;
182182 }
183183
184- var responseJson = await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
185- var responses = JsonConvert . DeserializeObject < List < RpcResponse < object > > > ( responseJson ) ;
184+ var responseContent = await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
185+ if ( responseContent . Equals ( "Unauthorized" , StringComparison . OrdinalIgnoreCase ) )
186+ {
187+ throw new HttpRequestException ( "Unauthorized" ) ;
188+ }
189+ var responses = JsonConvert . DeserializeObject < List < RpcResponse < object > > > ( responseContent ) ;
186190
187191 foreach ( var rpcResponse in responses )
188192 {
You can’t perform that action at this time.
0 commit comments