@@ -1019,6 +1019,29 @@ describe("Orchestration Client", () => {
10191019 expect ( result ) . to . be . equal ( undefined ) ;
10201020 } ) ;
10211021
1022+ it ( `throws when webhook returns invalid status code 404 with webhook error message` , async ( ) => {
1023+ const client = new DurableClient ( defaultClientInputData ) ;
1024+
1025+ const testId = "badId" ;
1026+ const testReason = "test" ;
1027+ const expectedWebhookUrl = new url . URL (
1028+ defaultClientInputData . managementUrls . rewindPostUri
1029+ . replace ( TestConstants . idPlaceholder , testId )
1030+ . replace ( TestConstants . reasonPlaceholder , testReason )
1031+ ) ;
1032+ const scope = nock ( expectedWebhookUrl . origin , requiredPostHeaders )
1033+ . post ( expectedWebhookUrl . pathname )
1034+ . query ( ( actualQueryObject : object ) =>
1035+ urlQueryEqualsQueryObject ( expectedWebhookUrl , actualQueryObject )
1036+ )
1037+ . reply ( 404 , "No instance ID found!" ) ;
1038+
1039+ await expect ( client . rewind ( testId , testReason ) ) . to . be . rejectedWith (
1040+ "No instance ID found!"
1041+ ) ;
1042+ expect ( scope . isDone ( ) ) . to . be . equal ( true ) ;
1043+ } ) ;
1044+
10221045 it ( `throws when webhook returns invalid status code 404` , async ( ) => {
10231046 const client = new DurableClient ( defaultClientInputData ) ;
10241047
@@ -1036,13 +1059,37 @@ describe("Orchestration Client", () => {
10361059 )
10371060 . reply ( 404 ) ;
10381061
1062+ // Since the webhook did not provide a response body, use our own custom error message
10391063 await expect ( client . rewind ( testId , testReason ) ) . to . be . rejectedWith (
10401064 `No instance with ID '${ testId } ' found.`
10411065 ) ;
10421066 expect ( scope . isDone ( ) ) . to . be . equal ( true ) ;
10431067 } ) ;
10441068
1045- it ( `throws when webhook returns invalid status code 410` , async ( ) => {
1069+ it ( `throws when webhook returns invalid status code 412 with webhook error message` , async ( ) => {
1070+ const client = new DurableClient ( defaultClientInputData ) ;
1071+
1072+ const testId = "badId" ;
1073+ const testReason = "test" ;
1074+ const expectedWebhookUrl = new url . URL (
1075+ defaultClientInputData . managementUrls . rewindPostUri
1076+ . replace ( TestConstants . idPlaceholder , testId )
1077+ . replace ( TestConstants . reasonPlaceholder , testReason )
1078+ ) ;
1079+ const scope = nock ( expectedWebhookUrl . origin , requiredPostHeaders )
1080+ . post ( expectedWebhookUrl . pathname )
1081+ . query ( ( actualQueryObject : object ) =>
1082+ urlQueryEqualsQueryObject ( expectedWebhookUrl , actualQueryObject )
1083+ )
1084+ . reply ( 412 , "Precondition failed!" ) ;
1085+
1086+ await expect ( client . rewind ( testId , testReason ) ) . to . be . rejectedWith (
1087+ "Precondition failed!"
1088+ ) ;
1089+ expect ( scope . isDone ( ) ) . to . be . equal ( true ) ;
1090+ } ) ;
1091+
1092+ it ( `throws when webhook returns invalid status code 412` , async ( ) => {
10461093 const client = new DurableClient ( defaultClientInputData ) ;
10471094
10481095 const testId = "badId" ;
@@ -1057,14 +1104,62 @@ describe("Orchestration Client", () => {
10571104 . query ( ( actualQueryObject : object ) =>
10581105 urlQueryEqualsQueryObject ( expectedWebhookUrl , actualQueryObject )
10591106 )
1060- . reply ( 410 ) ;
1107+ . reply ( 412 ) ;
10611108
1109+ // Since the webhook did not provide a response body, use our own custom error message
10621110 await expect ( client . rewind ( testId , testReason ) ) . to . be . rejectedWith (
10631111 "The rewind operation is only supported on failed orchestration instances."
10641112 ) ;
10651113 expect ( scope . isDone ( ) ) . to . be . equal ( true ) ;
10661114 } ) ;
10671115
1116+ it ( `throws when webhook returns invalid status code 501` , async ( ) => {
1117+ const client = new DurableClient ( defaultClientInputData ) ;
1118+
1119+ const testId = "badId" ;
1120+ const testReason = "test" ;
1121+ const expectedWebhookUrl = new url . URL (
1122+ defaultClientInputData . managementUrls . rewindPostUri
1123+ . replace ( TestConstants . idPlaceholder , testId )
1124+ . replace ( TestConstants . reasonPlaceholder , testReason )
1125+ ) ;
1126+ const scope = nock ( expectedWebhookUrl . origin , requiredPostHeaders )
1127+ . post ( expectedWebhookUrl . pathname )
1128+ . query ( ( actualQueryObject : object ) =>
1129+ urlQueryEqualsQueryObject ( expectedWebhookUrl , actualQueryObject )
1130+ )
1131+ . reply ( 501 , "Invalid storage provider!" ) ;
1132+
1133+ await expect ( client . rewind ( testId , testReason ) ) . to . be . rejectedWith (
1134+ "Invalid storage provider!"
1135+ ) ;
1136+ expect ( scope . isDone ( ) ) . to . be . equal ( true ) ;
1137+ } ) ;
1138+
1139+ it ( `throws when webhook returns invalid status code 501` , async ( ) => {
1140+ const client = new DurableClient ( defaultClientInputData ) ;
1141+
1142+ const testId = "badId" ;
1143+ const testReason = "test" ;
1144+ const expectedWebhookUrl = new url . URL (
1145+ defaultClientInputData . managementUrls . rewindPostUri
1146+ . replace ( TestConstants . idPlaceholder , testId )
1147+ . replace ( TestConstants . reasonPlaceholder , testReason )
1148+ ) ;
1149+ const scope = nock ( expectedWebhookUrl . origin , requiredPostHeaders )
1150+ . post ( expectedWebhookUrl . pathname )
1151+ . query ( ( actualQueryObject : object ) =>
1152+ urlQueryEqualsQueryObject ( expectedWebhookUrl , actualQueryObject )
1153+ )
1154+ . reply ( 501 ) ;
1155+
1156+ // Since the webhook did not provide a response body, use our own custom error message
1157+ await expect ( client . rewind ( testId , testReason ) ) . to . be . rejectedWith (
1158+ "The rewind operation is not supported by the underlying storage provider."
1159+ ) ;
1160+ expect ( scope . isDone ( ) ) . to . be . equal ( true ) ;
1161+ } ) ;
1162+
10681163 it ( `throws when webhook returns invalid status code 500` , async ( ) => {
10691164 const client = new DurableClient ( defaultClientInputData ) ;
10701165
0 commit comments