[render-test] Add access token to the test manifest

Needed if we want to run tests online. Will default to the
MAPBOX_ACCESS_TOKEN environment value.
This commit is contained in:
Thiago Marcos P. Santos
2019-12-21 01:48:04 +02:00
parent 4d815d8306
commit 26cfddaf47
2 changed files with 27 additions and 1 deletions

View File

@@ -22,7 +22,13 @@ std::string prependFileScheme(const std::string& url) {
}
} // namespace
Manifest::Manifest() = default;
Manifest::Manifest() {
const char* envToken = getenv("MAPBOX_ACCESS_TOKEN");
if (envToken != nullptr) {
accessToken = envToken;
}
}
Manifest::~Manifest() = default;
const std::vector<TestPaths>& Manifest::getTestPaths() const {
@@ -48,6 +54,10 @@ const std::string& Manifest::getCachePath() const {
return cachePath;
}
const std::string& Manifest::getAccessToken() const {
return accessToken;
}
const std::set<std::string>& Manifest::getProbes() const {
return probes;
}
@@ -321,6 +331,19 @@ mbgl::optional<Manifest> ManifestParser::parseManifest(const std::string& manife
return mbgl::nullopt;
}
}
if (document.HasMember("access_token")) {
const auto& accessTokenValue = document["access_token"];
if (!accessTokenValue.IsString()) {
mbgl::Log::Warning(mbgl::Event::General,
"Invalid access_token is provided inside the manifest file: %s",
filePath.c_str());
return mbgl::nullopt;
}
manifest.accessToken = accessTokenValue.GetString();
if (manifest.accessToken.empty()) {
return mbgl::nullopt;
}
}
mbgl::filesystem::path baseTestPath;
if (document.HasMember("base_test_path")) {
const auto& testPathValue = document["base_test_path"];