mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 08:49:58 +00:00
Move secrets for live tests into a property file, so missing that file won't fail the build.
This commit is contained in:
parent
6c1ee94b91
commit
7e172d2aaf
8 changed files with 33 additions and 34 deletions
|
@ -20,8 +20,10 @@ package de.schildbach.pte.live;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -139,4 +141,25 @@ public abstract class AbstractProviderLiveTest
|
|||
{
|
||||
return provider.queryMoreTrips(context, later);
|
||||
}
|
||||
|
||||
protected final static String secretProperty(final String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Properties properties = new Properties();
|
||||
final String secretPropertiesFilename = "secrets.properties";
|
||||
final InputStream is = AbstractProviderLiveTest.class.getResourceAsStream(secretPropertiesFilename);
|
||||
if (is == null)
|
||||
throw new IllegalStateException("Could not find secret property file " + secretPropertiesFilename + " in classpath.");
|
||||
properties.load(is);
|
||||
final String secret = properties.getProperty(key);
|
||||
if (secret == null)
|
||||
throw new IllegalStateException("Could not find secret value for '" + key + "' in " + secretPropertiesFilename + ".");
|
||||
return secret;
|
||||
}
|
||||
catch (final IOException x)
|
||||
{
|
||||
throw new RuntimeException(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue