@@ -461,4 +461,47 @@ public void shouldThrowOnDeleteCredentialsWithNullCredentialId() {
461461 () -> api .clients ().deleteCredential ("clientId" , null ),
462462 "'credential id' cannot be null!" );
463463 }
464+
465+ @ Test
466+ public void shouldUpdateClientCredential () throws Exception {
467+ Credential credential = new Credential ();
468+ credential .setName ("Updated credential name" );
469+ Request <Credential > request = api .clients ().updateCredential ("clientId" , "credId" , credential );
470+ assertThat (request , is (notNullValue ()));
471+
472+ server .jsonResponse (MGMT_CLIENT_CREDENTIAL , 200 );
473+ Credential response = request .execute ().getBody ();
474+ RecordedRequest recordedRequest = server .takeRequest ();
475+
476+ assertThat (recordedRequest , hasMethodAndPath (HttpMethod .PATCH , "/api/v2/clients/clientId/credentials/credId" ));
477+ assertThat (recordedRequest , hasHeader ("Content-Type" , "application/json" ));
478+ assertThat (recordedRequest , hasHeader ("Authorization" , "Bearer apiToken" ));
479+
480+ Map <String , Object > body = bodyFromRequest (recordedRequest );
481+ assertThat (body .size (), is (1 ));
482+ assertThat (body , hasEntry ("name" , "Updated credential name" ));
483+
484+ assertThat (response , is (notNullValue ()));
485+ }
486+
487+ @ Test
488+ public void shouldThrowOnUpdateCredentialWithNullClientId () {
489+ verifyThrows (IllegalArgumentException .class ,
490+ () -> api .clients ().updateCredential (null , "credId" , new Credential ()),
491+ "'client id' cannot be null!" );
492+ }
493+
494+ @ Test
495+ public void shouldThrowOnUpdateCredentialWithNullCredentialId () {
496+ verifyThrows (IllegalArgumentException .class ,
497+ () -> api .clients ().updateCredential ("clientId" , null , new Credential ()),
498+ "'credential id' cannot be null!" );
499+ }
500+
501+ @ Test
502+ public void shouldThrowOnUpdateCredentialWithNullCredential () {
503+ verifyThrows (IllegalArgumentException .class ,
504+ () -> api .clients ().updateCredential ("clientId" , "credId" , null ),
505+ "'credential' cannot be null!" );
506+ }
464507}
0 commit comments