Update gradle version to 8.0.2 (#104)

Update gradle version to 8.0.2

Signed-off-by: Max Lambrecht <max.lambrecht@hpe.com>
This commit is contained in:
Max Lambrecht 2023-04-12 13:16:22 -05:00 committed by GitHub
parent 0d0aae967f
commit e5600c3f4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 109 additions and 119 deletions

View File

@ -16,10 +16,11 @@ subprojects {
ext {
grpcVersion = '1.54.0'
jupiterVersion = '5.7.0'
mockitoVersion = '3.5.15'
jupiterVersion = '5.9.2'
mockitoVersion = '3.12.4'
lombokVersion = '1.18.20'
nimbusVersion = '9.31'
shadowVersion = '8.1.1'
//IMPORTANT: This must be in sync with the shaded netty version in gRPC
nettyVersion = '4.1.91.Final'
@ -107,6 +108,9 @@ subprojects {
testCompileOnly group: 'org.mockito', name: 'mockito-core', version: "${mockitoVersion}"
testRuntimeOnly group: 'org.mockito', name: 'mockito-junit-jupiter', version: "${mockitoVersion}"
testRuntimeOnly group: 'org.mockito', name: 'mockito-inline', version: "${mockitoVersion}"
testImplementation group: 'uk.org.webcompere', name: 'system-stubs-core', version: '2.0.2'
// Project Lombok dependency
compileOnly group: 'org.projectlombok', name: 'lombok', version: "${lombokVersion}"
@ -145,8 +149,8 @@ task jacocoTestReport(type: JacocoReport) {
}
reports {
xml.enabled true
html.enabled true
xml.required = true
html.required = true
}
}

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip

View File

@ -4,7 +4,7 @@ buildscript {
}
dependencies {
classpath group: 'com.google.protobuf', name: 'protobuf-gradle-plugin', version: '0.8.13'
classpath group: 'com.google.protobuf', name: 'protobuf-gradle-plugin', version: '0.9.2'
}
}
@ -31,6 +31,8 @@ sourceSets {
}
}
sourcesJar.duplicatesStrategy = DuplicatesStrategy.INCLUDE
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestCompile.extendsFrom testCompile

View File

@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import java.net.URI;
import java.util.stream.Stream;
@ -74,19 +75,24 @@ public class AddressTest {
@Test
void getDefaultAddress() throws Exception {
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test" );
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test").execute(() -> {
String defaultAddress = Address.getDefaultAddress();
assertEquals("unix:/tmp/test", defaultAddress);
});
}
@Test
void getDefaultAddress_isBlankThrowsException() throws Exception {
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "");
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "").execute(() -> {
try {
Address.getDefaultAddress();
fail();
} catch (Exception e) {
assertEquals("Endpoint Socket Address Environment Variable is not set: SPIFFE_ENDPOINT_SOCKET", e.getMessage());
}
});
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "").execute(() -> {
});
}
}

View File

@ -9,11 +9,11 @@ import io.spiffe.exception.SocketEndpointAddressException;
import io.spiffe.spiffeid.SpiffeId;
import io.spiffe.spiffeid.TrustDomain;
import io.spiffe.svid.jwtsvid.JwtSvid;
import io.spiffe.utils.TestUtils;
import lombok.val;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import java.io.IOException;
import java.time.Clock;
@ -495,8 +495,8 @@ class CachedJwtSourceTest {
@Test
void newSource_DefaultSocketAddress() throws Exception {
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test").execute(() -> {
try {
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test");
CachedJwtSource.newSource();
fail();
} catch (JwtSourceException e) {
@ -504,13 +504,13 @@ class CachedJwtSourceTest {
} catch (SocketEndpointAddressException e) {
fail();
}
});
}
@Test
void newSource_noSocketAddress() throws Exception {
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "").execute(() -> {
try {
// just in case it's defined in the environment
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "");
CachedJwtSource.newSource();
fail();
} catch (SocketEndpointAddressException e) {
@ -518,5 +518,6 @@ class CachedJwtSourceTest {
} catch (IllegalStateException e) {
assertEquals("Endpoint Socket Address Environment Variable is not set: SPIFFE_ENDPOINT_SOCKET", e.getMessage());
}
});
}
}

View File

@ -14,6 +14,7 @@ import lombok.val;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import java.io.IOException;
import java.time.Duration;
@ -257,8 +258,8 @@ class DefaultJwtSourceTest {
@Test
void newSource_DefaultSocketAddress() throws Exception {
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test").execute(() -> {
try {
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test");
DefaultJwtSource.newSource();
fail();
} catch (JwtSourceException e) {
@ -266,13 +267,13 @@ class DefaultJwtSourceTest {
} catch (SocketEndpointAddressException e) {
fail();
}
});
}
@Test
void newSource_noSocketAddress() throws Exception {
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "").execute(() -> {
try {
// just in case it's defined in the environment
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "");
DefaultJwtSource.newSource();
fail();
} catch (SocketEndpointAddressException e) {
@ -280,5 +281,6 @@ class DefaultJwtSourceTest {
} catch (IllegalStateException e) {
assertEquals("Endpoint Socket Address Environment Variable is not set: SPIFFE_ENDPOINT_SOCKET", e.getMessage());
}
});
}
}

View File

@ -20,6 +20,7 @@ import org.junit.Rule;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import java.io.IOException;
import java.security.KeyPair;
@ -54,13 +55,14 @@ class DefaultWorkloadApiClientTest {
@Test
void testNewClient_defaultOptions() throws Exception {
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/agent.sock").execute(() -> {
try {
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/agent.sock");
WorkloadApiClient client = DefaultWorkloadApiClient.newClient();
assertNotNull(client);
} catch (SocketEndpointAddressException e) {
fail(e);
}
});
}
@Test

View File

@ -7,11 +7,11 @@ import io.spiffe.exception.X509SourceException;
import io.spiffe.spiffeid.SpiffeId;
import io.spiffe.spiffeid.TrustDomain;
import io.spiffe.svid.x509svid.X509Svid;
import io.spiffe.utils.TestUtils;
import lombok.val;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import java.time.Duration;
@ -162,9 +162,8 @@ class DefaultX509SourceTest {
@Test
void newSource_noSocketAddress() throws Exception {
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "").execute(() -> {
try {
// just in case the variable is defined in the environment
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "");
DefaultX509Source.newSource();
fail();
} catch (X509SourceException | SocketEndpointAddressException e) {
@ -172,5 +171,6 @@ class DefaultX509SourceTest {
} catch (IllegalStateException e) {
assertEquals("Endpoint Socket Address Environment Variable is not set: SPIFFE_ENDPOINT_SOCKET", e.getMessage());
}
});
}
}

View File

@ -107,38 +107,7 @@ public class TestUtils {
.build();
}
public static void setEnvironmentVariable(String variableName, String value) throws Exception {
Class<?> processEnvironment = Class.forName("java.lang.ProcessEnvironment");
Field unmodifiableMapField = getField(processEnvironment, "theUnmodifiableEnvironment");
Object unmodifiableMap = unmodifiableMapField.get(null);
injectIntoUnmodifiableMap(variableName, value, unmodifiableMap);
Field mapField = getField(processEnvironment, "theEnvironment");
Map<String, String> map = (Map<String, String>) mapField.get(null);
map.put(variableName, value);
}
public static Object invokeMethod(Class<?> clazz, String methodName, Object... args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Method method = clazz.getDeclaredMethod(methodName);
method.setAccessible(true);
return method.invoke(args);
}
public static Field getField(Class<?> clazz, String fieldName) throws NoSuchFieldException {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return field;
}
public static URI toUri(String path) throws URISyntaxException {
return Thread.currentThread().getContextClassLoader().getResource(path).toURI();
}
private static void injectIntoUnmodifiableMap(String key, String value, Object map) throws ReflectiveOperationException {
Class unmodifiableMap = Class.forName("java.util.Collections$UnmodifiableMap");
Field field = getField(unmodifiableMap, "m");
Object obj = field.get(map);
((Map<String, String>) obj).put(key, value);
}
}

View File

@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "5.2.0"
id "com.github.johnrengelman.shadow" version "${shadowVersion}"
}
description = "Java SPIFFE Library Helper module to store X.509 SVIDs and Bundles in a Java KeyStore in disk"

View File

@ -13,6 +13,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import java.io.IOException;
import java.nio.file.Files;
@ -190,13 +191,14 @@ class KeyStoreHelperTest {
@Test
void testCreateKeyStoreHelper_createNewClient() throws Exception {
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test");
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test").execute(() -> {
val options = getKeyStoreValidOptions(null);
try {
KeyStoreHelper.create(options);
} catch (KeyStoreHelperException e) {
fail();
}
});
}
@Test

View File

@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "5.2.0"
id "com.github.johnrengelman.shadow" version "${shadowVersion}"
}
description = "Java Security Provider implementation supporting X.509-SVIDs and methods for " +

View File

@ -4,6 +4,7 @@ import io.spiffe.utils.TestUtils;
import io.spiffe.workloadapi.Address;
import io.spiffe.workloadapi.X509Source;
import org.junit.jupiter.api.Test;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import java.lang.reflect.Field;
@ -24,11 +25,12 @@ class X509SourceManagerTest {
@Test
void getX509Source_defaultAddressNotSet() throws Exception {
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "" );
new EnvironmentVariables(Address.SOCKET_ENV_VARIABLE, "").execute(() -> {
try {
X509SourceManager.getX509Source();
} catch (IllegalStateException e) {
assertEquals("Endpoint Socket Address Environment Variable is not set: SPIFFE_ENDPOINT_SOCKET", e.getMessage());
}
});
}
}