Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ private static Mono<Void> updateServicePlansPublicStatus(CloudFoundryClient clou
}

return Flux.fromIterable(servicePlans)
.filter(servicePlan -> isUpdateableServicePlan(request.getServicePlanName(), servicePlan))
.filter(servicePlan -> !ResourceUtils.getEntity(servicePlan).getPubliclyVisible())
.flatMap(servicePlan -> requestUpdateServicePlanPublicStatus(cloudFoundryClient, true, ResourceUtils.getId(servicePlan)))
.then();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,45 @@ public void enableServiceAccessSpecifyServicePlan() {
.verify(Duration.ofSeconds(5));
}

@Test
public void enableServiceAccessSpecifyServicePlanWithoutPublicVisibility() {
ServicePlanResource servicePlan1 = fill(ServicePlanResource.builder(), "service-plan-")
.metadata(fill(Metadata.builder(), "service-plan-")
.id("test-service-plan-id-1")
.build())
.entity(fill(ServicePlanEntity.builder(), "service-plan-")
.name("test-service-plan-name-1")
.serviceId("test-service-id")
.publiclyVisible(false)
.build())
.build();
ServicePlanResource servicePlan2 = fill(ServicePlanResource.builder(), "service-plan-")
.metadata(fill(Metadata.builder(), "service-plan-")
.id("test-service-plan-id-2")
.build())
.entity(fill(ServicePlanEntity.builder(), "service-plan-")
.name("test-service-plan-name-2")
.serviceId("test-service-id")
.publiclyVisible(false)
.build())
.build();

requestListServicesWithName(this.cloudFoundryClient, "test-service-name");
requestListServicePlans(this.cloudFoundryClient, "test-service-id", servicePlan1, servicePlan2);
requestListServicePlanVisibilities(this.cloudFoundryClient, "test-service-plan-id-1");
requestDeleteServicePlanVisibility(this.cloudFoundryClient, "test-service-plan-visibility-id");
requestUpdateServicePlan(this.cloudFoundryClient, "test-service-plan-id-1");

this.serviceAdmin
.enableServiceAccess(EnableServiceAccessRequest.builder()
.serviceName("test-service-name")
.servicePlanName("test-service-plan-name-1")
.build())
.as(StepVerifier::create)
.expectComplete()
.verify(Duration.ofSeconds(5));
}

@Test
public void listServiceAccessSettings() {
requestListServiceBrokers(this.cloudFoundryClient);
Expand Down Expand Up @@ -550,6 +589,15 @@ private static void requestDeleteServicePlanVisibility(CloudFoundryClient cloudF
.thenReturn(Mono.empty());
}

private static void requestUpdateServicePlan(CloudFoundryClient cloudFoundryClient, String servicePlanId) {
when(cloudFoundryClient.servicePlans()
.update(UpdateServicePlanRequest.builder()
.publiclyVisible(true)
.servicePlanId(servicePlanId)
.build()))
.thenReturn(Mono.empty());
}

private static void requestGetOrganization(CloudFoundryClient cloudFoundryClient, String organizationId) {
when(cloudFoundryClient.organizations()
.get(GetOrganizationRequest.builder()
Expand Down Expand Up @@ -699,18 +747,23 @@ private static void requestListServicePlanVisibilitiesEmpty(CloudFoundryClient c
}

private static void requestListServicePlans(CloudFoundryClient cloudFoundryClient, String serviceId) {
ServicePlanResource resource = fill(ServicePlanResource.builder(), "service-plan-")
.entity(fill(ServicePlanEntity.builder(), "service-plan-")
.serviceId("test-service-id")
.build())
.build();
requestListServicePlans(cloudFoundryClient, serviceId, resource);
}

private static void requestListServicePlans(CloudFoundryClient cloudFoundryClient, String serviceId, ServicePlanResource... resources) {
when(cloudFoundryClient.servicePlans()
.list(ListServicePlansRequest.builder()
.page(1)
.serviceId(serviceId)
.build()))
.thenReturn(Mono
.just(fill(ListServicePlansResponse.builder())
.resource(fill(ServicePlanResource.builder(), "service-plan-")
.entity(fill(ServicePlanEntity.builder(), "service-plan-")
.serviceId("test-service-id")
.build())
.build())
.resources(resources)
.build()));
}

Expand Down