AthenzIdentityProviderImpl extends AbstractComponent implements AthenzIdentityProvider, ServiceIdentityProvider { private void registerInstance() { try { updateIdentityCredentials(this.athenzCredentialsService.registerInstance()); this.scheduler.scheduleAtFixedRate(this::refreshCertificate, UPDATE_PERIOD.toMinutes(), UPDATE_PERIOD.toMinutes(), TimeUnit.MINUTES); this.scheduler.scheduleAtFixedRate(this::reportMetrics, 0, 5, TimeUnit.MINUTES); } catch (Throwable t) { throw new AthenzIdentityProviderException("Could not retrieve Athenz credentials", t); } } @Inject  AthenzIdentityProviderImpl(IdentityConfig config, Metric metric);   AthenzIdentityProviderImpl(IdentityConfig config,
                               Metric metric,
                               Path trustStore,
                               AthenzCredentialsService athenzCredentialsService,
                               ScheduledExecutorService scheduler,
                               Clock clock); @Override AthenzService identity(); @Override String domain(); @Override String service(); @Override SSLContext getIdentitySslContext(); @Override X509CertificateWithKey getIdentityCertificateWithKey(); @Override Path certificatePath(); @Override Path privateKeyPath(); @Override Path athenzTruststorePath(); @Override Path clientTruststorePath(); @Override SSLContext getRoleSslContext(String domain, String role); @Override String getRoleToken(String domain); @Override String getRoleToken(String domain, String role); @Override String getAccessToken(String domain); @Override String getAccessToken(String domain, List<String> roles); @Override PrivateKey getPrivateKey(); @Override Path trustStorePath(); @Override List<X509Certificate> getIdentityCertificate(); @Override void deconstruct(); static final String CERTIFICATE_EXPIRY_METRIC_NAME; }
@Test(expected = AthenzIdentityProviderException.class) public void component_creation_fails_when_credentials_not_found() { AthenzCredentialsService credentialService = mock(AthenzCredentialsService.class); when(credentialService.registerInstance()) .thenThrow(new RuntimeException("athenz unavailable")); new AthenzIdentityProviderImpl(IDENTITY_CONFIG, mock(Metric.class), trustStoreFile ,credentialService, mock(ScheduledExecutorService.class), new ManualClock(Instant.EPOCH)); }