test classes package-private; use mockStatic()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1a19eaa87d
commit
600f3d0d0f
@ -20,9 +20,6 @@ import de.stklcode.jvault.connector.exception.InvalidRequestException;
|
|||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
import de.stklcode.jvault.connector.exception.PermissionDeniedException;
|
import de.stklcode.jvault.connector.exception.PermissionDeniedException;
|
||||||
import de.stklcode.jvault.connector.exception.VaultConnectorException;
|
import de.stklcode.jvault.connector.exception.VaultConnectorException;
|
||||||
import net.bytebuddy.ByteBuddy;
|
|
||||||
import net.bytebuddy.agent.ByteBuddyAgent;
|
|
||||||
import net.bytebuddy.dynamic.loading.ClassReloadingStrategy;
|
|
||||||
import org.apache.http.ProtocolVersion;
|
import org.apache.http.ProtocolVersion;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
@ -33,6 +30,7 @@ import org.apache.http.message.BasicStatusLine;
|
|||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.MockedStatic;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -42,8 +40,6 @@ import java.security.cert.CertificateFactory;
|
|||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static net.bytebuddy.implementation.MethodDelegation.to;
|
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
|
||||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
@ -59,45 +55,31 @@ import static org.mockito.Mockito.*;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public class HTTPVaultConnectorOfflineTest {
|
class HTTPVaultConnectorOfflineTest {
|
||||||
private static final String INVALID_URL = "foo:/\\1nv4l1d_UrL";
|
private static final String INVALID_URL = "foo:/\\1nv4l1d_UrL";
|
||||||
|
|
||||||
private static CloseableHttpClient httpMock = mock(CloseableHttpClient.class);
|
private static CloseableHttpClient httpMock;
|
||||||
private CloseableHttpResponse responseMock = mock(CloseableHttpResponse.class);
|
private final CloseableHttpResponse responseMock = mock(CloseableHttpResponse.class);
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void initByteBuddy() {
|
static void prepare() {
|
||||||
// Install ByteBuddy Agent.
|
// Mock the static HTTPClient creation.
|
||||||
ByteBuddyAgent.install();
|
MockedStatic<HttpClientBuilder> hcbMock = mockStatic(HttpClientBuilder.class);
|
||||||
}
|
hcbMock.when(HttpClientBuilder::create).thenReturn(new MockedHttpClientBuilder());
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method for redefinition of {@link HttpClientBuilder#create()} from {@link #initHttpMock()}.
|
|
||||||
*
|
|
||||||
* @return Mocked HTTP client builder.
|
|
||||||
*/
|
|
||||||
public static HttpClientBuilder create() {
|
|
||||||
return new MockedHttpClientBuilder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void initHttpMock() {
|
void init() {
|
||||||
// Redefine static method to return Mock on HttpClientBuilder creation.
|
|
||||||
new ByteBuddy().redefine(HttpClientBuilder.class)
|
|
||||||
.method(named("create"))
|
|
||||||
.intercept(to(HTTPVaultConnectorOfflineTest.class))
|
|
||||||
.make()
|
|
||||||
.load(HttpClientBuilder.class.getClassLoader(), ClassReloadingStrategy.fromInstalledAgent());
|
|
||||||
|
|
||||||
// Re-initialize HTTP mock to ensure fresh (empty) results.
|
// Re-initialize HTTP mock to ensure fresh (empty) results.
|
||||||
httpMock = mock(CloseableHttpClient.class);
|
httpMock = mock(CloseableHttpClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test exceptions thrown during request.
|
* Test exceptions thrown during request.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void requestExceptionTest() throws IOException {
|
void requestExceptionTest() throws IOException {
|
||||||
HTTPVaultConnector connector = new HTTPVaultConnector("http://127.0.0.1", null, 0, 250);
|
HTTPVaultConnector connector = new HTTPVaultConnector("http://127.0.0.1", null, 0, 250);
|
||||||
|
|
||||||
// Test invalid response code.
|
// Test invalid response code.
|
||||||
@ -154,7 +136,7 @@ public class HTTPVaultConnectorOfflineTest {
|
|||||||
* Test constructors of the {@link HTTPVaultConnector} class.
|
* Test constructors of the {@link HTTPVaultConnector} class.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void constructorTest() throws IOException, CertificateException {
|
void constructorTest() throws IOException, CertificateException {
|
||||||
final String url = "https://vault.example.net/test/";
|
final String url = "https://vault.example.net/test/";
|
||||||
final String hostname = "vault.example.com";
|
final String hostname = "vault.example.com";
|
||||||
final Integer port = 1337;
|
final Integer port = 1337;
|
||||||
@ -206,7 +188,7 @@ public class HTTPVaultConnectorOfflineTest {
|
|||||||
* This test is designed to test exceptions caught and thrown by seal-methods if Vault is not reachable.
|
* This test is designed to test exceptions caught and thrown by seal-methods if Vault is not reachable.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void sealExceptionTest() throws IOException {
|
void sealExceptionTest() throws IOException {
|
||||||
HTTPVaultConnector connector = new HTTPVaultConnector(INVALID_URL);
|
HTTPVaultConnector connector = new HTTPVaultConnector(INVALID_URL);
|
||||||
try {
|
try {
|
||||||
connector.sealStatus();
|
connector.sealStatus();
|
||||||
@ -233,7 +215,7 @@ public class HTTPVaultConnectorOfflineTest {
|
|||||||
* This test is designed to test exceptions caught and thrown by seal-methods if Vault is not reachable.
|
* This test is designed to test exceptions caught and thrown by seal-methods if Vault is not reachable.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void healthExceptionTest() throws IOException {
|
void healthExceptionTest() throws IOException {
|
||||||
HTTPVaultConnector connector = new HTTPVaultConnector(INVALID_URL);
|
HTTPVaultConnector connector = new HTTPVaultConnector(INVALID_URL);
|
||||||
try {
|
try {
|
||||||
connector.getHealth();
|
connector.getHealth();
|
||||||
@ -259,7 +241,7 @@ public class HTTPVaultConnectorOfflineTest {
|
|||||||
* Test behavior on unparsable responses.
|
* Test behavior on unparsable responses.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void parseExceptionTest() throws IOException {
|
void parseExceptionTest() throws IOException {
|
||||||
HTTPVaultConnector connector = new HTTPVaultConnector("https://127.0.0.1", null, 0, 250);
|
HTTPVaultConnector connector = new HTTPVaultConnector("https://127.0.0.1", null, 0, 250);
|
||||||
// Mock authorization.
|
// Mock authorization.
|
||||||
setPrivate(connector, "authorized", true);
|
setPrivate(connector, "authorized", true);
|
||||||
@ -382,7 +364,7 @@ public class HTTPVaultConnectorOfflineTest {
|
|||||||
* Test requests that expect an empty response with code 204, but receive a 200 body.
|
* Test requests that expect an empty response with code 204, but receive a 200 body.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void nonEmpty204ResponseTest() throws IOException {
|
void nonEmpty204ResponseTest() throws IOException {
|
||||||
HTTPVaultConnector connector = new HTTPVaultConnector("https://127.0.0.1", null, 0, 250);
|
HTTPVaultConnector connector = new HTTPVaultConnector("https://127.0.0.1", null, 0, 250);
|
||||||
// Mock authorization.
|
// Mock authorization.
|
||||||
setPrivate(connector, "authorized", true);
|
setPrivate(connector, "authorized", true);
|
||||||
@ -454,7 +436,7 @@ public class HTTPVaultConnectorOfflineTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getRequestHelperPrivate(HTTPVaultConnector connector, String fieldName) {
|
private Object getRequestHelperPrivate(HTTPVaultConnector connector, String fieldName) {
|
||||||
try {
|
try {
|
||||||
return getPrivate(getPrivate(connector, "request"), fieldName);
|
return getPrivate(getPrivate(connector, "request"), fieldName);
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
|
@ -52,7 +52,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|||||||
* @since 0.1
|
* @since 0.1
|
||||||
*/
|
*/
|
||||||
@Tag("online")
|
@Tag("online")
|
||||||
public class HTTPVaultConnectorTest {
|
class HTTPVaultConnectorTest {
|
||||||
private static String VAULT_VERSION = "1.6.1"; // the vault version this test is supposed to run against
|
private static String VAULT_VERSION = "1.6.1"; // the vault version this test is supposed to run against
|
||||||
private static final String KEY1 = "E38bkCm0VhUvpdCKGQpcohhD9XmcHJ/2hreOSY019Lho";
|
private static final String KEY1 = "E38bkCm0VhUvpdCKGQpcohhD9XmcHJ/2hreOSY019Lho";
|
||||||
private static final String KEY2 = "O5OHwDleY3IiPdgw61cgHlhsrEm6tVJkrxhF6QAnILd1";
|
private static final String KEY2 = "O5OHwDleY3IiPdgw61cgHlhsrEm6tVJkrxhF6QAnILd1";
|
||||||
@ -78,7 +78,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
* Requires "vault" binary to be in current user's executable path. Not using MLock, so no extended rights required.
|
* Requires "vault" binary to be in current user's executable path. Not using MLock, so no extended rights required.
|
||||||
*/
|
*/
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp(TestInfo testInfo, @TempDir File tempDir) throws VaultConnectorException, IOException {
|
void setUp(TestInfo testInfo, @TempDir File tempDir) throws VaultConnectorException, IOException {
|
||||||
/* Determine, if TLS is required */
|
/* Determine, if TLS is required */
|
||||||
boolean isTls = testInfo.getTags().contains("tls");
|
boolean isTls = testInfo.getTags().contains("tls");
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void tearDown() {
|
void tearDown() {
|
||||||
if (vaultProcess != null && vaultProcess.isAlive())
|
if (vaultProcess != null && vaultProcess.isAlive())
|
||||||
vaultProcess.destroy();
|
vaultProcess.destroy();
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Order(10)
|
@Order(10)
|
||||||
@DisplayName("Read secrets")
|
@DisplayName("Read secrets")
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void readSecretTest() {
|
void readSecretTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(20)
|
@Order(20)
|
||||||
@DisplayName("List secrets")
|
@DisplayName("List secrets")
|
||||||
public void listSecretsTest() {
|
void listSecretsTest() {
|
||||||
authRoot();
|
authRoot();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
/* Try to list secrets from valid path */
|
/* Try to list secrets from valid path */
|
||||||
@ -230,7 +230,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Order(30)
|
@Order(30)
|
||||||
@DisplayName("Write secrets")
|
@DisplayName("Write secrets")
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void writeSecretTest() {
|
void writeSecretTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(40)
|
@Order(40)
|
||||||
@DisplayName("Delete secrets")
|
@DisplayName("Delete secrets")
|
||||||
public void deleteSecretTest() {
|
void deleteSecretTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(50)
|
@Order(50)
|
||||||
@DisplayName("Revoke secrets")
|
@DisplayName("Revoke secrets")
|
||||||
public void revokeTest() {
|
void revokeTest() {
|
||||||
authRoot();
|
authRoot();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(10)
|
@Order(10)
|
||||||
@DisplayName("Read v2 secret")
|
@DisplayName("Read v2 secret")
|
||||||
public void readSecretTest() {
|
void readSecretTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(20)
|
@Order(20)
|
||||||
@DisplayName("Write v2 secret")
|
@DisplayName("Write v2 secret")
|
||||||
public void writeSecretTest() {
|
void writeSecretTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(30)
|
@Order(30)
|
||||||
@DisplayName("Read v2 metadata")
|
@DisplayName("Read v2 metadata")
|
||||||
public void readSecretMetadataTest() {
|
void readSecretMetadataTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -487,7 +487,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(40)
|
@Order(40)
|
||||||
@DisplayName("Update v2 metadata")
|
@DisplayName("Update v2 metadata")
|
||||||
public void updateSecretMetadataTest() {
|
void updateSecretMetadataTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -511,7 +511,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(50)
|
@Order(50)
|
||||||
@DisplayName("Version handling")
|
@DisplayName("Version handling")
|
||||||
public void handleSecretVersionsTest() {
|
void handleSecretVersionsTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -588,7 +588,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Order(10)
|
@Order(10)
|
||||||
@DisplayName("Authenticate with App-ID")
|
@DisplayName("Authenticate with App-ID")
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void authAppIdTest() {
|
void authAppIdTest() {
|
||||||
/* Try unauthorized access first. */
|
/* Try unauthorized access first. */
|
||||||
assumeFalse(connector.isAuthorized());
|
assumeFalse(connector.isAuthorized());
|
||||||
|
|
||||||
@ -613,7 +613,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Order(20)
|
@Order(20)
|
||||||
@DisplayName("Register App-ID")
|
@DisplayName("Register App-ID")
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void registerAppIdTest() {
|
void registerAppIdTest() {
|
||||||
/* Authorize. */
|
/* Authorize. */
|
||||||
authRoot();
|
authRoot();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
@ -664,7 +664,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(10)
|
@Order(10)
|
||||||
@DisplayName("Authenticate with AppRole")
|
@DisplayName("Authenticate with AppRole")
|
||||||
public void authAppRole() {
|
void authAppRole() {
|
||||||
assumeFalse(connector.isAuthorized());
|
assumeFalse(connector.isAuthorized());
|
||||||
|
|
||||||
/* Authenticate with correct credentials */
|
/* Authenticate with correct credentials */
|
||||||
@ -724,7 +724,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(20)
|
@Order(20)
|
||||||
@DisplayName("List AppRoles")
|
@DisplayName("List AppRoles")
|
||||||
public void listAppRoleTest() {
|
void listAppRoleTest() {
|
||||||
/* Try unauthorized access first. */
|
/* Try unauthorized access first. */
|
||||||
assumeFalse(connector.isAuthorized());
|
assumeFalse(connector.isAuthorized());
|
||||||
|
|
||||||
@ -772,7 +772,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(30)
|
@Order(30)
|
||||||
@DisplayName("Create AppRole")
|
@DisplayName("Create AppRole")
|
||||||
public void createAppRoleTest() {
|
void createAppRoleTest() {
|
||||||
/* Try unauthorized access first. */
|
/* Try unauthorized access first. */
|
||||||
assumeFalse(connector.isAuthorized());
|
assumeFalse(connector.isAuthorized());
|
||||||
try {
|
try {
|
||||||
@ -974,7 +974,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(40)
|
@Order(40)
|
||||||
@DisplayName("Create AppRole secrets")
|
@DisplayName("Create AppRole secrets")
|
||||||
public void createAppRoleSecretTest() {
|
void createAppRoleSecretTest() {
|
||||||
authRoot();
|
authRoot();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -1028,7 +1028,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(10)
|
@Order(10)
|
||||||
@DisplayName("Authenticate with token")
|
@DisplayName("Authenticate with token")
|
||||||
public void authTokenTest() {
|
void authTokenTest() {
|
||||||
TokenResponse res;
|
TokenResponse res;
|
||||||
final String invalidToken = "52135869df23a5e64c5d33a9785af5edb456b8a4a235d1fe135e6fba1c35edf6";
|
final String invalidToken = "52135869df23a5e64c5d33a9785af5edb456b8a4a235d1fe135e6fba1c35edf6";
|
||||||
try {
|
try {
|
||||||
@ -1054,7 +1054,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(20)
|
@Order(20)
|
||||||
@DisplayName("Create token")
|
@DisplayName("Create token")
|
||||||
public void createTokenTest() {
|
void createTokenTest() {
|
||||||
authRoot();
|
authRoot();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -1156,7 +1156,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(30)
|
@Order(30)
|
||||||
@DisplayName("Lookup token")
|
@DisplayName("Lookup token")
|
||||||
public void lookupTokenTest() {
|
void lookupTokenTest() {
|
||||||
authRoot();
|
authRoot();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -1192,7 +1192,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(40)
|
@Order(40)
|
||||||
@DisplayName("Token roles")
|
@DisplayName("Token roles")
|
||||||
public void tokenRolesTest() {
|
void tokenRolesTest() {
|
||||||
authRoot();
|
authRoot();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
@ -1281,7 +1281,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("List auth methods")
|
@DisplayName("List auth methods")
|
||||||
public void authMethodsTest() {
|
void authMethodsTest() {
|
||||||
/* Authenticate as valid user */
|
/* Authenticate as valid user */
|
||||||
try {
|
try {
|
||||||
connector.authToken(TOKEN_ROOT);
|
connector.authToken(TOKEN_ROOT);
|
||||||
@ -1304,7 +1304,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Authenticate with UserPass")
|
@DisplayName("Authenticate with UserPass")
|
||||||
public void authUserPassTest() {
|
void authUserPassTest() {
|
||||||
AuthResponse res = null;
|
AuthResponse res = null;
|
||||||
final String invalidUser = "foo";
|
final String invalidUser = "foo";
|
||||||
final String invalidPass = "bar";
|
final String invalidPass = "bar";
|
||||||
@ -1332,7 +1332,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
@Test
|
@Test
|
||||||
@Tag("tls")
|
@Tag("tls")
|
||||||
@DisplayName("TLS connection test")
|
@DisplayName("TLS connection test")
|
||||||
public void tlsConnectionTest() {
|
void tlsConnectionTest() {
|
||||||
TokenResponse res;
|
TokenResponse res;
|
||||||
try {
|
try {
|
||||||
connector.authToken("52135869df23a5e64c5d33a9785af5edb456b8a4a235d1fe135e6fba1c35edf6");
|
connector.authToken("52135869df23a5e64c5d33a9785af5edb456b8a4a235d1fe135e6fba1c35edf6");
|
||||||
@ -1354,7 +1354,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Seal test")
|
@DisplayName("Seal test")
|
||||||
public void sealTest() throws VaultConnectorException {
|
void sealTest() throws VaultConnectorException {
|
||||||
SealResponse sealStatus = connector.sealStatus();
|
SealResponse sealStatus = connector.sealStatus();
|
||||||
assumeFalse(sealStatus.isSealed());
|
assumeFalse(sealStatus.isSealed());
|
||||||
|
|
||||||
@ -1387,7 +1387,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Health test")
|
@DisplayName("Health test")
|
||||||
public void healthTest() {
|
void healthTest() {
|
||||||
HealthResponse res = null;
|
HealthResponse res = null;
|
||||||
try {
|
try {
|
||||||
res = connector.getHealth();
|
res = connector.getHealth();
|
||||||
@ -1422,7 +1422,7 @@ public class HTTPVaultConnectorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Connector close test")
|
@DisplayName("Connector close test")
|
||||||
public void closeTest() {
|
void closeTest() {
|
||||||
authUser();
|
authUser();
|
||||||
assumeTrue(connector.isAuthorized());
|
assumeTrue(connector.isAuthorized());
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
*/
|
*/
|
||||||
public class HTTPVaultConnectorBuilderTest {
|
class HTTPVaultConnectorBuilderTest {
|
||||||
private static final String VAULT_ADDR = "https://localhost:8201";
|
private static final String VAULT_ADDR = "https://localhost:8201";
|
||||||
private static final Integer VAULT_MAX_RETRIES = 13;
|
private static final Integer VAULT_MAX_RETRIES = 13;
|
||||||
private static final String VAULT_TOKEN = "00001111-2222-3333-4444-555566667777";
|
private static final String VAULT_TOKEN = "00001111-2222-3333-4444-555566667777";
|
||||||
|
@ -29,19 +29,19 @@ import static org.hamcrest.core.Is.is;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
public class VaultConnectorExceptionTest {
|
class VaultConnectorExceptionTest {
|
||||||
private static final String MSG = "This is a test exception!";
|
private static final String MSG = "This is a test exception!";
|
||||||
private static final Throwable CAUSE = new Exception("Test-Cause");
|
private static final Throwable CAUSE = new Exception("Test-Cause");
|
||||||
private static final Integer STATUS_CODE = 1337;
|
private static final Integer STATUS_CODE = 1337;
|
||||||
private static final String RESPONSE = "Dummy response";
|
private static final String RESPONSE = "Dummy response";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void authorizationRequiredExceptionTest() {
|
void authorizationRequiredExceptionTest() {
|
||||||
assertEmptyConstructor(new AuthorizationRequiredException());
|
assertEmptyConstructor(new AuthorizationRequiredException());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void connectionExceptionTest() {
|
void connectionExceptionTest() {
|
||||||
assertEmptyConstructor(new ConnectionException());
|
assertEmptyConstructor(new ConnectionException());
|
||||||
assertMsgConstructor(new ConnectionException(MSG));
|
assertMsgConstructor(new ConnectionException(MSG));
|
||||||
assertCauseConstructor(new ConnectionException(CAUSE));
|
assertCauseConstructor(new ConnectionException(CAUSE));
|
||||||
@ -49,7 +49,7 @@ public class VaultConnectorExceptionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invalidRequestExceptionTest() {
|
void invalidRequestExceptionTest() {
|
||||||
assertEmptyConstructor(new InvalidRequestException());
|
assertEmptyConstructor(new InvalidRequestException());
|
||||||
assertMsgConstructor(new InvalidRequestException(MSG));
|
assertMsgConstructor(new InvalidRequestException(MSG));
|
||||||
assertCauseConstructor(new InvalidRequestException(CAUSE));
|
assertCauseConstructor(new InvalidRequestException(CAUSE));
|
||||||
@ -57,7 +57,7 @@ public class VaultConnectorExceptionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invalidResponseExceptionTest() {
|
void invalidResponseExceptionTest() {
|
||||||
assertEmptyConstructor(new InvalidResponseException());
|
assertEmptyConstructor(new InvalidResponseException());
|
||||||
assertMsgConstructor(new InvalidResponseException(MSG));
|
assertMsgConstructor(new InvalidResponseException(MSG));
|
||||||
assertCauseConstructor(new InvalidResponseException(CAUSE));
|
assertCauseConstructor(new InvalidResponseException(CAUSE));
|
||||||
@ -93,7 +93,7 @@ public class VaultConnectorExceptionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void permissionDeniedExceptionTest() {
|
void permissionDeniedExceptionTest() {
|
||||||
// Default message overwritten.
|
// Default message overwritten.
|
||||||
PermissionDeniedException e = new PermissionDeniedException();
|
PermissionDeniedException e = new PermissionDeniedException();
|
||||||
assertThat(e, is(instanceOf(VaultConnectorException.class)));
|
assertThat(e, is(instanceOf(VaultConnectorException.class)));
|
||||||
@ -108,7 +108,7 @@ public class VaultConnectorExceptionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tlsExceptionTest() {
|
void tlsExceptionTest() {
|
||||||
assertEmptyConstructor(new TlsException());
|
assertEmptyConstructor(new TlsException());
|
||||||
assertMsgConstructor(new TlsException(MSG));
|
assertMsgConstructor(new TlsException(MSG));
|
||||||
assertCauseConstructor(new TlsException(CAUSE));
|
assertCauseConstructor(new TlsException(CAUSE));
|
||||||
|
@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.6.0
|
* @since 0.6.0
|
||||||
*/
|
*/
|
||||||
public class HTTPVaultConnectorFactoryTest {
|
class HTTPVaultConnectorFactoryTest {
|
||||||
private static String VAULT_ADDR = "https://localhost:8201";
|
private static String VAULT_ADDR = "https://localhost:8201";
|
||||||
private static Integer VAULT_MAX_RETRIES = 13;
|
private static Integer VAULT_MAX_RETRIES = 13;
|
||||||
private static String VAULT_TOKEN = "00001111-2222-3333-4444-555566667777";
|
private static String VAULT_TOKEN = "00001111-2222-3333-4444-555566667777";
|
||||||
@ -50,7 +50,7 @@ public class HTTPVaultConnectorFactoryTest {
|
|||||||
* Test building from environment variables
|
* Test building from environment variables
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFromEnv() throws NoSuchFieldException, IllegalAccessException, IOException {
|
void testFromEnv() throws NoSuchFieldException, IllegalAccessException, IOException {
|
||||||
/* Provide address only should be enough */
|
/* Provide address only should be enough */
|
||||||
setenv(VAULT_ADDR, null, null, null);
|
setenv(VAULT_ADDR, null, null, null);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.*;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public class AppRoleBuilderTest {
|
class AppRoleBuilderTest {
|
||||||
private static final String NAME = "TestRole";
|
private static final String NAME = "TestRole";
|
||||||
private static final String ID = "test-id";
|
private static final String ID = "test-id";
|
||||||
private static final Boolean BIND_SECRET_ID = true;
|
private static final Boolean BIND_SECRET_ID = true;
|
||||||
@ -58,7 +58,7 @@ public class AppRoleBuilderTest {
|
|||||||
NAME, ID, BIND_SECRET_ID, CIDR_1, SECRET_ID_NUM_USES, SECRET_ID_TTL, ENABLE_LOCAL_SECRET_IDS, TOKEN_TTL, TOKEN_MAX_TTL, POLICY, CIDR_1, TOKEN_EXPLICIT_MAX_TTL, TOKEN_NO_DEFAULT_POLICY, TOKEN_NUM_USES, TOKEN_PERIOD, TOKEN_TYPE.value());
|
NAME, ID, BIND_SECRET_ID, CIDR_1, SECRET_ID_NUM_USES, SECRET_ID_TTL, ENABLE_LOCAL_SECRET_IDS, TOKEN_TTL, TOKEN_MAX_TTL, POLICY, CIDR_1, TOKEN_EXPLICIT_MAX_TTL, TOKEN_NO_DEFAULT_POLICY, TOKEN_NUM_USES, TOKEN_PERIOD, TOKEN_TYPE.value());
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void init() {
|
static void init() {
|
||||||
BOUND_CIDR_LIST.add(CIDR_1);
|
BOUND_CIDR_LIST.add(CIDR_1);
|
||||||
POLICIES.add(POLICY);
|
POLICIES.add(POLICY);
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ public class AppRoleBuilderTest {
|
|||||||
* Build role with only a name.
|
* Build role with only a name.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void buildDefaultTest() throws JsonProcessingException {
|
void buildDefaultTest() throws JsonProcessingException {
|
||||||
AppRole role = AppRole.builder(NAME).build();
|
AppRole role = AppRole.builder(NAME).build();
|
||||||
assertThat(role.getId(), is(nullValue()));
|
assertThat(role.getId(), is(nullValue()));
|
||||||
assertThat(role.getBindSecretId(), is(nullValue()));
|
assertThat(role.getBindSecretId(), is(nullValue()));
|
||||||
@ -95,7 +95,7 @@ public class AppRoleBuilderTest {
|
|||||||
* Build role with only a name.
|
* Build role with only a name.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void legacyBuildDefaultTest() throws JsonProcessingException {
|
void legacyBuildDefaultTest() throws JsonProcessingException {
|
||||||
AppRole role = new AppRoleBuilder(NAME).build();
|
AppRole role = new AppRoleBuilder(NAME).build();
|
||||||
assertThat(role.getId(), is(nullValue()));
|
assertThat(role.getId(), is(nullValue()));
|
||||||
assertThat(role.getBindSecretId(), is(nullValue()));
|
assertThat(role.getBindSecretId(), is(nullValue()));
|
||||||
@ -123,7 +123,7 @@ public class AppRoleBuilderTest {
|
|||||||
* Build token without all parameters set.
|
* Build token without all parameters set.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void buildFullTest() throws JsonProcessingException {
|
void buildFullTest() throws JsonProcessingException {
|
||||||
AppRole role = AppRole.builder(NAME)
|
AppRole role = AppRole.builder(NAME)
|
||||||
.withId(ID)
|
.withId(ID)
|
||||||
.withBindSecretID(BIND_SECRET_ID)
|
.withBindSecretID(BIND_SECRET_ID)
|
||||||
@ -168,7 +168,7 @@ public class AppRoleBuilderTest {
|
|||||||
* Build token without all parameters set.
|
* Build token without all parameters set.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void legacyBuildFullTest() throws JsonProcessingException {
|
void legacyBuildFullTest() throws JsonProcessingException {
|
||||||
AppRole role = new AppRoleBuilder(NAME)
|
AppRole role = new AppRoleBuilder(NAME)
|
||||||
.withId(ID)
|
.withId(ID)
|
||||||
.withBindSecretID(BIND_SECRET_ID)
|
.withBindSecretID(BIND_SECRET_ID)
|
||||||
@ -213,7 +213,7 @@ public class AppRoleBuilderTest {
|
|||||||
* Test convenience methods
|
* Test convenience methods
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void convenienceMethodsTest() {
|
void convenienceMethodsTest() {
|
||||||
/* bind_secret_id */
|
/* bind_secret_id */
|
||||||
AppRole role = AppRole.builder(NAME).build();
|
AppRole role = AppRole.builder(NAME).build();
|
||||||
assertThat(role.getBindSecretId(), is(nullValue()));
|
assertThat(role.getBindSecretId(), is(nullValue()));
|
||||||
@ -257,7 +257,7 @@ public class AppRoleBuilderTest {
|
|||||||
* Test convenience methods
|
* Test convenience methods
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void legacyConvenienceMethodsTest() {
|
void legacyConvenienceMethodsTest() {
|
||||||
/* bind_secret_id */
|
/* bind_secret_id */
|
||||||
AppRole role = new AppRoleBuilder(NAME).build();
|
AppRole role = new AppRoleBuilder(NAME).build();
|
||||||
assertThat(role.getBindSecretId(), is(nullValue()));
|
assertThat(role.getBindSecretId(), is(nullValue()));
|
||||||
|
@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.5.0
|
* @since 0.5.0
|
||||||
*/
|
*/
|
||||||
public class AppRoleSecretTest {
|
class AppRoleSecretTest {
|
||||||
|
|
||||||
private static final String TEST_ID = "abc123";
|
private static final String TEST_ID = "abc123";
|
||||||
private static final Map<String, Object> TEST_META = new HashMap<>();
|
private static final Map<String, Object> TEST_META = new HashMap<>();
|
||||||
@ -54,7 +54,7 @@ public class AppRoleSecretTest {
|
|||||||
* Test constructors.
|
* Test constructors.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void constructorTest() {
|
void constructorTest() {
|
||||||
/* Empty constructor */
|
/* Empty constructor */
|
||||||
AppRoleSecret secret = new AppRoleSecret();
|
AppRoleSecret secret = new AppRoleSecret();
|
||||||
assertThat(secret.getId(), is(nullValue()));
|
assertThat(secret.getId(), is(nullValue()));
|
||||||
@ -99,7 +99,7 @@ public class AppRoleSecretTest {
|
|||||||
* Test setter.
|
* Test setter.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void setterTest() {
|
void setterTest() {
|
||||||
AppRoleSecret secret = new AppRoleSecret(TEST_ID);
|
AppRoleSecret secret = new AppRoleSecret(TEST_ID);
|
||||||
assertThat(secret.getCidrList(), is(nullValue()));
|
assertThat(secret.getCidrList(), is(nullValue()));
|
||||||
assertThat(secret.getCidrListString(), is(emptyString()));
|
assertThat(secret.getCidrListString(), is(emptyString()));
|
||||||
@ -115,7 +115,7 @@ public class AppRoleSecretTest {
|
|||||||
* Test JSON (de)serialization.
|
* Test JSON (de)serialization.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonTest() throws NoSuchFieldException, IllegalAccessException {
|
void jsonTest() throws NoSuchFieldException, IllegalAccessException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
/* A simple roundtrip first. All set fields should be present afterwards. */
|
/* A simple roundtrip first. All set fields should be present afterwards. */
|
||||||
|
@ -27,13 +27,13 @@ import static org.hamcrest.Matchers.is;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public class AuthBackendTest {
|
class AuthBackendTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test forType() method.
|
* Test forType() method.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void forTypeTest() {
|
void forTypeTest() {
|
||||||
assertThat(AuthBackend.forType("token"), is(AuthBackend.TOKEN));
|
assertThat(AuthBackend.forType("token"), is(AuthBackend.TOKEN));
|
||||||
assertThat(AuthBackend.forType("app-id"), is(AuthBackend.APPID));
|
assertThat(AuthBackend.forType("app-id"), is(AuthBackend.APPID));
|
||||||
assertThat(AuthBackend.forType("userpass"), is(AuthBackend.USERPASS));
|
assertThat(AuthBackend.forType("userpass"), is(AuthBackend.USERPASS));
|
||||||
|
@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.*;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public class TokenBuilderTest {
|
class TokenBuilderTest {
|
||||||
private static final String ID = "test-id";
|
private static final String ID = "test-id";
|
||||||
private static final String DISPLAY_NAME = "display-name";
|
private static final String DISPLAY_NAME = "display-name";
|
||||||
private static final Boolean NO_PARENT = false;
|
private static final Boolean NO_PARENT = false;
|
||||||
@ -59,7 +59,7 @@ public class TokenBuilderTest {
|
|||||||
private static final String JSON_FULL = "{\"id\":\"test-id\",\"type\":\"service\",\"display_name\":\"display-name\",\"no_parent\":false,\"no_default_policy\":false,\"ttl\":123,\"explicit_max_ttl\":456,\"num_uses\":4,\"policies\":[\"policy\"],\"meta\":{\"key\":\"value\"},\"renewable\":true,\"period\":3600,\"entity_alias\":\"alias-value\"}";
|
private static final String JSON_FULL = "{\"id\":\"test-id\",\"type\":\"service\",\"display_name\":\"display-name\",\"no_parent\":false,\"no_default_policy\":false,\"ttl\":123,\"explicit_max_ttl\":456,\"num_uses\":4,\"policies\":[\"policy\"],\"meta\":{\"key\":\"value\"},\"renewable\":true,\"period\":3600,\"entity_alias\":\"alias-value\"}";
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void init() {
|
static void init() {
|
||||||
POLICIES.add(POLICY);
|
POLICIES.add(POLICY);
|
||||||
META.put(META_KEY, META_VALUE);
|
META.put(META_KEY, META_VALUE);
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public class TokenBuilderTest {
|
|||||||
* Build token without any parameters.
|
* Build token without any parameters.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void buildDefaultTest() throws JsonProcessingException {
|
void buildDefaultTest() throws JsonProcessingException {
|
||||||
Token token = Token.builder().build();
|
Token token = Token.builder().build();
|
||||||
assertThat(token.getId(), is(nullValue()));
|
assertThat(token.getId(), is(nullValue()));
|
||||||
assertThat(token.getType(), is(nullValue()));
|
assertThat(token.getType(), is(nullValue()));
|
||||||
@ -92,7 +92,7 @@ public class TokenBuilderTest {
|
|||||||
* Build token without any parameters.
|
* Build token without any parameters.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void legacyBuildDefaultTest() throws JsonProcessingException {
|
void legacyBuildDefaultTest() throws JsonProcessingException {
|
||||||
Token token = new TokenBuilder().build();
|
Token token = new TokenBuilder().build();
|
||||||
assertThat(token.getId(), is(nullValue()));
|
assertThat(token.getId(), is(nullValue()));
|
||||||
assertThat(token.getType(), is(nullValue()));
|
assertThat(token.getType(), is(nullValue()));
|
||||||
@ -113,7 +113,7 @@ public class TokenBuilderTest {
|
|||||||
* Build token without all parameters set.
|
* Build token without all parameters set.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void buildFullTest() throws JsonProcessingException {
|
void buildFullTest() throws JsonProcessingException {
|
||||||
Token token = Token.builder()
|
Token token = Token.builder()
|
||||||
.withId(ID)
|
.withId(ID)
|
||||||
.withType(Token.Type.SERVICE)
|
.withType(Token.Type.SERVICE)
|
||||||
@ -150,7 +150,7 @@ public class TokenBuilderTest {
|
|||||||
* Build token without all parameters set.
|
* Build token without all parameters set.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void legacyBuildFullTest() throws JsonProcessingException {
|
void legacyBuildFullTest() throws JsonProcessingException {
|
||||||
Token token = new TokenBuilder()
|
Token token = new TokenBuilder()
|
||||||
.withId(ID)
|
.withId(ID)
|
||||||
.withType(Token.Type.SERVICE)
|
.withType(Token.Type.SERVICE)
|
||||||
@ -182,7 +182,7 @@ public class TokenBuilderTest {
|
|||||||
* Test convenience methods
|
* Test convenience methods
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void convenienceMethodsTest() {
|
void convenienceMethodsTest() {
|
||||||
/* Parent */
|
/* Parent */
|
||||||
Token token = Token.builder().asOrphan().build();
|
Token token = Token.builder().asOrphan().build();
|
||||||
assertThat(token.getNoParent(), is(true));
|
assertThat(token.getNoParent(), is(true));
|
||||||
@ -230,7 +230,7 @@ public class TokenBuilderTest {
|
|||||||
* Test convenience methods
|
* Test convenience methods
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void legacyConvenienceMethodsTest() {
|
void legacyConvenienceMethodsTest() {
|
||||||
/* Parent */
|
/* Parent */
|
||||||
Token token = new TokenBuilder().asOrphan().build();
|
Token token = new TokenBuilder().asOrphan().build();
|
||||||
assertThat(token.getNoParent(), is(true));
|
assertThat(token.getNoParent(), is(true));
|
||||||
|
@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.*;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.9
|
* @since 0.9
|
||||||
*/
|
*/
|
||||||
public class TokenRoleBuilderTest {
|
class TokenRoleBuilderTest {
|
||||||
private static final String NAME = "test-role";
|
private static final String NAME = "test-role";
|
||||||
private static final String ALLOWED_POLICY_1 = "apol-1";
|
private static final String ALLOWED_POLICY_1 = "apol-1";
|
||||||
private static final String ALLOWED_POLICY_2 = "apol-2";
|
private static final String ALLOWED_POLICY_2 = "apol-2";
|
||||||
@ -78,7 +78,7 @@ public class TokenRoleBuilderTest {
|
|||||||
* Build token without any parameters.
|
* Build token without any parameters.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void buildDefaultTest() throws JsonProcessingException {
|
void buildDefaultTest() throws JsonProcessingException {
|
||||||
TokenRole role = TokenRole.builder().build();
|
TokenRole role = TokenRole.builder().build();
|
||||||
assertThat(role.getAllowedPolicies(), is(nullValue()));
|
assertThat(role.getAllowedPolicies(), is(nullValue()));
|
||||||
assertThat(role.getDisallowedPolicies(), is(nullValue()));
|
assertThat(role.getDisallowedPolicies(), is(nullValue()));
|
||||||
@ -100,7 +100,7 @@ public class TokenRoleBuilderTest {
|
|||||||
* Build token without all parameters NULL.
|
* Build token without all parameters NULL.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void buildNullTest() throws JsonProcessingException {
|
void buildNullTest() throws JsonProcessingException {
|
||||||
TokenRole role = TokenRole.builder()
|
TokenRole role = TokenRole.builder()
|
||||||
.forName(null)
|
.forName(null)
|
||||||
.withAllowedPolicies(null)
|
.withAllowedPolicies(null)
|
||||||
@ -141,7 +141,7 @@ public class TokenRoleBuilderTest {
|
|||||||
* Build token without all parameters set.
|
* Build token without all parameters set.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void buildFullTest() throws JsonProcessingException {
|
void buildFullTest() throws JsonProcessingException {
|
||||||
TokenRole role = TokenRole.builder()
|
TokenRole role = TokenRole.builder()
|
||||||
.forName(NAME)
|
.forName(NAME)
|
||||||
.withAllowedPolicies(ALLOWED_POLICIES)
|
.withAllowedPolicies(ALLOWED_POLICIES)
|
||||||
|
@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
public class AppRoleResponseTest {
|
class AppRoleResponseTest {
|
||||||
private static final Integer ROLE_TOKEN_TTL = 1200;
|
private static final Integer ROLE_TOKEN_TTL = 1200;
|
||||||
private static final Integer ROLE_TOKEN_MAX_TTL = 1800;
|
private static final Integer ROLE_TOKEN_MAX_TTL = 1800;
|
||||||
private static final Integer ROLE_SECRET_TTL = 600;
|
private static final Integer ROLE_SECRET_TTL = 600;
|
||||||
@ -75,7 +75,7 @@ public class AppRoleResponseTest {
|
|||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getDataRoundtrip() {
|
void getDataRoundtrip() {
|
||||||
// Create empty Object.
|
// Create empty Object.
|
||||||
AppRoleResponse res = new AppRoleResponse();
|
AppRoleResponse res = new AppRoleResponse();
|
||||||
assertThat("Initial data should be empty", res.getRole(), is(nullValue()));
|
assertThat("Initial data should be empty", res.getRole(), is(nullValue()));
|
||||||
@ -93,7 +93,7 @@ public class AppRoleResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtrip() {
|
void jsonRoundtrip() {
|
||||||
try {
|
try {
|
||||||
AppRoleResponse res = new ObjectMapper().readValue(RES_JSON, AppRoleResponse.class);
|
AppRoleResponse res = new ObjectMapper().readValue(RES_JSON, AppRoleResponse.class);
|
||||||
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
||||||
|
@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
public class AuthMethodsResponseTest {
|
class AuthMethodsResponseTest {
|
||||||
private static final String GH_PATH = "github/";
|
private static final String GH_PATH = "github/";
|
||||||
private static final String GH_TYPE = "github";
|
private static final String GH_TYPE = "github";
|
||||||
private static final String GH_DESCR = "GitHub auth";
|
private static final String GH_DESCR = "GitHub auth";
|
||||||
@ -73,7 +73,7 @@ public class AuthMethodsResponseTest {
|
|||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getDataRoundtrip() {
|
void getDataRoundtrip() {
|
||||||
// Create empty Object.
|
// Create empty Object.
|
||||||
AuthMethodsResponse res = new AuthMethodsResponse();
|
AuthMethodsResponse res = new AuthMethodsResponse();
|
||||||
assertThat("Initial method map should be empty", res.getSupportedMethods(), is(anEmptyMap()));
|
assertThat("Initial method map should be empty", res.getSupportedMethods(), is(anEmptyMap()));
|
||||||
@ -91,7 +91,7 @@ public class AuthMethodsResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtrip() {
|
void jsonRoundtrip() {
|
||||||
try {
|
try {
|
||||||
AuthMethodsResponse res = new ObjectMapper().readValue(RES_JSON, AuthMethodsResponse.class);
|
AuthMethodsResponse res = new ObjectMapper().readValue(RES_JSON, AuthMethodsResponse.class);
|
||||||
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
||||||
|
@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
public class AuthResponseTest {
|
class AuthResponseTest {
|
||||||
private static final String AUTH_ACCESSOR = "2c84f488-2133-4ced-87b0-570f93a76830";
|
private static final String AUTH_ACCESSOR = "2c84f488-2133-4ced-87b0-570f93a76830";
|
||||||
private static final String AUTH_CLIENT_TOKEN = "ABCD";
|
private static final String AUTH_CLIENT_TOKEN = "ABCD";
|
||||||
private static final String AUTH_POLICY_1 = "web";
|
private static final String AUTH_POLICY_1 = "web";
|
||||||
@ -81,7 +81,7 @@ public class AuthResponseTest {
|
|||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getDataRoundtrip() {
|
void getDataRoundtrip() {
|
||||||
// Create empty Object.
|
// Create empty Object.
|
||||||
AuthResponse res = new AuthResponse();
|
AuthResponse res = new AuthResponse();
|
||||||
assertThat("Initial data should be empty", res.getData(), is(nullValue()));
|
assertThat("Initial data should be empty", res.getData(), is(nullValue()));
|
||||||
@ -103,7 +103,7 @@ public class AuthResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtrip() {
|
void jsonRoundtrip() {
|
||||||
try {
|
try {
|
||||||
AuthResponse res = new ObjectMapper().readValue(RES_JSON, AuthResponse.class);
|
AuthResponse res = new ObjectMapper().readValue(RES_JSON, AuthResponse.class);
|
||||||
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
||||||
|
@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.8
|
* @since 0.8
|
||||||
*/
|
*/
|
||||||
public class CredentialsResponseTest {
|
class CredentialsResponseTest {
|
||||||
private static final Map<String, Object> DATA = new HashMap<>();
|
private static final Map<String, Object> DATA = new HashMap<>();
|
||||||
private static final String VAL_USER = "testUserName";
|
private static final String VAL_USER = "testUserName";
|
||||||
private static final String VAL_PASS = "5up3r5ecr3tP455";
|
private static final String VAL_PASS = "5up3r5ecr3tP455";
|
||||||
@ -52,7 +52,7 @@ public class CredentialsResponseTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void getCredentialsTest() throws InvalidResponseException {
|
void getCredentialsTest() throws InvalidResponseException {
|
||||||
// Create empty Object.
|
// Create empty Object.
|
||||||
CredentialsResponse res = new CredentialsResponse();
|
CredentialsResponse res = new CredentialsResponse();
|
||||||
assertThat("Username not present in data map should not return anything", res.getUsername(), is(nullValue()));
|
assertThat("Username not present in data map should not return anything", res.getUsername(), is(nullValue()));
|
||||||
|
@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public class HealthResponseTest {
|
class HealthResponseTest {
|
||||||
private static final String CLUSTER_ID = "c9abceea-4f46-4dab-a688-5ce55f89e228";
|
private static final String CLUSTER_ID = "c9abceea-4f46-4dab-a688-5ce55f89e228";
|
||||||
private static final String CLUSTER_NAME = "vault-cluster-5515c810";
|
private static final String CLUSTER_NAME = "vault-cluster-5515c810";
|
||||||
private static final String VERSION = "0.9.2";
|
private static final String VERSION = "0.9.2";
|
||||||
@ -60,7 +60,7 @@ public class HealthResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtrip() {
|
void jsonRoundtrip() {
|
||||||
try {
|
try {
|
||||||
HealthResponse res = new ObjectMapper().readValue(RES_JSON, HealthResponse.class);
|
HealthResponse res = new ObjectMapper().readValue(RES_JSON, HealthResponse.class);
|
||||||
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
||||||
|
@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.8
|
* @since 0.8
|
||||||
*/
|
*/
|
||||||
public class MetadataResponseTest {
|
class MetadataResponseTest {
|
||||||
private static final String V1_TIME = "2018-03-22T02:24:06.945319214Z";
|
private static final String V1_TIME = "2018-03-22T02:24:06.945319214Z";
|
||||||
private static final String V3_TIME = "2018-03-22T02:36:43.986212308Z";
|
private static final String V3_TIME = "2018-03-22T02:36:43.986212308Z";
|
||||||
private static final String V2_TIME = "2018-03-22T02:36:33.954880664Z";
|
private static final String V2_TIME = "2018-03-22T02:36:33.954880664Z";
|
||||||
@ -73,7 +73,7 @@ public class MetadataResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtrip() {
|
void jsonRoundtrip() {
|
||||||
try {
|
try {
|
||||||
MetadataResponse res = new ObjectMapper().readValue(META_JSON, MetadataResponse.class);
|
MetadataResponse res = new ObjectMapper().readValue(META_JSON, MetadataResponse.class);
|
||||||
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
||||||
|
@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.8
|
* @since 0.8
|
||||||
*/
|
*/
|
||||||
public class SealResponseTest {
|
class SealResponseTest {
|
||||||
private static final String TYPE = "shamir";
|
private static final String TYPE = "shamir";
|
||||||
private static final Integer THRESHOLD = 3;
|
private static final Integer THRESHOLD = 3;
|
||||||
private static final Integer SHARES = 5;
|
private static final Integer SHARES = 5;
|
||||||
@ -70,7 +70,7 @@ public class SealResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault when sealed (JSON example close to Vault documentation).
|
* Test creation from JSON value as returned by Vault when sealed (JSON example close to Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtripSealed() {
|
void jsonRoundtripSealed() {
|
||||||
// First test sealed Vault's response.
|
// First test sealed Vault's response.
|
||||||
try {
|
try {
|
||||||
SealResponse res = new ObjectMapper().readValue(RES_SEALED, SealResponse.class);
|
SealResponse res = new ObjectMapper().readValue(RES_SEALED, SealResponse.class);
|
||||||
|
@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.8
|
* @since 0.8
|
||||||
*/
|
*/
|
||||||
public class SecretListResponseTest {
|
class SecretListResponseTest {
|
||||||
private static final Map<String, Object> DATA = new HashMap<>();
|
private static final Map<String, Object> DATA = new HashMap<>();
|
||||||
private static final String KEY1 = "key1";
|
private static final String KEY1 = "key1";
|
||||||
private static final String KEY2 = "key-2";
|
private static final String KEY2 = "key-2";
|
||||||
@ -50,7 +50,7 @@ public class SecretListResponseTest {
|
|||||||
* @throws InvalidResponseException Should not occur
|
* @throws InvalidResponseException Should not occur
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getKeysTest() throws InvalidResponseException {
|
void getKeysTest() throws InvalidResponseException {
|
||||||
// Create empty Object.
|
// Create empty Object.
|
||||||
SecretListResponse res = new SecretListResponse();
|
SecretListResponse res = new SecretListResponse();
|
||||||
assertThat("Keys should be null without initialization", res.getKeys(), is(nullValue()));
|
assertThat("Keys should be null without initialization", res.getKeys(), is(nullValue()));
|
||||||
|
@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
public class SecretResponseTest {
|
class SecretResponseTest {
|
||||||
private static final Map<String, Object> DATA = new HashMap<>();
|
private static final Map<String, Object> DATA = new HashMap<>();
|
||||||
private static final String KEY_UNKNOWN = "unknown";
|
private static final String KEY_UNKNOWN = "unknown";
|
||||||
private static final String KEY_STRING = "test1";
|
private static final String KEY_STRING = "test1";
|
||||||
@ -120,7 +120,7 @@ public class SecretResponseTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void getDataRoundtrip() throws InvalidResponseException {
|
void getDataRoundtrip() throws InvalidResponseException {
|
||||||
// Create empty Object.
|
// Create empty Object.
|
||||||
SecretResponse res = new SecretResponse();
|
SecretResponse res = new SecretResponse();
|
||||||
assertThat("Initial data should be Map", res.getData(), is(instanceOf(Map.class)));
|
assertThat("Initial data should be Map", res.getData(), is(instanceOf(Map.class)));
|
||||||
@ -156,7 +156,7 @@ public class SecretResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtrip() {
|
void jsonRoundtrip() {
|
||||||
try {
|
try {
|
||||||
assertSecretData(new ObjectMapper().readValue(SECRET_JSON, SecretResponse.class));
|
assertSecretData(new ObjectMapper().readValue(SECRET_JSON, SecretResponse.class));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.8
|
* @since 0.8
|
||||||
*/
|
*/
|
||||||
public class SecretVersionResponseTest {
|
class SecretVersionResponseTest {
|
||||||
private static final String CREATION_TIME = "2018-03-22T02:24:06.945319214Z";
|
private static final String CREATION_TIME = "2018-03-22T02:24:06.945319214Z";
|
||||||
private static final String DELETION_TIME = "2018-03-22T02:36:43.986212308Z";
|
private static final String DELETION_TIME = "2018-03-22T02:36:43.986212308Z";
|
||||||
private static final Integer VERSION = 42;
|
private static final Integer VERSION = 42;
|
||||||
@ -50,7 +50,7 @@ public class SecretVersionResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtrip() {
|
void jsonRoundtrip() {
|
||||||
try {
|
try {
|
||||||
SecretVersionResponse res = new ObjectMapper().readValue(META_JSON, SecretVersionResponse.class);
|
SecretVersionResponse res = new ObjectMapper().readValue(META_JSON, SecretVersionResponse.class);
|
||||||
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
||||||
|
@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
public class TokenResponseTest {
|
class TokenResponseTest {
|
||||||
private static final Integer TOKEN_CREATION_TIME = 1457533232;
|
private static final Integer TOKEN_CREATION_TIME = 1457533232;
|
||||||
private static final Integer TOKEN_TTL = 2764800;
|
private static final Integer TOKEN_TTL = 2764800;
|
||||||
private static final Integer TOKEN_EXPLICIT_MAX_TTL = 0;
|
private static final Integer TOKEN_EXPLICIT_MAX_TTL = 0;
|
||||||
@ -101,7 +101,7 @@ public class TokenResponseTest {
|
|||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getDataRoundtrip() {
|
void getDataRoundtrip() {
|
||||||
// Create empty Object.
|
// Create empty Object.
|
||||||
TokenResponse res = new TokenResponse();
|
TokenResponse res = new TokenResponse();
|
||||||
assertThat("Initial data should be empty", res.getData(), is(nullValue()));
|
assertThat("Initial data should be empty", res.getData(), is(nullValue()));
|
||||||
@ -119,7 +119,7 @@ public class TokenResponseTest {
|
|||||||
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
* Test creation from JSON value as returned by Vault (JSON example copied from Vault documentation).
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void jsonRoundtrip() {
|
void jsonRoundtrip() {
|
||||||
try {
|
try {
|
||||||
TokenResponse res = new ObjectMapper().readValue(RES_JSON, TokenResponse.class);
|
TokenResponse res = new ObjectMapper().readValue(RES_JSON, TokenResponse.class);
|
||||||
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
assertThat("Parsed response is NULL", res, is(notNullValue()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user