@@ -779,6 +779,50 @@ public void shouldGetNewIdTokenWithIdTokenSync() throws Exception {
779779 assertThat (delegation , is (notNullValue ()));
780780 }
781781
782+ @ Test
783+ public void shouldGetCustomizedDelegationRequestWithIdToken () throws Exception {
784+ mockAPI .willReturnNewIdToken ();
785+
786+ final MockBaseCallback <Map <String ,Object >> callback = new MockBaseCallback <>();
787+ client .delegationWithIdToken (ID_TOKEN , "custom_api_type" )
788+ .setScope ("custom_scope" )
789+ .setTarget ("custom_target" )
790+ .start (callback );
791+
792+ final RecordedRequest request = mockAPI .takeRequest ();
793+ assertThat (request .getPath (), equalTo ("/delegation" ));
794+
795+ Map <String , String > body = bodyFromRequest (request );
796+ assertThat (body , hasEntry ("grant_type" , ParameterBuilder .GRANT_TYPE_JWT ));
797+ assertThat (body , hasEntry ("client_id" , CLIENT_ID ));
798+ assertThat (body , hasEntry ("api_type" , "custom_api_type" ));
799+ assertThat (body , hasEntry ("scope" , "custom_scope" ));
800+ assertThat (body , hasEntry ("target" , "custom_target" ));
801+ assertThat (body , hasEntry ("id_token" , ID_TOKEN ));
802+ }
803+
804+ @ Test
805+ public void shouldGetCustomizedDelegationRequestWithIdTokenSync () throws Exception {
806+ mockAPI .willReturnNewIdToken ();
807+
808+ client
809+ .delegationWithIdToken (ID_TOKEN , "custom_api_type" )
810+ .setScope ("custom_scope" )
811+ .setTarget ("custom_target" )
812+ .execute ();
813+
814+ final RecordedRequest request = mockAPI .takeRequest ();
815+ assertThat (request .getPath (), equalTo ("/delegation" ));
816+
817+ Map <String , String > body = bodyFromRequest (request );
818+ assertThat (body , hasEntry ("grant_type" , ParameterBuilder .GRANT_TYPE_JWT ));
819+ assertThat (body , hasEntry ("client_id" , CLIENT_ID ));
820+ assertThat (body , hasEntry ("api_type" , "custom_api_type" ));
821+ assertThat (body , hasEntry ("scope" , "custom_scope" ));
822+ assertThat (body , hasEntry ("target" , "custom_target" ));
823+ assertThat (body , hasEntry ("id_token" , ID_TOKEN ));
824+ }
825+
782826 @ Test
783827 public void shouldGetNewIdTokenWithRefreshToken () throws Exception {
784828 mockAPI .willReturnNewIdToken ();
@@ -820,7 +864,7 @@ public void shouldGetNewIdTokenWithRefreshTokenSync() throws Exception {
820864 }
821865
822866 @ Test
823- public void shouldGetCustomizedDelegationRequest () throws Exception {
867+ public void shouldGetCustomizedDelegationRequestWithRefreshToken () throws Exception {
824868 mockAPI .willReturnNewIdToken ();
825869
826870 final MockBaseCallback <Map <String ,Object >> callback = new MockBaseCallback <>();
@@ -842,7 +886,7 @@ public void shouldGetCustomizedDelegationRequest() throws Exception {
842886 }
843887
844888 @ Test
845- public void shouldGetCustomizedDelegationRequestSync () throws Exception {
889+ public void shouldGetCustomizedDelegationRequestWithRefreshTokenSync () throws Exception {
846890 mockAPI .willReturnNewIdToken ();
847891
848892 client
0 commit comments