@@ -16,8 +16,10 @@ public class StartTrialLicenseApiTests
1616 {
1717 public StartTrialLicenseApiTests ( XPackCluster cluster , EndpointUsage usage ) : base ( cluster , usage ) { }
1818
19- protected override bool ExpectIsValid => false ;
20- protected override int ExpectStatusCode => 403 ;
19+ protected bool BootstrappedWithLicense => ! string . IsNullOrEmpty ( Cluster . ClusterConfiguration . XPackLicenseJson ) ;
20+
21+ protected override bool ExpectIsValid => BootstrappedWithLicense ;
22+ protected override int ExpectStatusCode => BootstrappedWithLicense ? 200 : 403 ;
2123 protected override HttpMethod HttpMethod => HttpMethod . POST ;
2224 protected override bool SupportsDeserialization => false ;
2325 protected override string UrlPath => $ "/_xpack/license/start_trial";
@@ -32,9 +34,18 @@ protected override LazyResponses ClientUsage() => Calls(
3234 protected override void ExpectResponse ( IStartTrialLicenseResponse response )
3335 {
3436 response . ShouldNotBeValid ( ) ;
35- // license already applied
36- response . TrialWasStarted . Should ( ) . BeFalse ( ) ;
37- response . ErrorMessage . Should ( ) . Be ( "Operation failed: Trial was already activated." ) ;
37+ response . TrialWasStarted . Should ( ) . BeFalse ( ) ;
38+ if ( ! BootstrappedWithLicense )
39+ {
40+ // license already applied
41+ response . ErrorMessage . Should ( ) . Be ( "Operation failed: Trial was already activated." ) ;
42+ }
43+ else
44+ {
45+ // running with a license means you have to pass the acknowledge flag to forcefully go
46+ // into trial mode
47+ response . ErrorMessage . Should ( ) . Contain ( " Needs acknowledgement" ) ;
48+ }
3849 }
3950 }
4051}
0 commit comments