diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/test/TestURL.cpp | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/test/TestURL.cpp')
-rw-r--r-- | xbmc/test/TestURL.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/xbmc/test/TestURL.cpp b/xbmc/test/TestURL.cpp new file mode 100644 index 0000000..e74d3be --- /dev/null +++ b/xbmc/test/TestURL.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "URL.h" + +#include <gtest/gtest.h> + +using ::testing::Test; +using ::testing::WithParamInterface; +using ::testing::ValuesIn; + +struct TestURLGetWithoutUserDetailsData +{ + std::string input; + std::string expected; + bool redact; +}; + +std::ostream& operator<<(std::ostream& os, + const TestURLGetWithoutUserDetailsData& rhs) +{ + return os << "(Input: " << rhs.input << + "; Redact: " << (rhs.redact?"true":"false") << + "; Expected: " << rhs.expected << ")"; +} + +class TestURLGetWithoutUserDetails : public Test, + public WithParamInterface<TestURLGetWithoutUserDetailsData> +{ +}; + +TEST_P(TestURLGetWithoutUserDetails, GetWithoutUserDetails) +{ + CURL input(GetParam().input); + std::string result = input.GetWithoutUserDetails(GetParam().redact); + EXPECT_EQ(result, GetParam().expected); +} + +const TestURLGetWithoutUserDetailsData values[] = { + { std::string("smb://example.com/example"), std::string("smb://example.com/example"), false }, + { std::string("smb://example.com/example"), std::string("smb://example.com/example"), true }, + { std::string("smb://god:universe@example.com/example"), std::string("smb://example.com/example"), false }, + { std::string("smb://god@example.com/example"), std::string("smb://USERNAME@example.com/example"), true }, + { std::string("smb://god:universe@example.com/example"), std::string("smb://USERNAME:PASSWORD@example.com/example"), true }, + { std::string("http://god:universe@example.com:8448/example|auth=digest"), std::string("http://USERNAME:PASSWORD@example.com:8448/example|auth=digest"), true }, + { std::string("smb://fd00::1/example"), std::string("smb://fd00::1/example"), false }, + { std::string("smb://fd00::1/example"), std::string("smb://fd00::1/example"), true }, + { std::string("smb://[fd00::1]:8080/example"), std::string("smb://[fd00::1]:8080/example"), false }, + { std::string("smb://[fd00::1]:8080/example"), std::string("smb://[fd00::1]:8080/example"), true }, + { std::string("smb://god:universe@[fd00::1]:8080/example"), std::string("smb://[fd00::1]:8080/example"), false }, + { std::string("smb://god@[fd00::1]:8080/example"), std::string("smb://USERNAME@[fd00::1]:8080/example"), true }, + { std::string("smb://god:universe@fd00::1/example"), std::string("smb://USERNAME:PASSWORD@fd00::1/example"), true }, + { std::string("http://god:universe@[fd00::1]:8448/example|auth=digest"), std::string("http://USERNAME:PASSWORD@[fd00::1]:8448/example|auth=digest"), true }, + { std::string("smb://00ff:1:0000:abde::/example"), std::string("smb://00ff:1:0000:abde::/example"), true }, + { std::string("smb://god:universe@[00ff:1:0000:abde::]:8080/example"), std::string("smb://[00ff:1:0000:abde::]:8080/example"), false }, + { std::string("smb://god@[00ff:1:0000:abde::]:8080/example"), std::string("smb://USERNAME@[00ff:1:0000:abde::]:8080/example"), true }, + { std::string("smb://god:universe@00ff:1:0000:abde::/example"), std::string("smb://USERNAME:PASSWORD@00ff:1:0000:abde::/example"), true }, + { std::string("http://god:universe@[00ff:1:0000:abde::]:8448/example|auth=digest"), std::string("http://USERNAME:PASSWORD@[00ff:1:0000:abde::]:8448/example|auth=digest"), true }, + { std::string("smb://milkyway;god:universe@example.com/example"), std::string("smb://DOMAIN;USERNAME:PASSWORD@example.com/example"), true }, + { std::string("smb://milkyway;god@example.com/example"), std::string("smb://DOMAIN;USERNAME@example.com/example"), true }, + { std::string("smb://milkyway;@example.com/example"), std::string("smb://example.com/example"), true }, + { std::string("smb://milkyway;god:universe@example.com/example"), std::string("smb://example.com/example"), false }, + { std::string("smb://milkyway;god@example.com/example"), std::string("smb://example.com/example"), false }, + { std::string("smb://milkyway;@example.com/example"), std::string("smb://example.com/example"), false }, +}; + +INSTANTIATE_TEST_SUITE_P(URL, TestURLGetWithoutUserDetails, ValuesIn(values)); |