|
37 | 37 | import java.util.concurrent.atomic.AtomicInteger;
|
38 | 38 | import java.util.function.Supplier;
|
39 | 39 |
|
| 40 | +import com.microsoft.aad.msal4j.IAccount; |
| 41 | +import com.microsoft.aad.msal4j.ITenantProfile; |
40 | 42 | import org.awaitility.Awaitility;
|
41 | 43 | import org.awaitility.Durations;
|
42 | 44 | import org.junit.Test;
|
|
64 | 66 | import redis.clients.authentication.entraid.EntraIDTokenAuthConfigBuilder;
|
65 | 67 | import redis.clients.authentication.entraid.JWToken;
|
66 | 68 | import redis.clients.authentication.entraid.ManagedIdentityInfo;
|
| 69 | +import redis.clients.authentication.entraid.RedisEntraIDException; |
67 | 70 | import redis.clients.authentication.entraid.ServicePrincipalInfo;
|
68 | 71 | import redis.clients.authentication.entraid.ManagedIdentityInfo.UserManagedIdentityType;
|
69 | 72 |
|
@@ -143,6 +146,28 @@ public void testConfigBuilder() {
|
143 | 146 | }
|
144 | 147 | }
|
145 | 148 |
|
| 149 | + @Test |
| 150 | + public void testConfigBuilderThrowsErrorIfMissconfigured() { |
| 151 | + |
| 152 | + // Missing Configuration |
| 153 | + assertThrows(RedisEntraIDException.class,() -> EntraIDTokenAuthConfigBuilder.builder().build()); |
| 154 | + |
| 155 | + // spi & mpi configured |
| 156 | + assertThrows(RedisEntraIDException.class,() -> EntraIDTokenAuthConfigBuilder.builder() |
| 157 | + .clientId("clientid") |
| 158 | + .secret("secret") |
| 159 | + .systemAssignedManagedIdentity() |
| 160 | + .build()); |
| 161 | + |
| 162 | + // spi || mpi && customEntraIdAuthenticationSupplier configured |
| 163 | + assertThrows(RedisEntraIDException.class,() -> EntraIDTokenAuthConfigBuilder.builder() |
| 164 | + .clientId("clientid") |
| 165 | + .secret("secret") |
| 166 | + .customEntraIdAuthenticationSupplier(() -> mock(IAuthenticationResult.class)) |
| 167 | + .build()); |
| 168 | + } |
| 169 | + |
| 170 | + |
146 | 171 | // T.1.2
|
147 | 172 | // Implement a stubbed IdentityProvider and verify that the TokenManager works normally and handles:
|
148 | 173 | // network errors or other exceptions thrown from the IdentityProvider
|
@@ -529,6 +554,7 @@ public void renewalTimingConfigTest() {
|
529 | 554 | int maxAttemptsToRetry = 6;
|
530 | 555 | int tokenRequestExecTimeoutInMs = 401;
|
531 | 556 | TokenAuthConfig tokenAuthConfig = EntraIDTokenAuthConfigBuilder.builder()
|
| 557 | + .clientId("testClientId").secret("testSecret") |
532 | 558 | .expirationRefreshRatio(refreshRatio).delayInMsToRetry(delayInMsToRetry)
|
533 | 559 | .lowerRefreshBoundMillis(lowerRefreshBoundMillis)
|
534 | 560 | .maxAttemptsToRetry(maxAttemptsToRetry)
|
|
0 commit comments