@BeforeClass
    public static void beforeClass() throws Exception {
        originalAuthLocatorSingleton = RegistryAuthLocator.instance();

        String testRegistryAddress = authenticatedRegistry.getEndpoint();

        final AuthConfig authConfig = new AuthConfig()
            .withUsername("testuser")
            .withPassword("notasecret")
            .withRegistryAddress("http://" + testRegistryAddress);

        // Replace the RegistryAuthLocator singleton with our mock, for the duration of this test
        final RegistryAuthLocator mockAuthLocator = Mockito.mock(RegistryAuthLocator.class);
        RegistryAuthLocator.setInstance(mockAuthLocator);
        when(
            mockAuthLocator.lookupAuthConfig(
                argThat(argument -> testRegistryAddress.equals(argument.getRegistry())),
                any()
            )
        )
            .thenReturn(authConfig);
    }
Containerised docker image registry, with simple hardcoded credentials
core/src/test/java/org/testcontainers/utility/AuthenticatedImagePullTest.java