Skip to content

Commit

Permalink
DPNG-9169: Corrected generation of instances URL
Browse files Browse the repository at this point in the history
DPNG-7621: Added license templates
  • Loading branch information
mlaboszc committed Jul 19, 2016
1 parent c138c3f commit bbe5696
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ 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.
limitations under the License.
13 changes: 13 additions & 0 deletions license/license_header_2016.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2016 Intel Corporation

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.
16 changes: 16 additions & 0 deletions pack.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright (c) 2016 Intel Corporation
#
# 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.
#

set -e

VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[' | tail -1)
Expand Down
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>service-exposer</artifactId>
<version>0.2.20</version>
<version>0.2.21</version>

<parent>
<groupId>org.trustedanalytics</groupId>
<artifactId>trustedanalytics-cloud-parent</artifactId>
<version>0.4.5</version>
<version>0.6.1</version>
</parent>

<dependencies>
Expand Down Expand Up @@ -199,12 +199,11 @@
<artifactId>license-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<header>license/license_header.txt</header>
<includes>
<include>src/**/*.java</include>
<include>license/*.sh</include>
<include>pack.sh</include>
</includes>

<mapping>
<java>JAVADOC_STYLE</java>
<sh>SCRIPT_STYLE</sh>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public CredentialProperties(boolean credentialsExtraced, String domainName, Stri
this.spaceGuid = spaceGuid;
this.name = name;
if ("".equals(hostName)) {
this.hostName = name.replaceAll("[^A-Za-z0-9]", "_") + "-" + serviceInstaceGuid + domainName;
String sanitizedServiceName = this.name.replaceAll("[^A-Za-z0-9]+", "-").replaceAll("^-|-$","");
this.hostName = sanitizedServiceName + "-" + serviceInstaceGuid + domainName;
} else {
this.hostName = hostName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ public void testServiceInstanceExists() {
assertEquals(true, eligible);
}

@Test
public void testGetCredentialsGeneration() {
String malformedName1 = "my--___+!^!)--(*&instance";
String malformedName2 = "-my--___+!^!)--(*&instance-";
String malformedName3 = "my--___+!^!)--(*&instance-";
String malformedName4 = "-my--___+!^!)--(*&instance";
String malformedName5 = "-----my--+!^!)--(&instance";
String malformedName6 = "&$%&%$&my--+!^!)--(*&instance";

String domain = ".daily-nokrb.gotapass.eu";
String randomServiceGuid = UUID.randomUUID().toString();

String properName = "my-instance";
String properUrl = properName+"-"+randomServiceGuid+domain;

CredentialProperties entry1 = new CredentialProperties(true,domain,randomServiceGuid,randomServiceGuid,malformedName1,"","","","","");
CredentialProperties entry2 = new CredentialProperties(true,domain,randomServiceGuid,randomServiceGuid,malformedName2,"","","","","");
CredentialProperties entry3 = new CredentialProperties(true,domain,randomServiceGuid,randomServiceGuid,malformedName3,"","","","","");
CredentialProperties entry4 = new CredentialProperties(true,domain,randomServiceGuid,randomServiceGuid,malformedName4,"","","","","");
CredentialProperties entry5 = new CredentialProperties(true,domain,randomServiceGuid,randomServiceGuid,malformedName5,"","","","","");
CredentialProperties entry6 = new CredentialProperties(true,domain,randomServiceGuid,randomServiceGuid,malformedName6,"","","","","");

assertEquals(properUrl, entry1.getHostName());
assertEquals(properUrl, entry2.getHostName());
assertEquals(properUrl, entry3.getHostName());
assertEquals(properUrl, entry4.getHostName());
assertEquals(properUrl, entry5.getHostName());
assertEquals(properUrl, entry6.getHostName());
}

@Test
public void testGetCredentialsInJSON() {
String serviceName = "tested";
Expand Down

0 comments on commit bbe5696

Please sign in to comment.