@Test public void exceptionThrownIfKeyVaultConfigUrlSyntaxIncorrect() { when(envProvider.getEnv(HASHICORP_ROLE_ID)).thenReturn("role-id"); when(envProvider.getEnv(HASHICORP_SECRET_ID)).thenReturn("secret-id"); when(envProvider.getEnv(HASHICORP_TOKEN)).thenReturn("token"); KeyConfiguration keyConfiguration = mock(KeyConfiguration.class); when(config.getKeys()).thenReturn(keyConfiguration); DefaultKeyVaultConfig keyVaultConfig = mock(DefaultKeyVaultConfig.class); when(keyConfiguration.getKeyVaultConfig(KeyVaultType.HASHICORP)).thenReturn(Optional.of(keyVaultConfig)); when(keyVaultConfig.getProperty("url")).thenReturn(Optional.of("noschemeurl")); when(keyVaultConfig.getProperty("approlePath")).thenReturn(Optional.of("approle")); setUpUtilMocks(keyVaultConfig); Throwable ex = catchThrowable(() -> keyVaultServiceFactory.create(config, envProvider, keyVaultServiceFactoryUtil)); assertThat(ex).isExactlyInstanceOf(ConfigException.class); assertThat(ex.getMessage()).contains("Provided Hashicorp Vault url is incorrectly formatted"); }
@Override public KeyVaultService create(Config config, EnvironmentVariableProvider envProvider) { Objects.requireNonNull(config); Objects.requireNonNull(envProvider); HashicorpKeyVaultServiceFactoryUtil util = new HashicorpKeyVaultServiceFactoryUtil(); return this.create(config, envProvider, util); }
HashicorpKeyVaultServiceFactory implements KeyVaultServiceFactory { @Override public KeyVaultService create(Config config, EnvironmentVariableProvider envProvider) { Objects.requireNonNull(config); Objects.requireNonNull(envProvider); HashicorpKeyVaultServiceFactoryUtil util = new HashicorpKeyVaultServiceFactoryUtil(); return this.create(config, envProvider, util); } }
HashicorpKeyVaultServiceFactory implements KeyVaultServiceFactory { @Override public KeyVaultService create(Config config, EnvironmentVariableProvider envProvider) { Objects.requireNonNull(config); Objects.requireNonNull(envProvider); HashicorpKeyVaultServiceFactoryUtil util = new HashicorpKeyVaultServiceFactoryUtil(); return this.create(config, envProvider, util); }  }
HashicorpKeyVaultServiceFactory implements KeyVaultServiceFactory { @Override public KeyVaultService create(Config config, EnvironmentVariableProvider envProvider) { Objects.requireNonNull(config); Objects.requireNonNull(envProvider); HashicorpKeyVaultServiceFactoryUtil util = new HashicorpKeyVaultServiceFactoryUtil(); return this.create(config, envProvider, util); }  @Override KeyVaultService create(Config config, EnvironmentVariableProvider envProvider); @Override KeyVaultType getType(); }
HashicorpKeyVaultServiceFactory implements KeyVaultServiceFactory { @Override public KeyVaultService create(Config config, EnvironmentVariableProvider envProvider) { Objects.requireNonNull(config); Objects.requireNonNull(envProvider); HashicorpKeyVaultServiceFactoryUtil util = new HashicorpKeyVaultServiceFactoryUtil(); return this.create(config, envProvider, util); }  @Override KeyVaultService create(Config config, EnvironmentVariableProvider envProvider); @Override KeyVaultType getType();  }