|
15 | 15 | import com.sun.net.httpserver.HttpServer; |
16 | 16 |
|
17 | 17 | import org.apache.logging.log4j.LogManager; |
18 | | -import org.apache.lucene.tests.util.LuceneTestCase; |
19 | 18 | import org.elasticsearch.common.settings.Settings; |
20 | 19 | import org.elasticsearch.core.Strings; |
21 | 20 | import org.elasticsearch.core.SuppressForbidden; |
|
45 | 44 | import java.util.Arrays; |
46 | 45 | import java.util.Map; |
47 | 46 | import java.util.concurrent.CountDownLatch; |
| 47 | +import java.util.concurrent.TimeUnit; |
48 | 48 | import java.util.function.Consumer; |
49 | 49 | import java.util.stream.Collectors; |
50 | 50 |
|
51 | | -@LuceneTestCase.AwaitsFix(bugUrl = "TODO NOMERGE") |
52 | 51 | public class CustomWebIdentityTokenCredentialsProviderTests extends ESTestCase { |
53 | 52 |
|
54 | 53 | private static final String ROLE_ARN = "arn:aws:iam::123456789012:role/FederatedWebIdentityRole"; |
@@ -111,7 +110,7 @@ private static HttpServer getHttpServer(Consumer<String> webIdentityTokenCheck) |
111 | 110 | """, |
112 | 111 | ROLE_ARN, |
113 | 112 | ROLE_NAME, |
114 | | - ZonedDateTime.now().plusDays(1L).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")) |
| 113 | + ZonedDateTime.now(Clock.systemUTC()).plusDays(1L).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ")) |
115 | 114 | ).getBytes(StandardCharsets.UTF_8); |
116 | 115 | exchange.sendResponseHeaders(RestStatus.OK.getStatus(), response.length); |
117 | 116 | exchange.getResponseBody().write(response); |
@@ -186,6 +185,7 @@ public void accept(String s) { |
186 | 185 | } |
187 | 186 |
|
188 | 187 | @SuppressForbidden(reason = "HTTP server is used for testing") |
| 188 | + @AwaitsFix(bugUrl = "TODO NOMERGE") |
189 | 189 | public void testPickUpNewWebIdentityTokenWhenItsChanged() throws Exception { |
190 | 190 | DelegatingConsumer webIdentityTokenCheck = new DelegatingConsumer(s -> assertEquals("YXdzLXdlYi1pZGVudGl0eS10b2tlbi1maWxl", s)); |
191 | 191 |
|
@@ -216,8 +216,9 @@ public void testPickUpNewWebIdentityTokenWhenItsChanged() throws Exception { |
216 | 216 | } |
217 | 217 | }); |
218 | 218 | Files.writeString(environment.configDir().resolve("repository-s3/aws-web-identity-token-file"), newWebIdentityToken); |
219 | | - |
220 | | - safeAwait(latch); |
| 219 | + do { |
| 220 | + assertCredentials(awsCredentialsProvider.resolveCredentials()); |
| 221 | + } while (latch.await(500, TimeUnit.MILLISECONDS) == false); |
221 | 222 | assertCredentials(awsCredentialsProvider.resolveCredentials()); |
222 | 223 | } finally { |
223 | 224 | webIdentityTokenCredentialsProvider.close(); |
|
0 commit comments