Skip to content

Commit 02d6818

Browse files
committed
[O2-5887] Detect if an empty URL is passed to the CCDB api.
1 parent e3fdb85 commit 02d6818

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CCDB/src/CcdbApi.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ void CcdbApi::curlInit()
164164

165165
void CcdbApi::init(std::string const& host)
166166
{
167+
if (host.empty()) {
168+
throw std::invalid_argument("Empty url passed CcdbApi, cannot initialize. Aborting.");
169+
}
170+
167171
// if host is prefixed with "file://" this is a local snapshot
168172
// in this case we init the API in snapshot (readonly) mode
169173
constexpr const char* SNAPSHOTPREFIX = "file://";

CCDB/test/testCcdbApi.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,4 +589,11 @@ BOOST_AUTO_TEST_CASE(vectored)
589589
for (auto context : contexts) {
590590
BOOST_CHECK(context.dest.size() != 0);
591591
}
592+
}
593+
594+
BOOST_AUTO_TEST_CASE(empty_url)
595+
{
596+
CcdbApi api;
597+
ccdbUrl = "";
598+
BOOST_CHECK_EXCEPTION(api.init(ccdbUrl), invalid_argument, [](std::invalid_argument const&) -> bool { return true; });
592599
}

0 commit comments

Comments
 (0)