Only force "/c" prefix on credential names for service broker names.
This commit is contained in:
@@ -47,8 +47,8 @@ public class CredentialName {
|
||||
|
||||
Assert.isTrue(split.length > 2, "name must include at least one segment separated by '/'");
|
||||
|
||||
// remove the "/c/" prefix
|
||||
this.segments = Arrays.copyOfRange(split, 2, split.length);
|
||||
// remove the "/" prefix
|
||||
this.segments = Arrays.copyOfRange(split, 1, split.length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ public class CredentialName {
|
||||
*/
|
||||
@JsonInclude
|
||||
public String getName() {
|
||||
return "/c/" + StringUtils.arrayToDelimitedString(segments, "/");
|
||||
return "/" + StringUtils.arrayToDelimitedString(segments, "/");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ServiceInstanceCredentialName extends CredentialName {
|
||||
*/
|
||||
ServiceInstanceCredentialName(String serviceBrokerName, String serviceOfferingName,
|
||||
String serviceBindingId, String credentialName) {
|
||||
super(serviceBrokerName, serviceOfferingName, serviceBindingId, credentialName);
|
||||
super("c", serviceBrokerName, serviceOfferingName, serviceBindingId, credentialName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,15 +32,15 @@ public class CredentialSummaryDataUnitTests extends JsonParsingUnitTestsBase {
|
||||
String json = "{\n" +
|
||||
" \"credentials\": [\n" +
|
||||
" {\n" +
|
||||
" \"name\": \"/c/deploy123/example1\",\n" +
|
||||
" \"name\": \"/deploy123/example1\",\n" +
|
||||
" \"version_created_at\": \"" + TEST_DATE_STRING + "\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"name\": \"/c/deploy123/example2\",\n" +
|
||||
" \"name\": \"/deploy123/example2\",\n" +
|
||||
" \"version_created_at\": \"" + TEST_DATE_STRING + "\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"name\": \"/c/deploy123/example3\",\n" +
|
||||
" \"name\": \"/deploy123/example3\",\n" +
|
||||
" \"version_created_at\": \"" + TEST_DATE_STRING + "\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
@@ -53,11 +53,11 @@ public class CredentialSummaryDataUnitTests extends JsonParsingUnitTestsBase {
|
||||
List<CredentialSummary> credentials = response.getCredentials();
|
||||
|
||||
assertThat(credentials.get(0).getName().getName(),
|
||||
equalTo("/c/deploy123/example1"));
|
||||
equalTo("/deploy123/example1"));
|
||||
assertThat(credentials.get(1).getName().getName(),
|
||||
equalTo("/c/deploy123/example2"));
|
||||
equalTo("/deploy123/example2"));
|
||||
assertThat(credentials.get(2).getName().getName(),
|
||||
equalTo("/c/deploy123/example3"));
|
||||
equalTo("/deploy123/example3"));
|
||||
|
||||
for (CredentialSummary credential : credentials) {
|
||||
assertThat(credential.getVersionCreatedAt(), equalTo(testDate));
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class JsonParsingUnitTestsBase {
|
||||
protected final String CREDENTIAL_DETAIL_TEMPLATE = "{" +
|
||||
" \"version_created_at\": \"" + TEST_DATE_STRING + "\"," +
|
||||
" \"id\": \"80cbb13f-7562-4e72-92de-f3ccf69eaa59\"," +
|
||||
" \"name\": \"/c/service-broker-name/service-instance-name/binding-id/credentials-json\"," +
|
||||
" \"name\": \"/service-broker-name/service-instance-name/binding-id/credentials-json\"," +
|
||||
" %s" +
|
||||
"}";
|
||||
|
||||
@@ -76,6 +76,6 @@ public abstract class JsonParsingUnitTestsBase {
|
||||
assertThat(data.getVersionCreatedAt(), equalTo(testDate));
|
||||
assertThat(data.getId(), equalTo("80cbb13f-7562-4e72-92de-f3ccf69eaa59"));
|
||||
assertThat(data.getName().getName(), equalTo(
|
||||
"/c/service-broker-name/service-instance-name/binding-id/credentials-json"));
|
||||
"/service-broker-name/service-instance-name/binding-id/credentials-json"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ public class SimpleCredentialNameUnitTests {
|
||||
CredentialName credentialName =
|
||||
new SimpleCredentialName("myorg", "example", "credential-name");
|
||||
|
||||
assertThat(credentialName.getName(), equalTo("/c/myorg/example/credential-name"));
|
||||
assertThat(credentialName.getName(), equalTo("/myorg/example/credential-name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleNameIsParsed() {
|
||||
CredentialName credentialName = new CredentialName("/c/myorg/example/credential-name");
|
||||
CredentialName credentialName = new CredentialName("/myorg/example/credential-name");
|
||||
|
||||
assertThat(credentialName.getName(), equalTo("/c/myorg/example/credential-name"));
|
||||
assertThat(credentialName.getName(), equalTo("/myorg/example/credential-name"));
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class CertificateCredentialRequestUnitTests extends CredentialRequestUnit
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("certificate")),
|
||||
hasJsonPath("$.value.certificate", equalTo("cert")),
|
||||
hasJsonPath("$.value.ca", equalTo("ca")),
|
||||
@@ -57,7 +57,7 @@ public class CertificateCredentialRequestUnitTests extends CredentialRequestUnit
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("certificate")),
|
||||
hasJsonPath("$.value.certificate", equalTo("cert")),
|
||||
hasNoJsonPath("$.value.ca"),
|
||||
@@ -74,7 +74,7 @@ public class CertificateCredentialRequestUnitTests extends CredentialRequestUnit
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("certificate")),
|
||||
hasNoJsonPath("$.value.certificate"),
|
||||
hasJsonPath("$.value.ca", equalTo("ca")),
|
||||
|
||||
@@ -48,7 +48,7 @@ public class JsonCredentialRequestUnitTests extends CredentialRequestUnitTestsBa
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(false)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("json")),
|
||||
hasJsonPath("$.value.data", equalTo("value")),
|
||||
hasJsonPath("$.value.test", equalTo(true))));
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PasswordCredentialRequestUnitTests extends CredentialRequestUnitTes
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("password")),
|
||||
hasJsonPath("$.value", equalTo("secret"))));
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PasswordCredentialRequestUnitTests extends CredentialRequestUnitTes
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("password")),
|
||||
hasJsonPath("$.value", equalTo("secret"))));
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PasswordParametersRequestUnitTests extends ParametersRequestUnitTes
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("password")),
|
||||
hasJsonPath("$.parameters.length", equalTo(20)),
|
||||
hasJsonPath("$.parameters.exclude_lower", equalTo(true)),
|
||||
@@ -68,7 +68,7 @@ public class PasswordParametersRequestUnitTests extends ParametersRequestUnitTes
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("password")),
|
||||
hasNoJsonPath("$.parameters.length"),
|
||||
hasNoJsonPath("$.parameters.exclude_lower"),
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RsaCredentialRequestUnitTests extends CredentialRequestUnitTestsBas
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("rsa")),
|
||||
hasJsonPath("$.value.public_key", equalTo("public-key")),
|
||||
hasJsonPath("$.value.private_key", equalTo("private-key"))));
|
||||
@@ -56,7 +56,7 @@ public class RsaCredentialRequestUnitTests extends CredentialRequestUnitTestsBas
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("rsa")),
|
||||
hasJsonPath("$.value.public_key", equalTo("public-key")),
|
||||
hasNoJsonPath("$.value.private_key")));
|
||||
@@ -72,7 +72,7 @@ public class RsaCredentialRequestUnitTests extends CredentialRequestUnitTestsBas
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("rsa")),
|
||||
hasNoJsonPath("$.value.public_key"),
|
||||
hasJsonPath("$.value.private_key", equalTo("private-key"))));
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SshCredentialRequestUnitTests extends CredentialRequestUnitTestsBas
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("ssh")),
|
||||
hasJsonPath("$.value.public_key", equalTo("public-key")),
|
||||
hasJsonPath("$.value.private_key", equalTo("private-key"))));
|
||||
@@ -56,7 +56,7 @@ public class SshCredentialRequestUnitTests extends CredentialRequestUnitTestsBas
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("ssh")),
|
||||
hasJsonPath("$.value.public_key", equalTo("public-key")),
|
||||
hasNoJsonPath("$.value.private_key")));
|
||||
@@ -72,7 +72,7 @@ public class SshCredentialRequestUnitTests extends CredentialRequestUnitTestsBas
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("ssh")),
|
||||
hasNoJsonPath("$.value.public_key"),
|
||||
hasJsonPath("$.value.private_key", equalTo("private-key"))));
|
||||
|
||||
@@ -44,7 +44,7 @@ public class UserCredentialRequestUnitTests extends CredentialRequestUnitTestsBa
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("user")),
|
||||
hasJsonPath("$.value.username", equalTo("myname")),
|
||||
hasJsonPath("$.value.password", equalTo("secret"))));
|
||||
@@ -63,7 +63,7 @@ public class UserCredentialRequestUnitTests extends CredentialRequestUnitTestsBa
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("user")),
|
||||
hasNoJsonPath("$.value.username"),
|
||||
hasJsonPath("$.value.password", equalTo("secret"))));
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ValueCredentialRequestUnitTests extends CredentialRequestUnitTestsB
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("value")),
|
||||
hasJsonPath("$.value", equalTo("somevalue"))));
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ValueCredentialRequestUnitTests extends CredentialRequestUnitTestsB
|
||||
|
||||
assertThat(jsonValue,
|
||||
allOf(hasJsonPath("$.overwrite", equalTo(true)),
|
||||
hasJsonPath("$.name", equalTo("/c/example/credential")),
|
||||
hasJsonPath("$.name", equalTo("/example/credential")),
|
||||
hasJsonPath("$.type", equalTo("value")),
|
||||
hasJsonPath("$.value", equalTo("somevalue"))));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user