mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 21:48:50 +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
|
@ -1 +1 @@
|
|||
Secrets.java
|
||||
secrets.properties
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ParisProviderLiveTest extends AbstractNavitiaProviderLiveTest
|
|||
{
|
||||
public ParisProviderLiveTest()
|
||||
{
|
||||
super(new ParisProvider(Secrets.NAVITIA_AUTHORIZATION));
|
||||
super(new ParisProvider(secretProperty("navitia.authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2015 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte.live;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public final class Secrets
|
||||
{
|
||||
public static final String VGN_API_BASE = "insert vgn base here";
|
||||
public static final String NAVITIA_AUTHORIZATION = "insert navitia authorization here";
|
||||
public static final String VBN_JSON_API_AUTHORIZATION = "insert vao authorization here";
|
||||
public static final String VAO_JSON_API_AUTHORIZATION = "insert vao authorization here";
|
||||
}
|
|
@ -41,7 +41,7 @@ public class VaoProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
public VaoProviderLiveTest()
|
||||
{
|
||||
super(new VaoProvider(Secrets.VAO_JSON_API_AUTHORIZATION));
|
||||
super(new VaoProvider(secretProperty("vao.json_api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -44,7 +44,7 @@ public class VbnProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
public VbnProviderLiveTest()
|
||||
{
|
||||
super(new VbnProvider(Secrets.VBN_JSON_API_AUTHORIZATION));
|
||||
super(new VbnProvider(secretProperty("vbn.json_api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,7 +42,7 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
public VgnProviderLiveTest()
|
||||
{
|
||||
super(new VgnProvider(Secrets.VGN_API_BASE));
|
||||
super(new VgnProvider(secretProperty("vgn.api_base")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
# Secrets are needed to run some of the live tests.
|
||||
vgn.api_base =
|
||||
navitia.authorization =
|
||||
vbn.json_api_authorization =
|
||||
vao.json_api_authorization =
|
Loading…
Add table
Add a link
Reference in a new issue