Search in sources :

Example 1 with Client

use of org.cloudfoundry.uaa.clients.Client in project cf-java-client by cloudfoundry.

the class ClientsTest method delete.

@Test
public void delete() {
    String clientId = this.nameFactory.getClientId();
    String clientSecret = this.nameFactory.getClientSecret();
    requestCreateClient(this.uaaClient, clientId, clientSecret).then(this.uaaClient.clients().delete(DeleteClientRequest.builder().clientId(clientId).build())).thenMany(requestListClients(this.uaaClient)).filter(client -> clientId.equals(client.getClientId())).as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : UpdateMetadataResponse(org.cloudfoundry.uaa.clients.UpdateMetadataResponse) UpdateSecretAction(org.cloudfoundry.uaa.clients.UpdateSecretAction) StepVerifier(reactor.test.StepVerifier) UpdateClient(org.cloudfoundry.uaa.clients.UpdateClient) Client(org.cloudfoundry.uaa.clients.Client) DeleteClientRequest(org.cloudfoundry.uaa.clients.DeleteClientRequest) BatchUpdateClientsRequest(org.cloudfoundry.uaa.clients.BatchUpdateClientsRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IMPLICIT(org.cloudfoundry.uaa.tokens.GrantType.IMPLICIT) GetClientRequest(org.cloudfoundry.uaa.clients.GetClientRequest) CLIENT_CREDENTIALS(org.cloudfoundry.uaa.tokens.GrantType.CLIENT_CREDENTIALS) AsciiString(io.netty.util.AsciiString) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) UpdateMetadataRequest(org.cloudfoundry.uaa.clients.UpdateMetadataRequest) PASSWORD(org.cloudfoundry.uaa.tokens.GrantType.PASSWORD) MixedActionsRequest(org.cloudfoundry.uaa.clients.MixedActionsRequest) UpdateClientAction(org.cloudfoundry.uaa.clients.UpdateClientAction) Duration(java.time.Duration) PaginationUtils(org.cloudfoundry.util.PaginationUtils) UpdateSecretClientAction(org.cloudfoundry.uaa.clients.UpdateSecretClientAction) BatchChangeSecretResponse(org.cloudfoundry.uaa.clients.BatchChangeSecretResponse) CreateClientResponse(org.cloudfoundry.uaa.clients.CreateClientResponse) ListMetadatasResponse(org.cloudfoundry.uaa.clients.ListMetadatasResponse) BatchCreateClientsResponse(org.cloudfoundry.uaa.clients.BatchCreateClientsResponse) ListClientsRequest(org.cloudfoundry.uaa.clients.ListClientsRequest) UpdateClientRequest(org.cloudfoundry.uaa.clients.UpdateClientRequest) BatchUpdateClientsResponse(org.cloudfoundry.uaa.clients.BatchUpdateClientsResponse) GetMetadataResponse(org.cloudfoundry.uaa.clients.GetMetadataResponse) CreateClient(org.cloudfoundry.uaa.clients.CreateClient) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) BatchCreateClientsRequest(org.cloudfoundry.uaa.clients.BatchCreateClientsRequest) Flux(reactor.core.publisher.Flux) BatchChangeSecretRequest(org.cloudfoundry.uaa.clients.BatchChangeSecretRequest) Base64(java.util.Base64) DeleteClientAction(org.cloudfoundry.uaa.clients.DeleteClientAction) ChangeSecret(org.cloudfoundry.uaa.clients.ChangeSecret) ChangeSecretRequest(org.cloudfoundry.uaa.clients.ChangeSecretRequest) CreateClientRequest(org.cloudfoundry.uaa.clients.CreateClientRequest) ListMetadatasRequest(org.cloudfoundry.uaa.clients.ListMetadatasRequest) BatchDeleteClientsRequest(org.cloudfoundry.uaa.clients.BatchDeleteClientsRequest) ListClientsResponse(org.cloudfoundry.uaa.clients.ListClientsResponse) GetMetadataRequest(org.cloudfoundry.uaa.clients.GetMetadataRequest) REFRESH_TOKEN(org.cloudfoundry.uaa.tokens.GrantType.REFRESH_TOKEN) CreateClientAction(org.cloudfoundry.uaa.clients.CreateClientAction) AsciiString(io.netty.util.AsciiString) StepVerifier(reactor.test.StepVerifier) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with Client

use of org.cloudfoundry.uaa.clients.Client in project cf-java-client by cloudfoundry.

the class ClientsTest method batchDelete.

@Test
public void batchDelete() {
    String clientId1 = this.nameFactory.getClientId();
    String clientId2 = this.nameFactory.getClientId();
    String clientSecret = this.nameFactory.getClientSecret();
    batchCreateClients(this.uaaClient, clientId1, clientId2, clientSecret).flatMapIterable(BatchCreateClientsResponse::getClients).map(Client::getClientId).collectList().flatMap(clientIds -> this.uaaClient.clients().batchDelete(BatchDeleteClientsRequest.builder().clientIds(clientIds).build())).thenMany(requestListClients(this.uaaClient)).filter(client -> clientId1.equals(client.getClientId()) || clientId2.equals(client.getClientId())).as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : UpdateMetadataResponse(org.cloudfoundry.uaa.clients.UpdateMetadataResponse) UpdateSecretAction(org.cloudfoundry.uaa.clients.UpdateSecretAction) StepVerifier(reactor.test.StepVerifier) UpdateClient(org.cloudfoundry.uaa.clients.UpdateClient) Client(org.cloudfoundry.uaa.clients.Client) DeleteClientRequest(org.cloudfoundry.uaa.clients.DeleteClientRequest) BatchUpdateClientsRequest(org.cloudfoundry.uaa.clients.BatchUpdateClientsRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IMPLICIT(org.cloudfoundry.uaa.tokens.GrantType.IMPLICIT) GetClientRequest(org.cloudfoundry.uaa.clients.GetClientRequest) CLIENT_CREDENTIALS(org.cloudfoundry.uaa.tokens.GrantType.CLIENT_CREDENTIALS) AsciiString(io.netty.util.AsciiString) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) UpdateMetadataRequest(org.cloudfoundry.uaa.clients.UpdateMetadataRequest) PASSWORD(org.cloudfoundry.uaa.tokens.GrantType.PASSWORD) MixedActionsRequest(org.cloudfoundry.uaa.clients.MixedActionsRequest) UpdateClientAction(org.cloudfoundry.uaa.clients.UpdateClientAction) Duration(java.time.Duration) PaginationUtils(org.cloudfoundry.util.PaginationUtils) UpdateSecretClientAction(org.cloudfoundry.uaa.clients.UpdateSecretClientAction) BatchChangeSecretResponse(org.cloudfoundry.uaa.clients.BatchChangeSecretResponse) CreateClientResponse(org.cloudfoundry.uaa.clients.CreateClientResponse) ListMetadatasResponse(org.cloudfoundry.uaa.clients.ListMetadatasResponse) BatchCreateClientsResponse(org.cloudfoundry.uaa.clients.BatchCreateClientsResponse) ListClientsRequest(org.cloudfoundry.uaa.clients.ListClientsRequest) UpdateClientRequest(org.cloudfoundry.uaa.clients.UpdateClientRequest) BatchUpdateClientsResponse(org.cloudfoundry.uaa.clients.BatchUpdateClientsResponse) GetMetadataResponse(org.cloudfoundry.uaa.clients.GetMetadataResponse) CreateClient(org.cloudfoundry.uaa.clients.CreateClient) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) BatchCreateClientsRequest(org.cloudfoundry.uaa.clients.BatchCreateClientsRequest) Flux(reactor.core.publisher.Flux) BatchChangeSecretRequest(org.cloudfoundry.uaa.clients.BatchChangeSecretRequest) Base64(java.util.Base64) DeleteClientAction(org.cloudfoundry.uaa.clients.DeleteClientAction) ChangeSecret(org.cloudfoundry.uaa.clients.ChangeSecret) ChangeSecretRequest(org.cloudfoundry.uaa.clients.ChangeSecretRequest) CreateClientRequest(org.cloudfoundry.uaa.clients.CreateClientRequest) ListMetadatasRequest(org.cloudfoundry.uaa.clients.ListMetadatasRequest) BatchDeleteClientsRequest(org.cloudfoundry.uaa.clients.BatchDeleteClientsRequest) ListClientsResponse(org.cloudfoundry.uaa.clients.ListClientsResponse) GetMetadataRequest(org.cloudfoundry.uaa.clients.GetMetadataRequest) REFRESH_TOKEN(org.cloudfoundry.uaa.tokens.GrantType.REFRESH_TOKEN) CreateClientAction(org.cloudfoundry.uaa.clients.CreateClientAction) BatchCreateClientsResponse(org.cloudfoundry.uaa.clients.BatchCreateClientsResponse) AsciiString(io.netty.util.AsciiString) StepVerifier(reactor.test.StepVerifier) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 3 with Client

use of org.cloudfoundry.uaa.clients.Client in project cf-java-client by cloudfoundry.

the class ClientsTest method changeSecret.

@Test
public void changeSecret() {
    String clientId = this.nameFactory.getClientId();
    String newClientSecret = this.nameFactory.getClientSecret();
    String oldClientSecret = this.nameFactory.getClientSecret();
    requestCreateClient(this.uaaClient, clientId, oldClientSecret).then(this.uaaClient.clients().changeSecret(ChangeSecretRequest.builder().clientId(clientId).oldSecret(oldClientSecret).secret(newClientSecret).build())).as(StepVerifier::create).consumeErrorWith(t -> assertThat(t).isInstanceOf(UaaException.class).hasMessage("invalid_client: Only a client can change client secret")).verify(Duration.ofMinutes(5));
}
Also used : UpdateMetadataResponse(org.cloudfoundry.uaa.clients.UpdateMetadataResponse) UpdateSecretAction(org.cloudfoundry.uaa.clients.UpdateSecretAction) StepVerifier(reactor.test.StepVerifier) UpdateClient(org.cloudfoundry.uaa.clients.UpdateClient) Client(org.cloudfoundry.uaa.clients.Client) DeleteClientRequest(org.cloudfoundry.uaa.clients.DeleteClientRequest) BatchUpdateClientsRequest(org.cloudfoundry.uaa.clients.BatchUpdateClientsRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IMPLICIT(org.cloudfoundry.uaa.tokens.GrantType.IMPLICIT) GetClientRequest(org.cloudfoundry.uaa.clients.GetClientRequest) CLIENT_CREDENTIALS(org.cloudfoundry.uaa.tokens.GrantType.CLIENT_CREDENTIALS) AsciiString(io.netty.util.AsciiString) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) UpdateMetadataRequest(org.cloudfoundry.uaa.clients.UpdateMetadataRequest) PASSWORD(org.cloudfoundry.uaa.tokens.GrantType.PASSWORD) MixedActionsRequest(org.cloudfoundry.uaa.clients.MixedActionsRequest) UpdateClientAction(org.cloudfoundry.uaa.clients.UpdateClientAction) Duration(java.time.Duration) PaginationUtils(org.cloudfoundry.util.PaginationUtils) UpdateSecretClientAction(org.cloudfoundry.uaa.clients.UpdateSecretClientAction) BatchChangeSecretResponse(org.cloudfoundry.uaa.clients.BatchChangeSecretResponse) CreateClientResponse(org.cloudfoundry.uaa.clients.CreateClientResponse) ListMetadatasResponse(org.cloudfoundry.uaa.clients.ListMetadatasResponse) BatchCreateClientsResponse(org.cloudfoundry.uaa.clients.BatchCreateClientsResponse) ListClientsRequest(org.cloudfoundry.uaa.clients.ListClientsRequest) UpdateClientRequest(org.cloudfoundry.uaa.clients.UpdateClientRequest) BatchUpdateClientsResponse(org.cloudfoundry.uaa.clients.BatchUpdateClientsResponse) GetMetadataResponse(org.cloudfoundry.uaa.clients.GetMetadataResponse) CreateClient(org.cloudfoundry.uaa.clients.CreateClient) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) BatchCreateClientsRequest(org.cloudfoundry.uaa.clients.BatchCreateClientsRequest) Flux(reactor.core.publisher.Flux) BatchChangeSecretRequest(org.cloudfoundry.uaa.clients.BatchChangeSecretRequest) Base64(java.util.Base64) DeleteClientAction(org.cloudfoundry.uaa.clients.DeleteClientAction) ChangeSecret(org.cloudfoundry.uaa.clients.ChangeSecret) ChangeSecretRequest(org.cloudfoundry.uaa.clients.ChangeSecretRequest) CreateClientRequest(org.cloudfoundry.uaa.clients.CreateClientRequest) ListMetadatasRequest(org.cloudfoundry.uaa.clients.ListMetadatasRequest) BatchDeleteClientsRequest(org.cloudfoundry.uaa.clients.BatchDeleteClientsRequest) ListClientsResponse(org.cloudfoundry.uaa.clients.ListClientsResponse) GetMetadataRequest(org.cloudfoundry.uaa.clients.GetMetadataRequest) REFRESH_TOKEN(org.cloudfoundry.uaa.tokens.GrantType.REFRESH_TOKEN) CreateClientAction(org.cloudfoundry.uaa.clients.CreateClientAction) AsciiString(io.netty.util.AsciiString) StepVerifier(reactor.test.StepVerifier) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

AsciiString (io.netty.util.AsciiString)3 Duration (java.time.Duration)3 Base64 (java.util.Base64)3 TimeoutException (java.util.concurrent.TimeoutException)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 AbstractIntegrationTest (org.cloudfoundry.AbstractIntegrationTest)3 BatchChangeSecretRequest (org.cloudfoundry.uaa.clients.BatchChangeSecretRequest)3 BatchChangeSecretResponse (org.cloudfoundry.uaa.clients.BatchChangeSecretResponse)3 BatchCreateClientsRequest (org.cloudfoundry.uaa.clients.BatchCreateClientsRequest)3 BatchCreateClientsResponse (org.cloudfoundry.uaa.clients.BatchCreateClientsResponse)3 BatchDeleteClientsRequest (org.cloudfoundry.uaa.clients.BatchDeleteClientsRequest)3 BatchUpdateClientsRequest (org.cloudfoundry.uaa.clients.BatchUpdateClientsRequest)3 BatchUpdateClientsResponse (org.cloudfoundry.uaa.clients.BatchUpdateClientsResponse)3 ChangeSecret (org.cloudfoundry.uaa.clients.ChangeSecret)3 ChangeSecretRequest (org.cloudfoundry.uaa.clients.ChangeSecretRequest)3 Client (org.cloudfoundry.uaa.clients.Client)3 CreateClient (org.cloudfoundry.uaa.clients.CreateClient)3 CreateClientAction (org.cloudfoundry.uaa.clients.CreateClientAction)3 CreateClientRequest (org.cloudfoundry.uaa.clients.CreateClientRequest)3 CreateClientResponse (org.cloudfoundry.uaa.clients.CreateClientResponse)3