diff --git a/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java b/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java index 3694451955..05e90626c5 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java +++ b/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java @@ -428,7 +428,9 @@ public class EcrService implements ResourceProvider { // ============================================================ public AuthorizationData getAuthorizationToken() { - requireRegistry(); + // Deliberately not gated on the backing registry: AWS answers this call from the + // control plane, and both values here are computed without Docker. Gating it made + // every SDK client retry a 500 before its first repository call. String token = Base64.getEncoder() .encodeToString("AWS:floci".getBytes(StandardCharsets.UTF_8)); Instant expires = Instant.now().plusSeconds(12 * 60 * 60); diff --git a/src/test/java/io/github/hectorvent/floci/services/ecr/EcrServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/ecr/EcrServiceTest.java index 255e4e3c9e..ff3a8d4c89 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ecr/EcrServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ecr/EcrServiceTest.java @@ -375,11 +375,6 @@ class EcrServiceTest { service.createRepository(REPO, null, null, null, null, null, null, REGION); when(registryManager.tryEnsureStarted()).thenReturn(false); - AwsException auth = assertThrows(AwsException.class, () -> service.getAuthorizationToken()); - assertEquals("ServerException", auth.getErrorCode()); - assertEquals(500, auth.getHttpStatus()); - assertTrue(auth.getMessage().contains("Docker"), auth.getMessage()); - assertEquals("ServerException", assertThrows(AwsException.class, () -> service.listImages(REPO, null, REGION)).getErrorCode()); assertEquals("ServerException", @@ -393,6 +388,19 @@ class EcrServiceTest { () -> service.batchDeleteImage(REPO, List.of(), null, REGION)).getErrorCode()); } + @Test + void getAuthorizationToken_succeedsWhenRegistryIsUnavailable() { + when(registryManager.tryEnsureStarted()).thenReturn(false); + + AuthorizationData data = service.getAuthorizationToken(); + + String decoded = new String(Base64.getDecoder().decode(data.getAuthorizationToken())); + assertTrue(decoded.startsWith("AWS:"), "decoded token should start with AWS: but was: " + decoded); + assertEquals("http://localhost:4566", data.getProxyEndpoint()); + assertNotNull(data.getExpiresAt()); + verify(registryManager, never()).tryEnsureStarted(); + } + // ------------------------------------------------------------ // DescribeRepositories // ------------------------------------------------------------ @@ -567,7 +575,7 @@ class EcrServiceTest { assertNotNull(data.getExpiresAt()); String decoded = new String(Base64.getDecoder().decode(data.getAuthorizationToken())); assertTrue(decoded.startsWith("AWS:"), "decoded token should start with AWS: but was: " + decoded); - Mockito.verify(registryManager).tryEnsureStarted(); + verify(registryManager, never()).tryEnsureStarted(); } @Test