From 5b8367b567d45478663b74b8b8ef104815ad4a78 Mon Sep 17 00:00:00 2001 From: Sebastien Bortolussi Date: Tue, 31 Jan 2017 17:09:10 +0100 Subject: [PATCH] Add support for volume mount These changes add support for volume mount. Static cred broker may return, in the create instance response, data required for configuration with volume_mount . [#31] --- README.md | 35 +++- pom.xml | 11 +- .../staticcreds/domain/CatalogSettings.java | 36 +++- ...ava => CredentialsServicePlanBinding.java} | 3 +- .../staticcreds/domain/Plan.java | 20 ++- .../staticcreds/domain/Service.java | 12 +- .../domain/ServicePlanBinding.java | 22 +++ ...java => ServicePlanBindingRepository.java} | 4 +- .../domain/SharedVolumeDeviceProperties.java | 32 ++++ .../domain/VolumeDeviceProperties.java | 22 +++ .../domain/VolumeMountProperties.java | 85 +++++++++ .../domain/VolumeServicePlanBinding.java | 38 ++++ ...ingConfigServicePlanBindingRepository.java | 65 +++++++ ...ringConfigServicePlanDetailRepository.java | 44 ----- .../infrastructure/VolumeMountMapper.java | 37 ++++ .../CredsServiceInstanceBindingService.java | 56 ++++-- .../service/CredsServiceInstanceService.java | 12 +- .../java/com/orange/RemoteConfigTest.java | 19 +- .../domain/ConfigureSyslogDrainUrlTest.java | 4 +- ...SpringConfigCredentialsRepositoryTest.java | 12 +- .../infrastructure/VolumeMountMapperTest.java | 58 +++++++ .../CreateLogDrainServiceBindingStage.java | 4 +- ...redsServiceInstanceBindingServiceTest.java | 9 +- .../ConfigureServiceBrokerStage.java | 48 ++++++ ...igureServiceBrokerWithVolumeMountTest.java | 162 ++++++++++++++++++ .../CreateServiceInstanceStage.java | 4 +- ...eateServiceInstanceVolumeBindingStage.java | 55 ++++++ ...reateServiceInstanceVolumeBindingTest.java | 117 +++++++++++++ .../formatter/CatalogYAMLFormatter.java | 5 + ...CreateServiceBindingResponseFormatter.java | 6 +- ...talog.java => ConfigureServiceBroker.java} | 6 +- 31 files changed, 926 insertions(+), 117 deletions(-) rename src/main/java/com/orange/servicebroker/staticcreds/domain/{ServicePlanDetail.java => CredentialsServicePlanBinding.java} (93%) create mode 100644 src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanBinding.java rename src/main/java/com/orange/servicebroker/staticcreds/domain/{ServicePlanDetailRepository.java => ServicePlanBindingRepository.java} (54%) create mode 100644 src/main/java/com/orange/servicebroker/staticcreds/domain/SharedVolumeDeviceProperties.java create mode 100644 src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeDeviceProperties.java create mode 100644 src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeMountProperties.java create mode 100644 src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeServicePlanBinding.java create mode 100644 src/main/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigServicePlanBindingRepository.java delete mode 100644 src/main/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigServicePlanDetailRepository.java create mode 100644 src/main/java/com/orange/servicebroker/staticcreds/infrastructure/VolumeMountMapper.java create mode 100644 src/test/java/com/orange/servicebroker/staticcreds/infrastructure/VolumeMountMapperTest.java create mode 100644 src/test/java/com/orange/servicebroker/staticcreds/stories/configure_service_broker/ConfigureServiceBrokerStage.java create mode 100644 src/test/java/com/orange/servicebroker/staticcreds/stories/configure_service_broker/ConfigureServiceBrokerWithVolumeMountTest.java create mode 100644 src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance_binding/CreateServiceInstanceVolumeBindingStage.java create mode 100644 src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance_binding/CreateServiceInstanceVolumeBindingTest.java rename src/test/java/com/orange/servicebroker/staticcreds/stories/tags/{ConfigureCatalog.java => ConfigureServiceBroker.java} (88%) diff --git a/README.md b/README.md index 39294db..a26e497 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ among the cloudfoundry installation to register with (among orgs and spaces). * SERVICES[{SERVICE_ID}]_TAGS (String holding an array-of-strings, multiple tags are separated by comma, as ```tag1,tag2,tag3```, default is ```[]```) * SERVICES[{SERVICE_ID}]_REQUIRES (String holding an array-of-strings, multiple requires are separated by comma, -as ```syslog_drain, route_forwarding```, default is ```[]```). A list of permissions that the user would have to give the service, if they provision it. The only permission currently supported is syslog_drain. +as ```syslog_drain, volume_mount```, default is ```[]```). A list of permissions that the user would have to give the service, if they provision it. The only permission currently supported is syslog_drain. * SERVICES[{SERVICE_ID}]_DASHBOARD_URL (String, no default). The URL of a web-based management user interface for the service instance. * SERVICES[{SERVICE_ID}]_METADATA_DISPLAY_NAME (String, default is SERVICES_ID_NAME). The user-facing name of the service. * SERVICES[{SERVICE_ID}]_METADATA_IMAGE_URL (String, default is "") @@ -138,9 +138,9 @@ A number of catalog variables are not configureable, the broker always return th * plan_updateable: false * dashboard_client: ````{}```` (empty) -## Bound credentials +## credentials binding -The returned credentials are identical for all bound service instances of a specific plan~~, with at least one define~~. +The returned credentials are identical for all bound service instances of a specific plan. The credentials could be defined for a service, it will be applied for all plans of the service. It is configured by the following environment variables: @@ -165,9 +165,9 @@ the same format as 'cf cups', e.g. ```'{"username":"admin","password":"pa55woRD" This is mapped to [spring-cloud-cloudfoundry-service-broker](https://github.com/spring-cloud/spring-cloud-cloudfoundry-service-broker/blob/master/src%2Fmain%2Fjava%2Forg%2Fspringframework%2Fcloud%2Fservicebroker%2Fmodel%2FCreateServiceInstanceBindingResponse.java#L35) -## Bound syslog_drain_url +## syslog_drain_url binding -The returned syslog_drain_url is identical for all bound service instances of a specific plan~~, with at least one define~~. +The returned syslog_drain_url is identical for all bound service instances of a specific plan. The syslog_drain_url could be defined for a service, it will be applied for all plans of the service. It is configured by the following environment variables: @@ -180,6 +180,31 @@ It is configured by the following environment variables: If syslog_drain_url has been defined, ```SERVICES[{SERVICE_ID}]_REQUIRES``` property with a value ```syslog_drain``` must be declared in the Catalog endpoint or the service broker would consider the configuration invalid. +## volume_mount binding + +The returned volume_mount is identical for all bound service instances of a specific plan. + +The volume_mount could be defined for a service, it will be applied for all plans of the service. +It is configured by the following environment variables: +* SERVICES[{SERVICE_ID}]\_VOLUME_MOUNT[{INDEX}]_CONTAINER_DIR String. +* SERVICES[{SERVICE_ID}]\_VOLUME_MOUNT[{INDEX}]_DRIVER String. +* SERVICES[{SERVICE_ID}]\_VOLUME_MOUNT[{INDEX}]_MODE String. +* SERVICES[{SERVICE_ID}]\_VOLUME_MOUNT[{INDEX}]_DEVICE_TYPE String. +* SERVICES[{SERVICE_ID}]\_VOLUME_MOUNT[{INDEX}]_DEVICE_VOLUME_ID String. +* SERVICES[{SERVICE_ID}]\_VOLUME_MOUNT[{INDEX}]_DEVICE_MOUNT_CONFIG_[{MOUNT_KEY}] String. + +The volume_mount could also be defined for a particular plan, if it contains conflict volume_mount key between the service +volume_mount and plan volume_mount, the values of the plan volume_mount will be taken. +It is configured by the following environment variables: +* SERVICES[{SERVICE_ID}]\_PLANS\[{PLAN_ID}]_VOLUME_MOUNT[{INDEX}]_CONTAINER_DIR String. +* SERVICES[{SERVICE_ID}]\_PLANS\[{PLAN_ID}]_VOLUME_MOUNT[{INDEX}]_DRIVER String. +* SERVICES[{SERVICE_ID}]\_PLANS\[{PLAN_ID}]_VOLUME_MOUNT[{INDEX}]_MODE String. +* SERVICES[{SERVICE_ID}]\_PLANS\[{PLAN_ID}]_VOLUME_MOUNT[{INDEX}]_DEVICE_TYPE String. +* SERVICES[{SERVICE_ID}]\_PLANS\[{PLAN_ID}]_VOLUME_MOUNT[{INDEX}]_DEVICE_VOLUME_ID String. +* SERVICES[{SERVICE_ID}]\_PLANS\[{PLAN_ID}]_VOLUME_MOUNT[{INDEX}]_DEVICE_MOUNT_CONFIG_[{MOUNT_KEY}] String. + +If volume_mount has been defined, ```SERVICES[{SERVICE_ID}]_REQUIRES``` property with a value ```volume_mount``` must be declared in the Catalog endpoint or the service broker would consider the configuration invalid. + ## Authentication The service broker authenticates calls coming from Cloud Foundry through basic auth diff --git a/pom.xml b/pom.xml index 27c0146..05af32c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 static-creds-broker static-creds-broker @@ -19,6 +19,7 @@ 1.16.12 1.4 0.14.0 + 1.5.0 @@ -86,6 +87,12 @@ ${springCloudServiceBrokerVersion} + + ma.glasnost.orika + orika-core + ${orika-core.version} + + org.projectlombok lombok diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/CatalogSettings.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/CatalogSettings.java index 64be09e..fb87497 100644 --- a/src/main/java/com/orange/servicebroker/staticcreds/domain/CatalogSettings.java +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/CatalogSettings.java @@ -2,6 +2,7 @@ import lombok.ToString; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.servicebroker.model.ServiceDefinitionRequires; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; @@ -22,7 +23,6 @@ public class CatalogSettings { public static final String NO_SERVICE_ERROR = "Invalid configuration. No service has been defined"; - public static final String SYSLOG_DRAIN_REQUIRES = "syslog_drain"; @NotNull @Size(min = 1, message = NO_SERVICE_ERROR) @Valid @@ -52,10 +52,11 @@ public void init() { setDefaultPlanDescriptions(); assertPlanCredentialsExists(); assertSyslogDrainUrlRequiresExists(); + assertVolumeMountRequiresExists(); } private void assertPlanCredentialsExists() { - final Predicate planWithoutCredential = plan -> plan.getFullCredentials() == null || plan.getFullCredentials().isEmpty(); + final Predicate planWithoutCredential = plan -> !plan.getFullCredentials().isPresent(); final Predicate serviceWithoutCredential = service -> !service.getFullCredentials().isPresent(); services.values().stream() @@ -77,12 +78,29 @@ private void assertSyslogDrainUrlRequiresExists() { }); } + private void assertVolumeMountRequiresExists() { + services.values().stream() + .flatMap(service -> service.getPlans().values().stream().filter(plan -> volumeMountExists(service, plan) && requiresVolumeMountNotPresent(service))) + .findFirst() + .ifPresent(plan -> { + throw new InvalidVolumeMountException(services); + }); + } + private boolean syslogDrainUrlHasText(Service service, Plan plan) { return plan.getSyslogDrainUrl() != null || service.getSyslogDrainUrl() != null; } private boolean requiresSyslogDrainUrlNotPresent(Service service) { - return service.getRequires() == null || !service.getRequires().contains(SYSLOG_DRAIN_REQUIRES); + return service.getRequires() == null || !service.getRequires().contains(ServiceDefinitionRequires.SERVICE_REQUIRES_SYSLOG_DRAIN.toString()); + } + + private boolean volumeMountExists(Service service, Plan plan) { + return (plan.getVolumeMounts() != null && !plan.getVolumeMounts().isEmpty()) || (service.getVolumeMounts() != null && !service.getVolumeMounts().isEmpty()); + } + + private boolean requiresVolumeMountNotPresent(Service service) { + return service.getRequires() == null || !service.getRequires().contains(ServiceDefinitionRequires.SERVICE_REQUIRES_VOLUME_MOUNT.toString()); } private void setDefaultServiceDisplayName() { @@ -153,7 +171,7 @@ private void setDefaultPlan() { }); } - class NoCredentialException extends IllegalStateException { + public class NoCredentialException extends IllegalStateException { public NoCredentialException(Plan plan) { @@ -161,7 +179,7 @@ public NoCredentialException(Plan plan) { } } - class InvalidSyslogDrainUrlException extends IllegalStateException { + public class InvalidSyslogDrainUrlException extends IllegalStateException { public InvalidSyslogDrainUrlException(Map services) { @@ -169,4 +187,12 @@ public InvalidSyslogDrainUrlException(Map services) { } } + public class InvalidVolumeMountException extends IllegalStateException { + + + public InvalidVolumeMountException(Map services) { + super(String.format("%s includes a volume_mount but \"requires\":[\"volume_mount\"] is not present", services)); + } + } + } diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanDetail.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/CredentialsServicePlanBinding.java similarity index 93% rename from src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanDetail.java rename to src/main/java/com/orange/servicebroker/staticcreds/domain/CredentialsServicePlanBinding.java index 8952394..22e7517 100644 --- a/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanDetail.java +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/CredentialsServicePlanBinding.java @@ -27,7 +27,8 @@ @ToString @EqualsAndHashCode @Builder -public class ServicePlanDetail { +@AllArgsConstructor +public class CredentialsServicePlanBinding extends ServicePlanBinding { /** * The URL to which Cloud Foundry should drain logs for the bound application. diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/Plan.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/Plan.java index 3dd440f..43b4acf 100644 --- a/src/main/java/com/orange/servicebroker/staticcreds/domain/Plan.java +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/Plan.java @@ -11,8 +11,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * Cloud Foundry plan @@ -58,6 +57,11 @@ public class Plan { */ private String dashboardUrl; + /** + * The details of the volume mounts available to applications. + */ + private List volumeMounts = new ArrayList<>(); + public Plan() { } @@ -65,11 +69,15 @@ public Plan(String id) { this.id = id; } - public Map getFullCredentials() { + public Optional> getFullCredentials() { final Map full = new HashMap<>(); - full.putAll(credentials); - full.putAll(credentialsJson); - return full; + if (credentials != null) { + full.putAll(credentials); + } + if (credentialsJson != null) { + full.putAll(credentialsJson); + } + return full.isEmpty() ? Optional.empty() : Optional.of(full); } public void setMetadata(String metadataJson) { diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/Service.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/Service.java index 24e242d..216b113 100644 --- a/src/main/java/com/orange/servicebroker/staticcreds/domain/Service.java +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/Service.java @@ -5,15 +5,13 @@ import lombok.Setter; import lombok.ToString; import org.hibernate.validator.constraints.NotEmpty; +import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.boot.json.JsonParser; import org.springframework.boot.json.JsonParserFactory; import org.springframework.cloud.servicebroker.model.ServiceDefinitionRequires; import javax.validation.Valid; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; /** * Cloud Foundry Service @@ -71,6 +69,12 @@ public class Service { */ private String dashboardUrl; + /** + * The details of the volume mounts available to applications. + */ + @NestedConfigurationProperty + private List volumeMounts = new ArrayList<>(); + public Service() { } diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanBinding.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanBinding.java new file mode 100644 index 0000000..d0943ca --- /dev/null +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanBinding.java @@ -0,0 +1,22 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.domain; + +/** + * @author Sebastien Bortolussi + */ +public class ServicePlanBinding { +} diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanDetailRepository.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanBindingRepository.java similarity index 54% rename from src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanDetailRepository.java rename to src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanBindingRepository.java index 4b74340..4ae5a9a 100644 --- a/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanDetailRepository.java +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/ServicePlanBindingRepository.java @@ -5,8 +5,8 @@ /** * Created by YSBU7453 on 04/04/2016. */ -public interface ServicePlanDetailRepository { +public interface ServicePlanBindingRepository { - Optional find(String servicePlanId); + Optional find(String servicePlanId); } diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/SharedVolumeDeviceProperties.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/SharedVolumeDeviceProperties.java new file mode 100644 index 0000000..548f5cd --- /dev/null +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/SharedVolumeDeviceProperties.java @@ -0,0 +1,32 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SharedVolumeDeviceProperties extends VolumeDeviceProperties { + + private String volumeId; + + private Map mountConfig; +} diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeDeviceProperties.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeDeviceProperties.java new file mode 100644 index 0000000..227beb1 --- /dev/null +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeDeviceProperties.java @@ -0,0 +1,22 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.domain; + +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode +public class VolumeDeviceProperties { +} diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeMountProperties.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeMountProperties.java new file mode 100644 index 0000000..3a86a16 --- /dev/null +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeMountProperties.java @@ -0,0 +1,85 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * Details of a volume mount in a binding response. + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class VolumeMountProperties { + /** + * The name of the volume driver plugin which manages the device. + */ + private String driver; + /** + * The directory to mount inside the application container. + */ + private String containerDir; + /** + * Indicates whether the volume can be mounted in read-only or read-write mode. + */ + private Mode mode; + /** + * The type of the volume device to mount. + */ + private DeviceType deviceType; + /** + * Details of the volume device to mount, specific to the device type. + */ + private SharedVolumeDeviceProperties device; + + public enum Mode { + READ_ONLY("r"), + READ_WRITE("rw"); + + private final String value; + + Mode(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + } + + public enum DeviceType { + /** + * A shared volume mount represents a distributed file system which can be mounted on all app instances + * simultaneously. + */ + SHARED("shared"); + + private final String value; + + DeviceType(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + } +} diff --git a/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeServicePlanBinding.java b/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeServicePlanBinding.java new file mode 100644 index 0000000..94fe83d --- /dev/null +++ b/src/main/java/com/orange/servicebroker/staticcreds/domain/VolumeServicePlanBinding.java @@ -0,0 +1,38 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.domain; + +import lombok.*; + +import java.util.List; + +/** + * Cloud Foundry plan summary + */ +@Getter +@Setter +@ToString +@EqualsAndHashCode +@Builder +public class VolumeServicePlanBinding extends ServicePlanBinding { + + /** + * The details of the volume mounts available to applications. + */ + @Singular + private List volumeMounts; + +} diff --git a/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigServicePlanBindingRepository.java b/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigServicePlanBindingRepository.java new file mode 100644 index 0000000..1893099 --- /dev/null +++ b/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigServicePlanBindingRepository.java @@ -0,0 +1,65 @@ +package com.orange.servicebroker.staticcreds.infrastructure; + +import com.orange.servicebroker.staticcreds.domain.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.servicebroker.model.ServiceDefinitionRequires; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +/** + * Created by YSBU7453 on 03/05/2016. + */ +@Component +public class SpringConfigServicePlanBindingRepository implements ServicePlanBindingRepository { + + private final CatalogSettings catalog; + + @Autowired + public SpringConfigServicePlanBindingRepository(CatalogSettings catalogSettings) { + this.catalog = catalogSettings; + } + + + @Override + public Optional find(String servicePlanId) { + return catalog.getServices().values() + .stream() + .flatMap(service -> service.getPlans().values().stream() + .filter(plan -> servicePlanId.equals(plan.getId())) + .map(plan -> toServicePlanBinding(service, plan)) + ) + .findFirst(); + } + + private ServicePlanBinding toServicePlanBinding(Service service, Plan plan) { + if (isVolumeMountService(service)) { + return toVolumeServicePlanDetail(service, plan); + } else { + return toCredentialsServicePlanBinding(service, plan); + } + } + + private boolean isVolumeMountService(Service service) { + return service.getRequires() == null ? Boolean.FALSE : service.getRequires().contains(ServiceDefinitionRequires.SERVICE_REQUIRES_VOLUME_MOUNT.toString()); + } + + private VolumeServicePlanBinding toVolumeServicePlanDetail(Service service, Plan plan) { + final VolumeServicePlanBinding.VolumeServicePlanBindingBuilder builder = VolumeServicePlanBinding.builder(); + service.getVolumeMounts().forEach(builder::volumeMount); + plan.getVolumeMounts().forEach(builder::volumeMount); + + return builder.build(); + } + + private CredentialsServicePlanBinding toCredentialsServicePlanBinding(Service service, Plan plan) { + final CredentialsServicePlanBinding.CredentialsServicePlanBindingBuilder builder = CredentialsServicePlanBinding.builder(); + builder.syslogDrainUrl(Optional.ofNullable(plan.getSyslogDrainUrl()).map(Optional::of).orElse(Optional.ofNullable(service.getSyslogDrainUrl()))); + builder.dashboardUrl(Optional.ofNullable(plan.getDashboardUrl()).map(Optional::of).orElse(Optional.ofNullable(service.getDashboardUrl()))); + service.getFullCredentials().map(builder::credentials); + plan.getFullCredentials().map(builder::credentials); + + return builder.build(); + } + +} diff --git a/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigServicePlanDetailRepository.java b/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigServicePlanDetailRepository.java deleted file mode 100644 index 3b825d2..0000000 --- a/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigServicePlanDetailRepository.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.orange.servicebroker.staticcreds.infrastructure; - -import com.orange.servicebroker.staticcreds.domain.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Optional; - -/** - * Created by YSBU7453 on 03/05/2016. - */ -@Component -public class SpringConfigServicePlanDetailRepository implements ServicePlanDetailRepository { - - private final CatalogSettings catalog; - - @Autowired - public SpringConfigServicePlanDetailRepository(CatalogSettings catalogSettings) { - this.catalog = catalogSettings; - } - - - @Override - public Optional find(String servicePlanId) { - return catalog.getServices().values() - .stream() - .flatMap(service -> service.getPlans().values().stream() - .filter(plan -> servicePlanId.equals(plan.getId())) - .map(plan -> toServicePlanDetail(service, plan)) - ) - .findFirst(); - } - - private ServicePlanDetail toServicePlanDetail(Service service, Plan plan) { - final ServicePlanDetail.ServicePlanDetailBuilder builder = ServicePlanDetail.builder(); - builder.syslogDrainUrl(Optional.ofNullable(plan.getSyslogDrainUrl()).map(Optional::of).orElse(Optional.ofNullable(service.getSyslogDrainUrl()))); - builder.dashboardUrl(Optional.ofNullable(plan.getDashboardUrl()).map(Optional::of).orElse(Optional.ofNullable(service.getDashboardUrl()))); - service.getFullCredentials().map(builder::credentials); - plan.getFullCredentials().forEach(builder::credential); - - return builder.build(); - } - -} diff --git a/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/VolumeMountMapper.java b/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/VolumeMountMapper.java new file mode 100644 index 0000000..04747dd --- /dev/null +++ b/src/main/java/com/orange/servicebroker/staticcreds/infrastructure/VolumeMountMapper.java @@ -0,0 +1,37 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.infrastructure; + +import com.orange.servicebroker.staticcreds.domain.SharedVolumeDeviceProperties; +import com.orange.servicebroker.staticcreds.domain.VolumeMountProperties; +import ma.glasnost.orika.MapperFactory; +import ma.glasnost.orika.impl.ConfigurableMapper; + +/** + * Created by YSBU7453 on 28/04/2016. + */ +public class VolumeMountMapper extends ConfigurableMapper { + + protected void configure(MapperFactory factory) { + factory.classMap(VolumeMountProperties.class, org.springframework.cloud.servicebroker.model.VolumeMount.class) + .byDefault() + .register(); + factory.classMap(SharedVolumeDeviceProperties.class, org.springframework.cloud.servicebroker.model.SharedVolumeDevice.class) + .byDefault() + .register(); + } + +} diff --git a/src/main/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceBindingService.java b/src/main/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceBindingService.java index e220d17..2a7a654 100644 --- a/src/main/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceBindingService.java +++ b/src/main/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceBindingService.java @@ -1,44 +1,68 @@ package com.orange.servicebroker.staticcreds.service; -import com.orange.servicebroker.staticcreds.domain.ServicePlanDetail; -import com.orange.servicebroker.staticcreds.domain.ServicePlanDetailRepository; +import com.orange.servicebroker.staticcreds.domain.CredentialsServicePlanBinding; +import com.orange.servicebroker.staticcreds.domain.ServicePlanBinding; +import com.orange.servicebroker.staticcreds.domain.ServicePlanBindingRepository; +import com.orange.servicebroker.staticcreds.domain.VolumeServicePlanBinding; +import com.orange.servicebroker.staticcreds.infrastructure.VolumeMountMapper; +import ma.glasnost.orika.MapperFacade; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.servicebroker.model.CreateServiceInstanceAppBindingResponse; -import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingRequest; -import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; -import org.springframework.cloud.servicebroker.model.DeleteServiceInstanceBindingRequest; +import org.springframework.cloud.servicebroker.model.*; import org.springframework.cloud.servicebroker.service.ServiceInstanceBindingService; import org.springframework.stereotype.Service; +import java.util.Arrays; import java.util.Optional; +import java.util.stream.Collectors; @Service public class CredsServiceInstanceBindingService implements ServiceInstanceBindingService { private static final Logger LOGGER = LoggerFactory.getLogger(CredsServiceInstanceService.class); - private ServicePlanDetailRepository servicePlanDetailRepository; + private final ServicePlanBindingRepository servicePlanBindingRepository; + + private final MapperFacade volumeMountMapper = new VolumeMountMapper(); @Autowired - public CredsServiceInstanceBindingService(ServicePlanDetailRepository servicePlanDetailRepository) { - this.servicePlanDetailRepository = servicePlanDetailRepository; + public CredsServiceInstanceBindingService(final ServicePlanBindingRepository servicePlanBindingRepository) { + this.servicePlanBindingRepository = servicePlanBindingRepository; } - private static CreateServiceInstanceBindingResponse toResponse(ServicePlanDetail servicePlanDetail) { + private static CreateServiceInstanceBindingResponse toResponse(CredentialsServicePlanBinding credentialsServicePlanBinding) { return new CreateServiceInstanceAppBindingResponse() - .withCredentials(servicePlanDetail.getCredentials()) - .withSyslogDrainUrl(servicePlanDetail.getSyslogDrainUrl().orElse(null)); + .withCredentials(credentialsServicePlanBinding.getCredentials()) + .withSyslogDrainUrl(credentialsServicePlanBinding.getSyslogDrainUrl().orElse(null)); + } + + private CreateServiceInstanceBindingResponse toResponse(VolumeServicePlanBinding volumeServicePlanDetail) { + return new CreateServiceInstanceVolumeBindingResponse() + .withVolumeMounts(volumeServicePlanDetail.getVolumeMounts().stream() + .map(volumeMount -> volumeMountMapper.map(volumeMount, VolumeMount.class)) + .collect(Collectors.toList())); } @Override public CreateServiceInstanceBindingResponse createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) { LOGGER.debug("binding service instance"); - final Optional planSummary = servicePlanDetailRepository.find(request.getPlanId()); - return planSummary - .map(CredsServiceInstanceBindingService::toResponse) - .orElse(new CreateServiceInstanceAppBindingResponse()); + final Optional servicePlanBinding = servicePlanBindingRepository.find(request.getPlanId()); + + final Optional createServiceInstanceVolumeBindingResponse = servicePlanBinding + .filter(VolumeServicePlanBinding.class::isInstance) + .map(VolumeServicePlanBinding.class::cast) + .map(this::toResponse); + + final Optional createServiceInstanceAppBindingResponse = servicePlanBinding + .filter(CredentialsServicePlanBinding.class::isInstance) + .map(CredentialsServicePlanBinding.class::cast) + .map(CredsServiceInstanceBindingService::toResponse); + + return Arrays.asList(createServiceInstanceVolumeBindingResponse, createServiceInstanceAppBindingResponse).stream() + .filter(Optional::isPresent) + .map(Optional::get) + .findFirst().orElse(new CreateServiceInstanceBindingResponse()); } @Override diff --git a/src/main/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceService.java b/src/main/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceService.java index c393dd0..f7b00a7 100644 --- a/src/main/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceService.java +++ b/src/main/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceService.java @@ -1,7 +1,7 @@ package com.orange.servicebroker.staticcreds.service; -import com.orange.servicebroker.staticcreds.domain.ServicePlanDetail; -import com.orange.servicebroker.staticcreds.domain.ServicePlanDetailRepository; +import com.orange.servicebroker.staticcreds.domain.CredentialsServicePlanBinding; +import com.orange.servicebroker.staticcreds.domain.ServicePlanBindingRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.servicebroker.model.*; @@ -13,13 +13,13 @@ public class CredsServiceInstanceService implements ServiceInstanceService { private static final Logger LOGGER = LoggerFactory.getLogger(CredsServiceInstanceService.class); - private final ServicePlanDetailRepository repository; + private final ServicePlanBindingRepository repository; - public CredsServiceInstanceService(ServicePlanDetailRepository repository) { + public CredsServiceInstanceService(ServicePlanBindingRepository repository) { this.repository = repository; } - private static CreateServiceInstanceResponse toResponse(ServicePlanDetail servicePlanDetail) { + private static CreateServiceInstanceResponse toResponse(CredentialsServicePlanBinding servicePlanDetail) { return new CreateServiceInstanceResponse() .withDashboardUrl(servicePlanDetail.getDashboardUrl().orElse(null)); } @@ -28,6 +28,8 @@ private static CreateServiceInstanceResponse toResponse(ServicePlanDetail servic public CreateServiceInstanceResponse createServiceInstance(CreateServiceInstanceRequest request) { LOGGER.debug("creating service instance"); return repository.find(request.getPlanId()) + .filter(CredentialsServicePlanBinding.class::isInstance) + .map(CredentialsServicePlanBinding.class::cast) .map(CredsServiceInstanceService::toResponse) .orElse(new CreateServiceInstanceResponse()); } diff --git a/src/test/java/com/orange/RemoteConfigTest.java b/src/test/java/com/orange/RemoteConfigTest.java index 81ce2c0..90d27a9 100644 --- a/src/test/java/com/orange/RemoteConfigTest.java +++ b/src/test/java/com/orange/RemoteConfigTest.java @@ -1,7 +1,8 @@ package com.orange; -import com.orange.servicebroker.staticcreds.domain.ServicePlanDetail; -import com.orange.servicebroker.staticcreds.domain.ServicePlanDetailRepository; +import com.orange.servicebroker.staticcreds.domain.CredentialsServicePlanBinding; +import com.orange.servicebroker.staticcreds.domain.ServicePlanBinding; +import com.orange.servicebroker.staticcreds.domain.ServicePlanBindingRepository; import org.fest.assertions.Assertions; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,7 +22,7 @@ */ @RunWith(SpringRunner.class) //"native" profile in the Config Server will not use Git, but just loads the config files from the local classpath or file system -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"security.user.password=pass","spring.profiles.active=native","spring.cloud.config.server.native.searchLocations=classpath:/remote-config"}) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"security.user.password=pass", "spring.profiles.active=native", "spring.cloud.config.server.native.searchLocations=classpath:/remote-config"}) public class RemoteConfigTest { public static final String API_DIRECTORY_SERVICE_PLAN_DEV_ID = "f7ae3ff9-85ed-3515-bef9-2e4d2f572422"; @@ -30,7 +31,7 @@ public class RemoteConfigTest { String serviceApiDirectoryName; @Autowired - ServicePlanDetailRepository servicePlanDetailRepository; + ServicePlanBindingRepository servicePlanBindingRepository; @Autowired Catalog catalog; @@ -40,14 +41,18 @@ public void should_get_remote_config() { Assertions.assertThat(serviceApiDirectoryName).isEqualTo("API_DIRECTORY_test_Service"); } - @Test + @Test public void should_find_a_service_plan() { //service plan id for plan dev of service API_DIRECTORY, see static-creds-broker.yml - final Optional credentials = servicePlanDetailRepository.find(API_DIRECTORY_SERVICE_PLAN_DEV_ID); + final Optional servicePlanBinding = servicePlanBindingRepository.find(API_DIRECTORY_SERVICE_PLAN_DEV_ID); - assertThat(credentials.get().getCredentials()).hasSize(3).includes(entry("HOSTNAME", "http://company.com"),entry("URI", "http://mydev-api.org"), entry("ACCESS_KEY", "devAZERT23456664DFDSFSDFDSF")); + assertThat(servicePlanBinding + .map(CredentialsServicePlanBinding.class::cast) + .get().getCredentials() + ) + .hasSize(3).includes(entry("HOSTNAME", "http://company.com"), entry("URI", "http://mydev-api.org"), entry("ACCESS_KEY", "devAZERT23456664DFDSFSDFDSF")); } diff --git a/src/test/java/com/orange/servicebroker/staticcreds/domain/ConfigureSyslogDrainUrlTest.java b/src/test/java/com/orange/servicebroker/staticcreds/domain/ConfigureSyslogDrainUrlTest.java index 3cc2272..794f09a 100644 --- a/src/test/java/com/orange/servicebroker/staticcreds/domain/ConfigureSyslogDrainUrlTest.java +++ b/src/test/java/com/orange/servicebroker/staticcreds/domain/ConfigureSyslogDrainUrlTest.java @@ -15,7 +15,7 @@ package com.orange.servicebroker.staticcreds.domain; -import com.orange.servicebroker.staticcreds.stories.tags.ConfigureCatalog; +import com.orange.servicebroker.staticcreds.stories.tags.ConfigureServiceBroker; import com.tngtech.jgiven.junit.SimpleScenarioTest; import org.junit.Test; @@ -26,7 +26,7 @@ /** * @author Sebastien Bortolussi */ -@ConfigureCatalog +@ConfigureServiceBroker public class ConfigureSyslogDrainUrlTest extends SimpleScenarioTest { public static final String SYSLOG_DRAIN_REQUIRES = "syslog_drain"; diff --git a/src/test/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigCredentialsRepositoryTest.java b/src/test/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigCredentialsRepositoryTest.java index 3ee50d3..693ecb4 100644 --- a/src/test/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigCredentialsRepositoryTest.java +++ b/src/test/java/com/orange/servicebroker/staticcreds/infrastructure/SpringConfigCredentialsRepositoryTest.java @@ -1,6 +1,7 @@ package com.orange.servicebroker.staticcreds.infrastructure; -import com.orange.servicebroker.staticcreds.domain.ServicePlanDetail; +import com.orange.servicebroker.staticcreds.domain.CredentialsServicePlanBinding; +import com.orange.servicebroker.staticcreds.domain.ServicePlanBinding; import org.junit.Test; import java.util.Optional; @@ -20,11 +21,14 @@ public void plan_credentials_override_service_credentials() throws Exception { //GIVEN credentials have been set at service and plan level //some overlaps - SpringConfigServicePlanDetailRepository repository = new SpringConfigServicePlanDetailRepository(CatalogTestFactory.newInstance()); + SpringConfigServicePlanBindingRepository repository = new SpringConfigServicePlanBindingRepository(CatalogTestFactory.newInstance()); - final Optional planSummary = repository.find(CatalogTestFactory.SERVICE_PLAN_PROD); + final Optional planSummary = repository.find(CatalogTestFactory.SERVICE_PLAN_PROD); - assertThat(planSummary.get().getCredentials()).hasSize(3).includes(entry("HOSTNAME", HOSTNAME_PLAN_PROD_VALUE),entry("URI", "http://myprod-api.org"), entry("ACCESS_KEY", "prod")); + assertThat(planSummary + .map(CredentialsServicePlanBinding.class::cast) + .get().getCredentials() + ).hasSize(3).includes(entry("HOSTNAME", HOSTNAME_PLAN_PROD_VALUE), entry("URI", "http://myprod-api.org"), entry("ACCESS_KEY", "prod")); } diff --git a/src/test/java/com/orange/servicebroker/staticcreds/infrastructure/VolumeMountMapperTest.java b/src/test/java/com/orange/servicebroker/staticcreds/infrastructure/VolumeMountMapperTest.java new file mode 100644 index 0000000..034a140 --- /dev/null +++ b/src/test/java/com/orange/servicebroker/staticcreds/infrastructure/VolumeMountMapperTest.java @@ -0,0 +1,58 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.infrastructure; + +import com.orange.servicebroker.staticcreds.domain.SharedVolumeDeviceProperties; +import com.orange.servicebroker.staticcreds.domain.VolumeMountProperties; +import org.fest.assertions.Assertions; +import org.junit.Test; +import org.springframework.cloud.servicebroker.model.SharedVolumeDevice; +import org.springframework.cloud.servicebroker.model.VolumeMount; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Sebastien Bortolussi + */ +public class VolumeMountMapperTest { + + + private static VolumeMountProperties volumeMountProperties() { + Map mountConfig = new HashMap<>(); + mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions"); + mountConfig.put("attr_timeout", "0"); + mountConfig.put("negative_timeout", "2"); + final SharedVolumeDeviceProperties sharedVolumeDevice = new SharedVolumeDeviceProperties("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig); + return new VolumeMountProperties("nfsv3driver", "/data/images", VolumeMountProperties.Mode.READ_WRITE, VolumeMountProperties.DeviceType.SHARED, sharedVolumeDevice); + } + + private static VolumeMount expected() { + Map mountConfig = new HashMap<>(); + mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions"); + mountConfig.put("attr_timeout", "0"); + mountConfig.put("negative_timeout", "2"); + final SharedVolumeDevice sharedVolumeDevice = new SharedVolumeDevice("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig); + return new VolumeMount("nfsv3driver", "/data/images", VolumeMount.Mode.READ_WRITE, VolumeMount.DeviceType.SHARED, sharedVolumeDevice); + } + + @Test + public void should_map_volume_mount() throws Exception { + VolumeMountMapper mapper = new VolumeMountMapper(); + + Assertions.assertThat(mapper.map(volumeMountProperties(), VolumeMount.class)).isEqualTo(expected()); + } +} \ No newline at end of file diff --git a/src/test/java/com/orange/servicebroker/staticcreds/service/CreateLogDrainServiceBindingStage.java b/src/test/java/com/orange/servicebroker/staticcreds/service/CreateLogDrainServiceBindingStage.java index 11f0cca..059fdde 100644 --- a/src/test/java/com/orange/servicebroker/staticcreds/service/CreateLogDrainServiceBindingStage.java +++ b/src/test/java/com/orange/servicebroker/staticcreds/service/CreateLogDrainServiceBindingStage.java @@ -16,7 +16,7 @@ package com.orange.servicebroker.staticcreds.service; import com.orange.servicebroker.staticcreds.domain.CatalogSettings; -import com.orange.servicebroker.staticcreds.infrastructure.SpringConfigServicePlanDetailRepository; +import com.orange.servicebroker.staticcreds.infrastructure.SpringConfigServicePlanBindingRepository; import com.orange.servicebroker.staticcreds.stories.formatter.CatalogYAML; import com.orange.servicebroker.staticcreds.stories.formatter.CreateServiceBindingResponseJSON; import com.tngtech.jgiven.Stage; @@ -40,7 +40,7 @@ public CreateLogDrainServiceBindingStage cloud_controller_requests_to_create_a_s } public CreateLogDrainServiceBindingStage syslog_drain_url_set_in_catalog(@CatalogYAML CatalogSettings catalog) { - SpringConfigServicePlanDetailRepository planSummaryRepository = new SpringConfigServicePlanDetailRepository(catalog); + SpringConfigServicePlanBindingRepository planSummaryRepository = new SpringConfigServicePlanBindingRepository(catalog); instanceBindingService = new CredsServiceInstanceBindingService(planSummaryRepository); return self(); } diff --git a/src/test/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceBindingServiceTest.java b/src/test/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceBindingServiceTest.java index 37686a5..d28397d 100644 --- a/src/test/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceBindingServiceTest.java +++ b/src/test/java/com/orange/servicebroker/staticcreds/service/CredsServiceInstanceBindingServiceTest.java @@ -18,7 +18,7 @@ import com.orange.servicebroker.staticcreds.domain.CatalogSettings; import com.orange.servicebroker.staticcreds.domain.Plan; import com.orange.servicebroker.staticcreds.domain.Service; -import com.orange.servicebroker.staticcreds.infrastructure.SpringConfigServicePlanDetailRepository; +import com.orange.servicebroker.staticcreds.infrastructure.SpringConfigServicePlanBindingRepository; import org.junit.Test; import org.springframework.cloud.servicebroker.model.CreateServiceInstanceAppBindingResponse; import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingRequest; @@ -44,7 +44,7 @@ public class CredsServiceInstanceBindingServiceTest { @Test public void should_bind_with_credentials_that_have_been_set_for_associated_service_plan() throws Exception { - SpringConfigServicePlanDetailRepository repository = new SpringConfigServicePlanDetailRepository(catalog()); + SpringConfigServicePlanBindingRepository repository = new SpringConfigServicePlanBindingRepository(catalog()); //when I bind my app to a service API_DIRECTORY instance whose plan is dev CredsServiceInstanceBindingService serviceInstanceBindingService = new CredsServiceInstanceBindingService(repository); @@ -80,10 +80,10 @@ private CatalogSettings catalog() { return new CatalogSettings(services); } - +/* @Test public void should_bind_with_no_credentials_if_no_credentials_have_been_set_for_associated_service_plan() throws Exception { - SpringConfigServicePlanDetailRepository repository = new SpringConfigServicePlanDetailRepository(catalog()); + SpringConfigServicePlanBindingRepository repository = new SpringConfigServicePlanBindingRepository(catalog()); //when I bind my app to a service API_DIRECTORY instance whose plan is dummy CredsServiceInstanceBindingService serviceInstanceBindingService = new CredsServiceInstanceBindingService(repository); @@ -94,6 +94,7 @@ public void should_bind_with_no_credentials_if_no_credentials_have_been_set_for_ } + */ private CreateServiceInstanceBindingRequest getCreateServiceInstanceRequestWithServiceAndPlan(String servicePlan) { return new CreateServiceInstanceBindingRequest("serviceDefinitionId", servicePlan, "appGuid", null); diff --git a/src/test/java/com/orange/servicebroker/staticcreds/stories/configure_service_broker/ConfigureServiceBrokerStage.java b/src/test/java/com/orange/servicebroker/staticcreds/stories/configure_service_broker/ConfigureServiceBrokerStage.java new file mode 100644 index 0000000..e7d30f4 --- /dev/null +++ b/src/test/java/com/orange/servicebroker/staticcreds/stories/configure_service_broker/ConfigureServiceBrokerStage.java @@ -0,0 +1,48 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.stories.configure_service_broker; + +import com.orange.servicebroker.staticcreds.domain.CatalogSettings; +import com.orange.servicebroker.staticcreds.stories.formatter.CatalogYAML; +import com.tngtech.jgiven.Stage; +import org.assertj.core.api.Assertions; + +/** + * @author Sebastien Bortolussi + */ +public class ConfigureServiceBrokerStage extends Stage { + + private CatalogSettings.InvalidVolumeMountException invalidVolumeMountException; + + public ConfigureServiceBrokerStage paas_ops_configures_service_broker_with_following_config(@CatalogYAML CatalogSettings catalogSettings) { + try { + catalogSettings.init(); + } catch (CatalogSettings.InvalidVolumeMountException e) { + invalidVolumeMountException = e; + } + return self(); + } + + public ConfigureServiceBrokerStage it_should_succeed() { + Assertions.assertThat(invalidVolumeMountException).isNull(); + return self(); + } + + public ConfigureServiceBrokerStage it_should_fail() { + Assertions.assertThat(invalidVolumeMountException).isNotNull(); + return self(); + } +} diff --git a/src/test/java/com/orange/servicebroker/staticcreds/stories/configure_service_broker/ConfigureServiceBrokerWithVolumeMountTest.java b/src/test/java/com/orange/servicebroker/staticcreds/stories/configure_service_broker/ConfigureServiceBrokerWithVolumeMountTest.java new file mode 100644 index 0000000..22cc603 --- /dev/null +++ b/src/test/java/com/orange/servicebroker/staticcreds/stories/configure_service_broker/ConfigureServiceBrokerWithVolumeMountTest.java @@ -0,0 +1,162 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.stories.configure_service_broker; + +import com.orange.servicebroker.staticcreds.domain.*; +import com.orange.servicebroker.staticcreds.stories.tags.ConfigureServiceBroker; +import com.tngtech.jgiven.junit.SimpleScenarioTest; +import org.junit.Test; +import org.springframework.cloud.servicebroker.model.ServiceDefinitionRequires; +import org.springframework.cloud.servicebroker.model.SharedVolumeDevice; +import org.springframework.cloud.servicebroker.model.VolumeMount; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Sebastien Bortolussi + */ +@ConfigureServiceBroker +public class ConfigureServiceBrokerWithVolumeMountTest extends SimpleScenarioTest { + + private static CatalogSettings catalog_with_volume_mount_at_service_level_and_requires_field_set() { + Plan dev = new Plan("dev"); + dev.setId("dev-id"); + dev.setCredentials(uriCredentials()); + + Service myService = new Service(); + myService.setName("myservice"); + myService.setId("myservice-id"); + myService.setRequires(Arrays.asList(ServiceDefinitionRequires.SERVICE_REQUIRES_VOLUME_MOUNT.toString())); + myService.setVolumeMounts(Arrays.asList(nfsv3SharedVolumeMount())); + final Map myServicePlans = new HashMap<>(); + myServicePlans.put("dev", dev); + myService.setPlans(myServicePlans); + + final Map services = new HashMap<>(); + services.put("myservice", myService); + + return new CatalogSettings(services); + } + + private static Map uriCredentials() { + Map credentials = new HashMap<>(); + credentials.put("URI", "http://my-api.org"); + return credentials; + } + + private static VolumeMountProperties nfsv3SharedVolumeMount() { + Map mountConfig = new HashMap<>(); + mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions"); + mountConfig.put("attr_timeout", "0"); + mountConfig.put("negative_timeout", "2"); + final SharedVolumeDeviceProperties sharedVolumeDevice = new SharedVolumeDeviceProperties("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig); + return new VolumeMountProperties("nfsv3driver", "/data/images", VolumeMountProperties.Mode.READ_WRITE, VolumeMountProperties.DeviceType.SHARED, sharedVolumeDevice); + } + + private static VolumeMount expectedVolumeMount() { + Map mountConfig = new HashMap<>(); + mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions"); + mountConfig.put("attr_timeout", "0"); + mountConfig.put("negative_timeout", "2"); + final SharedVolumeDevice sharedVolumeDevice = new SharedVolumeDevice("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig); + return new VolumeMount("nfsv3driver", "/data/images", VolumeMount.Mode.READ_WRITE, VolumeMount.DeviceType.SHARED, sharedVolumeDevice); + } + + private static CatalogSettings catalog_with_volume_mount_at_service_plan_level_and_requires_field_set() { + Plan dev = new Plan("dev"); + dev.setId("dev-id"); + dev.setCredentials(uriCredentials()); + dev.setVolumeMounts(Arrays.asList(nfsv3SharedVolumeMount())); + + Service myService = new Service(); + myService.setName("myservice"); + myService.setId("myservice-id"); + myService.setRequires(Arrays.asList(ServiceDefinitionRequires.SERVICE_REQUIRES_VOLUME_MOUNT.toString())); + final Map myServicePlans = new HashMap<>(); + myServicePlans.put("dev", dev); + myService.setPlans(myServicePlans); + + final Map services = new HashMap<>(); + services.put("myservice", myService); + + return new CatalogSettings(services); + } + + private static CatalogSettings catalog_with_volume_mount_at_service_level_but_without_requires_field_set() { + Plan dev = new Plan("dev"); + dev.setId("dev-id"); + dev.setCredentials(uriCredentials()); + + Service myService = new Service(); + myService.setName("myservice"); + myService.setId("myservice-id"); + myService.setVolumeMounts(Arrays.asList(nfsv3SharedVolumeMount())); + final Map myServicePlans = new HashMap<>(); + myServicePlans.put("dev", dev); + myService.setPlans(myServicePlans); + + final Map services = new HashMap<>(); + services.put("myservice", myService); + + return new CatalogSettings(services); + } + + private static CatalogSettings catalog_with_volume_mount_at_service_plan_level_but_without_requires_field_set() { + Plan dev = new Plan("dev"); + dev.setId("dev-id"); + dev.setCredentials(uriCredentials()); + dev.setVolumeMounts(Arrays.asList(nfsv3SharedVolumeMount())); + + Service myService = new Service(); + myService.setName("myservice"); + myService.setId("myservice-id"); + final Map myServicePlans = new HashMap<>(); + myServicePlans.put("dev", dev); + myService.setPlans(myServicePlans); + + final Map services = new HashMap<>(); + services.put("myservice", myService); + + return new CatalogSettings(services); + } + + + @Test + public void configure_service_broker_with_same_volume_mount_for_all_service_plans_and_requires_field_set() throws Exception { + when().paas_ops_configures_service_broker_with_following_config(catalog_with_volume_mount_at_service_level_and_requires_field_set()); + then().it_should_succeed(); + } + + @Test + public void configure_service_broker_with_same_volume_mount_for_all_service_plans_but_omits_requires_field() throws Exception { + when().paas_ops_configures_service_broker_with_following_config(catalog_with_volume_mount_at_service_level_but_without_requires_field_set()); + then().it_should_fail(); + } + + @Test + public void configure_service_broker_with_volume_mount_set_for_a_service_plan_and_requires_field_set() throws Exception { + when().paas_ops_configures_service_broker_with_following_config(catalog_with_volume_mount_at_service_plan_level_and_requires_field_set()); + then().it_should_succeed(); + } + + @Test + public void configure_service_broker_with_volume_mount_set_for_a_service_plan_but_omits_requires_field() throws Exception { + when().paas_ops_configures_service_broker_with_following_config(catalog_with_volume_mount_at_service_plan_level_but_without_requires_field_set()); + then().it_should_fail(); + } +} diff --git a/src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance/CreateServiceInstanceStage.java b/src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance/CreateServiceInstanceStage.java index 63c45f5..bddce04 100644 --- a/src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance/CreateServiceInstanceStage.java +++ b/src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance/CreateServiceInstanceStage.java @@ -16,7 +16,7 @@ package com.orange.servicebroker.staticcreds.stories.create_service_instance; import com.orange.servicebroker.staticcreds.domain.CatalogSettings; -import com.orange.servicebroker.staticcreds.infrastructure.SpringConfigServicePlanDetailRepository; +import com.orange.servicebroker.staticcreds.infrastructure.SpringConfigServicePlanBindingRepository; import com.orange.servicebroker.staticcreds.service.CredsServiceInstanceService; import com.orange.servicebroker.staticcreds.stories.formatter.CatalogYAML; import com.orange.servicebroker.staticcreds.stories.formatter.CreateServiceInstanceResponseJSON; @@ -34,7 +34,7 @@ public class CreateServiceInstanceStage extends Stage { + + private CredsServiceInstanceBindingService instanceBindingService; + private CreateServiceInstanceBindingResponse response; + + public CreateServiceInstanceVolumeBindingStage cloud_controller_requests_to_create_a_service_instance_binding_for_plan_id(String servicePlanId) { + final CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest("myservice-id", servicePlanId, "app-id", null); + response = instanceBindingService.createServiceInstanceBinding(request); + return self(); + } + + public CreateServiceInstanceVolumeBindingStage catalog_with_volume_mount(@CatalogYAML CatalogSettings catalog) { + SpringConfigServicePlanBindingRepository planSummaryRepository = new SpringConfigServicePlanBindingRepository(catalog); + instanceBindingService = new CredsServiceInstanceBindingService(planSummaryRepository); + return self(); + } + + public CreateServiceInstanceVolumeBindingStage it_should_be_returned_with_volume_mount(@CreateServiceBindingResponseJSON CreateServiceInstanceVolumeBindingResponse expected) { + Assertions.assertThat(response).isInstanceOf(CreateServiceInstanceVolumeBindingResponse.class); + Assertions.assertThat(response).isEqualTo(expected); + return self(); + } + +} diff --git a/src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance_binding/CreateServiceInstanceVolumeBindingTest.java b/src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance_binding/CreateServiceInstanceVolumeBindingTest.java new file mode 100644 index 0000000..acadbea --- /dev/null +++ b/src/test/java/com/orange/servicebroker/staticcreds/stories/create_service_instance_binding/CreateServiceInstanceVolumeBindingTest.java @@ -0,0 +1,117 @@ +/* + * * + * * Copyright (C) 2015 Orange + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.orange.servicebroker.staticcreds.stories.create_service_instance_binding; + +import com.orange.servicebroker.staticcreds.domain.*; +import com.orange.servicebroker.staticcreds.stories.tags.CreateServiceBinding; +import com.tngtech.jgiven.junit.SimpleScenarioTest; +import org.junit.Test; +import org.springframework.cloud.servicebroker.model.CreateServiceInstanceVolumeBindingResponse; +import org.springframework.cloud.servicebroker.model.ServiceDefinitionRequires; +import org.springframework.cloud.servicebroker.model.SharedVolumeDevice; +import org.springframework.cloud.servicebroker.model.VolumeMount; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Sebastien Bortolussi + */ +@CreateServiceBinding +public class CreateServiceInstanceVolumeBindingTest extends SimpleScenarioTest { + + private static CatalogSettings catalog_with_same_volume_mount_for_all_service_plans() { + Plan dev = new Plan("dev"); + dev.setId("dev-id"); + dev.setCredentials(uriCredentials()); + + Service myService = new Service(); + myService.setName("myservice"); + myService.setId("myservice-id"); + myService.setRequires(Arrays.asList(ServiceDefinitionRequires.SERVICE_REQUIRES_VOLUME_MOUNT.toString())); + myService.setVolumeMounts(Arrays.asList(nfsv3SharedVolumeMount())); + final Map myServicePlans = new HashMap<>(); + myServicePlans.put("dev", dev); + myService.setPlans(myServicePlans); + + final Map services = new HashMap<>(); + services.put("myservice", myService); + + return new CatalogSettings(services); + } + + private static Map uriCredentials() { + Map credentials = new HashMap<>(); + credentials.put("URI", "http://my-api.org"); + return credentials; + } + + private static VolumeMountProperties nfsv3SharedVolumeMount() { + Map mountConfig = new HashMap<>(); + mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions"); + mountConfig.put("attr_timeout", "0"); + mountConfig.put("negative_timeout", "2"); + final SharedVolumeDeviceProperties sharedVolumeDevice = new SharedVolumeDeviceProperties("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig); + return new VolumeMountProperties("nfsv3driver", "/data/images", VolumeMountProperties.Mode.READ_WRITE, VolumeMountProperties.DeviceType.SHARED, sharedVolumeDevice); + } + + private static CatalogSettings catalog_with_volume_mount_set_for_a_service_plan() { + Plan dev = new Plan("dev"); + dev.setId("dev-id"); + dev.setCredentials(uriCredentials()); + dev.setVolumeMounts(Arrays.asList(nfsv3SharedVolumeMount())); + + Service myService = new Service(); + myService.setName("myservice"); + myService.setId("myservice-id"); + myService.setRequires(Arrays.asList(ServiceDefinitionRequires.SERVICE_REQUIRES_VOLUME_MOUNT.toString())); + final Map myServicePlans = new HashMap<>(); + myServicePlans.put("dev", dev); + myService.setPlans(myServicePlans); + + final Map services = new HashMap<>(); + services.put("myservice", myService); + + return new CatalogSettings(services); + } + + private static VolumeMount expectedNfsv3SharedVolumeMount() { + Map mountConfig = new HashMap<>(); + mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions"); + mountConfig.put("attr_timeout", "0"); + mountConfig.put("negative_timeout", "2"); + final SharedVolumeDevice sharedVolumeDevice = new SharedVolumeDevice("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig); + return new VolumeMount("nfsv3driver", "/data/images", VolumeMount.Mode.READ_WRITE, VolumeMount.DeviceType.SHARED, sharedVolumeDevice); + } + + @Test + public void create_volume_service_binding_with_volume_mount_set_for_all_service_plans() throws Exception { + given().catalog_with_volume_mount(catalog_with_same_volume_mount_for_all_service_plans()); + when().cloud_controller_requests_to_create_a_service_instance_binding_for_plan_id("dev-id"); + then().it_should_be_returned_with_volume_mount(new CreateServiceInstanceVolumeBindingResponse() + .withVolumeMounts(Arrays.asList(expectedNfsv3SharedVolumeMount()))); + } + + @Test + public void create_volume_service_binding_with_volume_mount_set_for_a_service_plan() throws Exception { + given().catalog_with_volume_mount(catalog_with_volume_mount_set_for_a_service_plan()); + when().cloud_controller_requests_to_create_a_service_instance_binding_for_plan_id("dev-id"); + then().it_should_be_returned_with_volume_mount(new CreateServiceInstanceVolumeBindingResponse() + .withVolumeMounts(Arrays.asList(expectedNfsv3SharedVolumeMount()))); + } + +} diff --git a/src/test/java/com/orange/servicebroker/staticcreds/stories/formatter/CatalogYAMLFormatter.java b/src/test/java/com/orange/servicebroker/staticcreds/stories/formatter/CatalogYAMLFormatter.java index ed1dc8f..ab63022 100644 --- a/src/test/java/com/orange/servicebroker/staticcreds/stories/formatter/CatalogYAMLFormatter.java +++ b/src/test/java/com/orange/servicebroker/staticcreds/stories/formatter/CatalogYAMLFormatter.java @@ -17,8 +17,10 @@ import com.orange.servicebroker.staticcreds.domain.CatalogSettings; import com.tngtech.jgiven.format.ArgumentFormatter; +import org.springframework.cloud.servicebroker.model.SharedVolumeDevice; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.introspector.BeanAccess; import org.yaml.snakeyaml.introspector.Property; import org.yaml.snakeyaml.nodes.*; import org.yaml.snakeyaml.representer.Representer; @@ -35,8 +37,11 @@ public String format(CatalogSettings catalogSettings, String... strings) { final SkipNullEmptyRepresenter representer = new SkipNullEmptyRepresenter(); representer.addClassTag(CatalogSettings.class, Tag.MAP); + representer.addClassTag(SharedVolumeDevice.class, Tag.MAP); + Yaml yaml = new Yaml(representer, options); + yaml.setBeanAccess(BeanAccess.FIELD); return yaml.dump(catalogSettings); } diff --git a/src/test/java/com/orange/servicebroker/staticcreds/stories/formatter/CreateServiceBindingResponseFormatter.java b/src/test/java/com/orange/servicebroker/staticcreds/stories/formatter/CreateServiceBindingResponseFormatter.java index c75e2ac..179b50b 100644 --- a/src/test/java/com/orange/servicebroker/staticcreds/stories/formatter/CreateServiceBindingResponseFormatter.java +++ b/src/test/java/com/orange/servicebroker/staticcreds/stories/formatter/CreateServiceBindingResponseFormatter.java @@ -18,15 +18,15 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.tngtech.jgiven.format.ArgumentFormatter; -import org.springframework.cloud.servicebroker.model.CreateServiceInstanceAppBindingResponse; +import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; /** * General formatter to format catalog values to yaml. */ -public class CreateServiceBindingResponseFormatter implements ArgumentFormatter { +public class CreateServiceBindingResponseFormatter implements ArgumentFormatter { @Override - public String format(CreateServiceInstanceAppBindingResponse response, String... strings) { + public String format(CreateServiceInstanceBindingResponse response, String... strings) { ObjectMapper mapper = new ObjectMapper(); try { return mapper.writer().withDefaultPrettyPrinter().writeValueAsString(response); diff --git a/src/test/java/com/orange/servicebroker/staticcreds/stories/tags/ConfigureCatalog.java b/src/test/java/com/orange/servicebroker/staticcreds/stories/tags/ConfigureServiceBroker.java similarity index 88% rename from src/test/java/com/orange/servicebroker/staticcreds/stories/tags/ConfigureCatalog.java rename to src/test/java/com/orange/servicebroker/staticcreds/stories/tags/ConfigureServiceBroker.java index 35c319a..21ea291 100644 --- a/src/test/java/com/orange/servicebroker/staticcreds/stories/tags/ConfigureCatalog.java +++ b/src/test/java/com/orange/servicebroker/staticcreds/stories/tags/ConfigureServiceBroker.java @@ -20,11 +20,11 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -@IsTag(name = "Service Broker configures a catalog", +@IsTag(name = "Paas ops configures a service broker", description = "In order to advertise to the marketplace,
" + - "As a Service Broker,
" + + "As a Paas ops,
" + "I want to configure a catalog of service offerings and service plans.") @Retention(RetentionPolicy.RUNTIME) -public @interface ConfigureCatalog { +public @interface ConfigureServiceBroker { }