Adding method to TrustDomain and test
Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
This commit is contained in:
parent
588da2cd55
commit
12329d924d
|
|
@ -50,6 +50,10 @@ public class TrustDomain {
|
||||||
return new TrustDomain(host);
|
return new TrustDomain(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SpiffeId newSpiffeId(String ...path) {
|
||||||
|
return SpiffeId.of(this, path);
|
||||||
|
}
|
||||||
|
|
||||||
private static void validateHost(String host) {
|
private static void validateHost(String host) {
|
||||||
if (StringUtils.isBlank(host)) {
|
if (StringUtils.isBlank(host)) {
|
||||||
throw new IllegalArgumentException("Trust domain cannot be empty");
|
throw new IllegalArgumentException("Trust domain cannot be empty");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package spiffe.spiffeid;
|
package spiffe.spiffeid;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
@ -31,7 +32,7 @@ public class TrustDomainTest {
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("provideTestTrustDomain")
|
@MethodSource("provideTestTrustDomain")
|
||||||
void parseAddressInvalid(String input, Object expected) {
|
void parseTrustDomain(String input, Object expected) {
|
||||||
TrustDomain result = null;
|
TrustDomain result = null;
|
||||||
try {
|
try {
|
||||||
result = TrustDomain.of(input);
|
result = TrustDomain.of(input);
|
||||||
|
|
@ -40,4 +41,13 @@ public class TrustDomainTest {
|
||||||
assertEquals(expected, e.getMessage());
|
assertEquals(expected, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void newSpiffeId() {
|
||||||
|
TrustDomain trustDomain = TrustDomain.of("test.domain");
|
||||||
|
SpiffeId spiffeId = trustDomain.newSpiffeId("path1", "host");
|
||||||
|
|
||||||
|
assertEquals(trustDomain, spiffeId.getTrustDomain());
|
||||||
|
assertEquals("/path1/host", spiffeId.getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class AddressTest {
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("provideTestAddress")
|
@MethodSource("provideTestAddress")
|
||||||
void parseAddressInvalid(String input, Object expected) {
|
void parseAddress(String input, Object expected) {
|
||||||
URI result = null;
|
URI result = null;
|
||||||
try {
|
try {
|
||||||
result = Address.parseAddress(input);
|
result = Address.parseAddress(input);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue