@@ -66,6 +66,7 @@ public AdminPaths(WireMockServerSettings settings)
6666 public RegexMatcher MappingsCodeGuidPathMatcher => new ( $ "^{ _prefixEscaped } \\ /mappings\\ /code\\ /([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})$") ;
6767 public RegexMatcher RequestsGuidPathMatcher => new ( $ "^{ _prefixEscaped } \\ /requests\\ /([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})$") ;
6868 public RegexMatcher ScenariosNameMatcher => new ( $ "^{ _prefixEscaped } \\ /scenarios\\ /.+$") ;
69+ public RegexMatcher ScenariosNameWithStateMatcher => new ( $ "^{ _prefixEscaped } \\ /scenarios\\ /.+\\ /state$") ;
6970 public RegexMatcher ScenariosNameWithResetMatcher => new ( $ "^{ _prefixEscaped } \\ /scenarios\\ /.+\\ /reset$") ;
7071 public RegexMatcher FilesFilenamePathMatcher => new ( $ "^{ _prefixEscaped } \\ /files\\ /.+$") ;
7172 public RegexMatcher ProtoDefinitionsIdPathMatcher => new ( $ "^{ _prefixEscaped } \\ /protodefinitions\\ /.+$") ;
@@ -138,6 +139,9 @@ private void InitAdmin()
138139 Given ( Request . Create ( ) . WithPath ( _adminPaths . Scenarios + "/reset" ) . UsingPost ( ) ) . AtPriority ( WireMockConstants . AdminPriority ) . RespondWith ( new DynamicResponseProvider ( ScenariosReset ) ) ;
139140 Given ( Request . Create ( ) . WithPath ( _adminPaths . ScenariosNameWithResetMatcher ) . UsingPost ( ) ) . AtPriority ( WireMockConstants . AdminPriority ) . RespondWith ( new DynamicResponseProvider ( ScenarioReset ) ) ;
140141
142+ // __admin/scenarios/{scenario}/state
143+ Given ( Request . Create ( ) . WithPath ( _adminPaths . ScenariosNameWithStateMatcher ) . UsingPut ( ) ) . AtPriority ( WireMockConstants . AdminPriority ) . RespondWith ( new DynamicResponseProvider ( ScenariosSetState ) ) ;
144+
141145 // __admin/files/{filename}
142146 Given ( Request . Create ( ) . WithPath ( _adminPaths . FilesFilenamePathMatcher ) . UsingPost ( ) ) . AtPriority ( WireMockConstants . AdminPriority ) . RespondWith ( new DynamicResponseProvider ( FilePost ) ) ;
143147 Given ( Request . Create ( ) . WithPath ( _adminPaths . FilesFilenamePathMatcher ) . UsingPut ( ) ) . AtPriority ( WireMockConstants . AdminPriority ) . RespondWith ( new DynamicResponseProvider ( FilePut ) ) ;
@@ -705,6 +709,21 @@ private IResponseMessage ScenarioReset(IRequestMessage requestMessage)
705709 ResponseMessageBuilder . Create ( 200 , "Scenario reset" ) :
706710 ResponseMessageBuilder . Create ( HttpStatusCode . NotFound , $ "No scenario found by name '{ name } '.") ;
707711 }
712+
713+ private IResponseMessage ScenariosSetState ( IRequestMessage requestMessage )
714+ {
715+ var name = requestMessage . Path . Split ( '/' ) . Reverse ( ) . Skip ( 1 ) . First ( ) ;
716+ if ( ! _options . Scenarios . ContainsKey ( name ) )
717+ {
718+ ResponseMessageBuilder . Create ( HttpStatusCode . NotFound , $ "No scenario found by name '{ name } '.") ;
719+ }
720+
721+ var update = DeserializeObject < ScenarioStateUpdateModel > ( requestMessage ) ;
722+
723+ return SetScenarioState ( name , update . State ) ?
724+ ResponseMessageBuilder . Create ( 200 , $ "Scenario state set to '{ update . State } '") :
725+ ResponseMessageBuilder . Create ( HttpStatusCode . NotFound , $ "No scenario found by name '{ name } '.") ;
726+ }
708727 #endregion
709728
710729 #region Pact
0 commit comments