Fix CachedJwtSource tests (#120)

Signed-off-by: Max Lambrecht <max.lambrecht@hpe.com>
This commit is contained in:
Max Lambrecht 2023-04-10 15:02:27 -05:00 committed by GitHub
parent 50208a709a
commit c3dc4950e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -40,7 +40,7 @@ class CachedJwtSourceTest {
void setUp() throws JwtSourceException, SocketEndpointAddressException { void setUp() throws JwtSourceException, SocketEndpointAddressException {
workloadApiClient = new WorkloadApiClientStub(); workloadApiClient = new WorkloadApiClientStub();
JwtSourceOptions options = JwtSourceOptions.builder().workloadApiClient(workloadApiClient).build(); JwtSourceOptions options = JwtSourceOptions.builder().workloadApiClient(workloadApiClient).build();
System.setProperty(DefaultJwtSource.TIMEOUT_SYSTEM_PROPERTY, "PT1S"); System.setProperty(CachedJwtSource.TIMEOUT_SYSTEM_PROPERTY, "PT1S");
jwtSource = (CachedJwtSource) CachedJwtSource.newSource(options); jwtSource = (CachedJwtSource) CachedJwtSource.newSource(options);
workloadApiClientErrorStub = new WorkloadApiClientErrorStub(); workloadApiClientErrorStub = new WorkloadApiClientErrorStub();
@ -439,7 +439,7 @@ class CachedJwtSourceTest {
.initTimeout(Duration.ofSeconds(0)) .initTimeout(Duration.ofSeconds(0))
.build(); .build();
try { try {
JwtSource jwtSource = DefaultJwtSource.newSource(options); JwtSource jwtSource = CachedJwtSource.newSource(options);
assertNotNull(jwtSource); assertNotNull(jwtSource);
} catch (SocketEndpointAddressException | JwtSourceException e) { } catch (SocketEndpointAddressException | JwtSourceException e) {
fail(e); fail(e);
@ -449,7 +449,7 @@ class CachedJwtSourceTest {
@Test @Test
void newSource_nullParam() { void newSource_nullParam() {
try { try {
DefaultJwtSource.newSource(null); CachedJwtSource.newSource(null);
fail(); fail();
} catch (NullPointerException e) { } catch (NullPointerException e) {
assertEquals("options is marked non-null but is null", e.getMessage()); assertEquals("options is marked non-null but is null", e.getMessage());
@ -466,7 +466,7 @@ class CachedJwtSourceTest {
.spiffeSocketPath("unix:/tmp/test") .spiffeSocketPath("unix:/tmp/test")
.build(); .build();
try { try {
DefaultJwtSource.newSource(options); CachedJwtSource.newSource(options);
fail(); fail();
} catch (JwtSourceException e) { } catch (JwtSourceException e) {
assertEquals("Error creating JWT source", e.getMessage()); assertEquals("Error creating JWT source", e.getMessage());
@ -483,7 +483,7 @@ class CachedJwtSourceTest {
.builder() .builder()
.spiffeSocketPath("unix:/tmp/test") .spiffeSocketPath("unix:/tmp/test")
.build(); .build();
DefaultJwtSource.newSource(options); CachedJwtSource.newSource(options);
fail(); fail();
} catch (JwtSourceException e) { } catch (JwtSourceException e) {
assertEquals("Error creating JWT source", e.getMessage()); assertEquals("Error creating JWT source", e.getMessage());
@ -497,7 +497,7 @@ class CachedJwtSourceTest {
void newSource_DefaultSocketAddress() throws Exception { void newSource_DefaultSocketAddress() throws Exception {
try { try {
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test"); TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "unix:/tmp/test");
DefaultJwtSource.newSource(); CachedJwtSource.newSource();
fail(); fail();
} catch (JwtSourceException e) { } catch (JwtSourceException e) {
assertEquals("Error creating JWT source", e.getMessage()); assertEquals("Error creating JWT source", e.getMessage());
@ -511,7 +511,7 @@ class CachedJwtSourceTest {
try { try {
// just in case it's defined in the environment // just in case it's defined in the environment
TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, ""); TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "");
DefaultJwtSource.newSource(); CachedJwtSource.newSource();
fail(); fail();
} catch (SocketEndpointAddressException e) { } catch (SocketEndpointAddressException e) {
fail(); fail();