127127import org .cloudfoundry .client .v3 .DockerData ;
128128import org .cloudfoundry .client .v3 .Lifecycle ;
129129import org .cloudfoundry .client .v3 .applications .ApplicationState ;
130+ import org .cloudfoundry .client .v3 .applications .GetApplicationEnvironmentRequest ;
131+ import org .cloudfoundry .client .v3 .applications .GetApplicationEnvironmentResponse ;
132+ import org .cloudfoundry .client .v3 .applications .GetApplicationSshEnabledRequest ;
133+ import org .cloudfoundry .client .v3 .applications .GetApplicationSshEnabledResponse ;
130134import org .cloudfoundry .client .v3 .applications .ListApplicationsRequest ;
131135import org .cloudfoundry .client .v3 .applications .ListApplicationsResponse ;
136+ import org .cloudfoundry .client .v3 .applications .UpdateApplicationFeatureRequest ;
137+ import org .cloudfoundry .client .v3 .applications .UpdateApplicationFeatureResponse ;
132138import org .cloudfoundry .client .v3 .tasks .CancelTaskRequest ;
133139import org .cloudfoundry .client .v3 .tasks .CancelTaskResponse ;
134140import org .cloudfoundry .client .v3 .tasks .CreateTaskRequest ;
@@ -405,10 +411,11 @@ void deleteWithBoundRoutes() {
405411 }
406412
407413 @ Test
408- void disableSsh () {
409- requestApplications (
410- this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , "test-metadata-id" );
411- requestUpdateApplicationSsh (this .cloudFoundryClient , "test-metadata-id" , false );
414+ public void disableSsh () {
415+ requestApplicationsV3 (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , "test-application-id" );
416+ requestGetSshEnabled (this .cloudFoundryClient ,"test-application-id" ,true );
417+ requestUpdateApplicationSshV3 (this .cloudFoundryClient , "test-application-id" , false );
418+
412419
413420 this .applications
414421 .disableSsh (DisableApplicationSshRequest .builder ().name ("test-app-name" ).build ())
@@ -418,8 +425,9 @@ void disableSsh() {
418425 }
419426
420427 @ Test
421- void disableSshAlreadyDisabled () {
422- requestApplicationsWithSsh (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , false );
428+ public void disableSshAlreadyDisabled () {
429+ requestApplicationsV3 (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , "test-application-id" );
430+ requestGetSshEnabled (this .cloudFoundryClient ,"test-application-id" ,false );
423431
424432 this .applications
425433 .disableSsh (DisableApplicationSshRequest .builder ().name ("test-app-name" ).build ())
@@ -429,8 +437,8 @@ void disableSshAlreadyDisabled() {
429437 }
430438
431439 @ Test
432- void disableSshNoApp () {
433- requestApplicationsEmpty (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID );
440+ public void disableSshNoApp () {
441+ requestApplicationsEmptyV3 (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID );
434442
435443 this .applications
436444 .disableSsh (DisableApplicationSshRequest .builder ().name ("test-app-name" ).build ())
@@ -444,10 +452,10 @@ void disableSshNoApp() {
444452 }
445453
446454 @ Test
447- void enableSsh () {
448- requestApplications (
449- this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , "test-metadata- id" );
450- requestUpdateApplicationSsh (this .cloudFoundryClient , "test-application-id" , true );
455+ public void enableSsh () {
456+ requestApplicationsV3 ( this . cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , "test-application-id" );
457+ requestGetSshEnabled ( this .cloudFoundryClient ,"test-application- id" , false );
458+ requestUpdateApplicationSshV3 (this .cloudFoundryClient , "test-application-id" , true );
451459
452460 this .applications
453461 .enableSsh (EnableApplicationSshRequest .builder ().name ("test-app-name" ).build ())
@@ -457,8 +465,9 @@ void enableSsh() {
457465 }
458466
459467 @ Test
460- void enableSshAlreadyEnabled () {
461- requestApplicationsWithSsh (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , true );
468+ public void enableSshAlreadyEnabled () {
469+ requestApplicationsV3 (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , "test-application-id" );
470+ requestGetSshEnabled (this .cloudFoundryClient ,"test-application-id" ,true );
462471
463472 this .applications
464473 .enableSsh (EnableApplicationSshRequest .builder ().name ("test-app-name" ).build ())
@@ -468,8 +477,8 @@ void enableSshAlreadyEnabled() {
468477 }
469478
470479 @ Test
471- void enableSshNoApp () {
472- requestApplicationsEmpty (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID );
480+ public void enableSshNoApp () {
481+ requestApplicationsEmptyV3 (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID );
473482
474483 this .applications
475484 .enableSsh (EnableApplicationSshRequest .builder ().name ("test-app-name" ).build ())
@@ -721,8 +730,8 @@ void getDetectedBuildpack() {
721730 }
722731
723732 @ Test
724- void getEnvironments () {
725- requestApplications (this .cloudFoundryClient , "test-app" , TEST_SPACE_ID , "test-metadata-id" );
733+ public void getEnvironments () {
734+ requestApplicationsV3 (this .cloudFoundryClient , "test-app" , TEST_SPACE_ID , "test-metadata-id" );
726735 requestApplicationEnvironment (this .cloudFoundryClient , "test-metadata-id" );
727736
728737 this .applications
@@ -753,8 +762,8 @@ void getEnvironments() {
753762 }
754763
755764 @ Test
756- void getEnvironmentsNoApp () {
757- requestApplicationsEmpty (this .cloudFoundryClient , "test-app" , TEST_SPACE_ID );
765+ public void getEnvironmentsNoApp () {
766+ requestApplicationsEmptyV3 (this .cloudFoundryClient , "test-app" , TEST_SPACE_ID );
758767
759768 this .applications
760769 .getEnvironments (
@@ -3733,9 +3742,9 @@ void setHealthCheck() {
37333742 }
37343743
37353744 @ Test
3736- void sshEnabled () {
3737- requestApplications (
3738- this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , "test-metadata- id" );
3745+ public void sshEnabled () {
3746+ requestApplicationsV3 ( this . cloudFoundryClient , "test-app-name" , TEST_SPACE_ID , "test-application-id" );
3747+ requestGetSshEnabled ( this .cloudFoundryClient ,"test-application- id" , true );
37393748
37403749 this .applications
37413750 .sshEnabled (ApplicationSshEnabledRequest .builder ().name ("test-app-name" ).build ())
@@ -3746,8 +3755,8 @@ void sshEnabled() {
37463755 }
37473756
37483757 @ Test
3749- void sshEnabledNoApp () {
3750- requestApplicationsEmpty (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID );
3758+ public void sshEnabledNoApp () {
3759+ requestApplicationsEmptyV3 (this .cloudFoundryClient , "test-app-name" , TEST_SPACE_ID );
37513760
37523761 this .applications
37533762 .sshEnabled (ApplicationSshEnabledRequest .builder ().name ("test-app-name" ).build ())
@@ -3760,6 +3769,7 @@ void sshEnabledNoApp() {
37603769 .verify (Duration .ofSeconds (5 ));
37613770 }
37623771
3772+
37633773 @ Test
37643774 void startApplicationFailurePartial () {
37653775 requestApplicationsSpecificState (
@@ -4046,27 +4056,19 @@ private static void requestApplicationEmptyStats(
40464056 .thenReturn (Mono .just (ApplicationStatisticsResponse .builder ().build ()));
40474057 }
40484058
4049- private static void requestApplicationEnvironment (
4050- CloudFoundryClient cloudFoundryClient , String applicationId ) {
4051- when (cloudFoundryClient
4052- .applicationsV2 ()
4053- .environment (
4054- ApplicationEnvironmentRequest .builder ()
4055- .applicationId (applicationId )
4056- .build ()))
4057- .thenReturn (
4058- Mono .just (
4059- ApplicationEnvironmentResponse .builder ()
4060- .runningEnvironmentJson (
4061- "running-env-name" , "running-env-value" )
4062- .applicationEnvironmentJson (
4063- "application-env-name" , "application-env-value" )
4064- .stagingEnvironmentJson (
4065- "staging-env-name" , "staging-env-value" )
4066- .environmentJson ("env-name" , "env-value" )
4067- .systemEnvironmentJson (
4068- "system-env-name" , "system-env-value" )
4069- .build ()));
4059+ private static void requestApplicationEnvironment (CloudFoundryClient cloudFoundryClient , String applicationId ) {
4060+ when (cloudFoundryClient .applicationsV3 ()
4061+ .getEnvironment (GetApplicationEnvironmentRequest .builder ()
4062+ .applicationId (applicationId )
4063+ .build ()))
4064+ .thenReturn (Mono
4065+ .just (GetApplicationEnvironmentResponse .builder ()
4066+ .runningEnvironmentVariable ("running-env-name" , "running-env-value" )
4067+ .applicationEnvironmentVariable ("application-env-name" , "application-env-value" )
4068+ .stagingEnvironmentVariable ("staging-env-name" , "staging-env-value" )
4069+ .environmentVariable ("env-name" , "env-value" )
4070+ .systemEnvironmentVariable ("system-env-name" , "system-env-value" )
4071+ .build ()));
40704072 }
40714073
40724074 private static void requestApplicationInstances (
@@ -4661,33 +4663,33 @@ private static void requestApplicationsEmpty(
46614663 .thenReturn (Mono .just (fill (ListSpaceApplicationsResponse .builder ()).build ()));
46624664 }
46634665
4664- private static void requestApplicationsSpecificState (
4665- CloudFoundryClient cloudFoundryClient ,
4666- String application ,
4667- String spaceId ,
4668- String stateReturned ) {
4669- when ( cloudFoundryClient
4670- . spaces ( )
4671- . listApplications (
4672- ListSpaceApplicationsRequest . builder ()
4673- . name ( application )
4674- . page ( 1 )
4675- . spaceId ( spaceId )
4676- . build ()))
4677- . thenReturn (
4678- Mono . just (
4679- fill ( ListSpaceApplicationsResponse . builder () )
4680- . resource (
4681- fill ( ApplicationResource . builder (), "application-" )
4682- . entity (
4683- fill (
4684- ApplicationEntity
4685- . builder (),
4686- "application-entity-" )
4687- .state (stateReturned )
4688- .build ())
4689- .build ())
4690- .build ()));
4666+ private static void requestApplicationsEmptyV3 ( CloudFoundryClient cloudFoundryClient , String application , String spaceId ) {
4667+ when ( cloudFoundryClient . applicationsV3 ()
4668+ . list ( ListApplicationsRequest . builder ()
4669+ . name ( application )
4670+ . spaceId ( spaceId )
4671+ . page ( 1 )
4672+ . build ()) )
4673+ . thenReturn ( Mono
4674+ . just ( fill ( ListApplicationsResponse . builder () )
4675+ . build ()));
4676+ }
4677+
4678+ private static void requestApplicationsSpecificState ( CloudFoundryClient cloudFoundryClient , String application , String spaceId , String stateReturned ) {
4679+ when ( cloudFoundryClient . spaces ()
4680+ . listApplications ( ListSpaceApplicationsRequest . builder ()
4681+ . name ( application )
4682+ . page ( 1 )
4683+ . spaceId ( spaceId )
4684+ . build ()))
4685+ . thenReturn ( Mono
4686+ . just ( fill ( ListSpaceApplicationsResponse . builder ())
4687+ . resource ( fill ( ApplicationResource . builder (), "application-" )
4688+ . entity ( fill ( ApplicationEntity . builder (), "application-entity-" )
4689+ .state (stateReturned )
4690+ .build ())
4691+ .build ())
4692+ .build ()));
46914693 }
46924694
46934695 private static void requestApplicationsV3 (
@@ -5850,8 +5852,34 @@ private static void requestUpdateApplicationSsh(
58505852 .build ()));
58515853 }
58525854
5853- private static void requestUpdateApplicationState (
5854- CloudFoundryClient cloudFoundryClient , String applicationId , String state ) {
5855+ private static void requestUpdateApplicationSshV3 (CloudFoundryClient cloudFoundryClient , String applicationId , Boolean enabled ) {
5856+
5857+ when (cloudFoundryClient .applicationsV3 ()
5858+ .updateFeature (UpdateApplicationFeatureRequest .builder ()
5859+ .applicationId (applicationId )
5860+ .featureName (APP_FEATURE_SSH )
5861+ .enabled (enabled )
5862+ .build ()))
5863+ .thenReturn (Mono
5864+ .just (fill (UpdateApplicationFeatureResponse .builder ())
5865+ .description ("test-description" )
5866+ .name ("test-application-name" )
5867+ .enabled (enabled )
5868+ .build ()));
5869+ }
5870+
5871+ private static void requestGetSshEnabled (CloudFoundryClient cloudFoundryClient , String applicationId ,boolean status ) {
5872+ when (cloudFoundryClient .applicationsV3 ()
5873+ .getSshEnabled (GetApplicationSshEnabledRequest .builder ()
5874+ .applicationId (applicationId ).build ()))
5875+ .thenReturn (Mono
5876+ .just (fill (GetApplicationSshEnabledResponse .builder ())
5877+ .reason ("test-reason" )
5878+ .enabled (status )
5879+ .build ()));
5880+ }
5881+
5882+ private static void requestUpdateApplicationState (CloudFoundryClient cloudFoundryClient , String applicationId , String state ) {
58555883 requestUpdateApplicationState (cloudFoundryClient , applicationId , state , 1 );
58565884 }
58575885
0 commit comments