/* * 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 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 { }; 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));